Compare commits

...

105 commits

Author SHA1 Message Date
Brent Rubell
1f87e56290
Merge pull request #175 from brentru/update-fingerprint-2025
Update SSL Fingerprint for 2025
2025-07-16 10:15:05 -04:00
brentru
e67e9229c6 Match clang diff 2025-07-14 16:11:09 -04:00
brentru
36b88bb9da Update SSL fingerprint 2025-07-14 16:02:21 -04:00
Tyeth Gundry
93251aaae4
Merge pull request #174 from adafruit/update-schedule-example
Update schedule example
2025-05-14 17:47:52 +01:00
tyeth
ef46ac5a67 clang format config.h files 2025-05-14 17:42:54 +01:00
Tyeth Gundry
6e2de69a8e
Update library.properties 2025-05-14 17:34:09 +01:00
Tyeth Gundry
527328e376
Update adafruitio_25_schedule_trigger.ino - make values wipper compatible 2025-05-14 17:33:49 +01:00
Brent Rubell
04e52a3f2d
Merge pull request #171 from brentru/master
Add support for RP2040/PicoW
2024-04-01 15:58:57 -04:00
brentru
a9a9c19531 add 2x skipfiles 2024-04-01 15:39:43 -04:00
brentru
7c3049e55b test works 2024-04-01 15:38:42 -04:00
brentru
b21d7637da add rp2040 2024-04-01 12:43:56 -04:00
Brent Rubell
7f04b63811
Merge pull request #169 from brentru/fix-for-esp32-backwards-compat
Add backwards compatibility with ESP32 BSP's stable release
2023-10-12 12:23:26 -04:00
brentru
e9867fb1d6 backwards compat with stable release 2023-10-11 18:27:19 -04:00
Brent Rubell
a76e50bc69
Merge pull request #168 from brentru/fixes-for-esp-3-alpha
Fixes warnings introduced by ESP32 BSP 3.0.0 alpha 1
2023-10-11 15:50:40 -04:00
brentru
140f13febc match ledcWrite_RGB example in esp32 docs 2023-10-11 15:12:31 -04:00
brentru
0f94088d28 fixes for ledc, servo lib is broken and external so we cantfix/wontfix 2023-10-11 14:37:32 -04:00
brentru
e1ace0ac6f add lib prop 2023-10-11 14:06:36 -04:00
brentru
2e73006040 fix one more 2023-10-11 13:42:22 -04:00
brentru
db939d7405 fix werror=address 2023-10-11 12:45:14 -04:00
Brent Rubell
4d87df2528
Update library.properties 2023-07-21 10:53:13 -04:00
Justin Cooper
a2bb62a930
Merge pull request #167 from adafruit/root-ca-update
Update AdafruitIO_ESP32.h with new root ca
2023-07-21 09:52:54 -05:00
Justin Cooper
d06616eadf latest ssl fingerprint 2023-07-21 09:32:21 -05:00
Justin Cooper
3eebc74f01
Update AdafruitIO_ESP32.h with new root ca 2023-07-21 09:17:52 -05:00
dherrada
5e70cdb719 Update CI action versions 2023-05-12 11:24:00 -04:00
Brent Rubell
a2d84decef
Update library.properties 2023-05-04 18:24:00 -04:00
Brent Rubell
28fc13d597
Merge pull request #166 from adafruit/revert-165-fix-esp-bsp-2-0-8
Revert "Fix connectErrorString return type for ESP-32 BSP 2.0.8"
2023-05-04 18:23:35 -04:00
Brent Rubell
f75cb9d14d
Revert "Fix connectErrorString return type for ESP-32 BSP 2.0.8" 2023-05-04 14:35:24 -04:00
Brent Rubell
e3c27cd196
Merge pull request #165 from brentru/fix-esp-bsp-2-0-8
Fix connectErrorString return type for ESP-32 BSP 2.0.8
2023-04-24 10:37:11 -04:00
brentru
88e85694a2 match a94f4d512e 2023-04-21 15:41:49 -04:00
brentru
0e2cdf61f8 fix ; at end of ifdef? 2023-04-21 13:49:40 -04:00
brentru
a770ba9357 add preproc for return types 2023-04-21 13:08:55 -04:00
Brent Rubell
a21c9a3999
Merge pull request #161 from bradrblack/WiFiManager-Example
Adding WiFiManager Example Sketches
2022-08-30 16:25:55 -04:00
bradrblack
5b33739f12 updated library properties with 4.2.3 version 2022-08-30 14:35:29 -04:00
bradrblack
4240f3c2d9 removed wifi power cmd 2022-08-22 19:54:40 -04:00
bradrblack
36f3437eb8 updated library.properties - removed LittleFS 2022-08-22 19:25:19 -04:00
bradrblack
534cbbcb54 Merge branch 'WiFiManager-Example' of https://github.com/bradrblack/Adafruit_IO_Arduino into WiFiManager-Example 2022-08-22 17:39:19 -04:00
bradrblack
4ac3fde145 updated library.properties with ArduinoJson and LittleFS 2022-08-22 17:20:15 -04:00
bradrblack
963c452ade
Rename pyportal.test.skip to .pyportal.test.skip 2022-08-22 15:47:10 -04:00
bradrblack
a47e7b9f24
Rename metro_m4_airliftlite.test.skip to .metro_m4_airliftlite.test.skip 2022-08-22 15:46:44 -04:00
bradrblack
ccf9875bf2
Rename metro_m4_airliftlite.test.skip to .metro_m4_airliftlite.test.skip 2022-08-22 15:46:25 -04:00
bradrblack
98e4941945
Rename pyportal.test.skip to .pyportal.test.skip 2022-08-22 15:45:51 -04:00
bradrblack
3cfe5b96c1
Delete metro_m4_airlist.test.skip 2022-08-22 13:26:47 -04:00
bradrblack
790534521b
Delete metro_m4_airlist.test.skip 2022-08-22 13:26:28 -04:00
bradrblack
fe5050c6db fixed wrong skip filenames 2022-08-22 13:25:07 -04:00
bradrblack
fbe050e179 add CI skip files and updated library.properties 2022-08-22 13:14:31 -04:00
bradrblack
a00c8b20a4 Minor fixes - typos - removed unused code 2022-08-20 08:09:21 -04:00
bradrblack
f3ff8ea03a Minor changes 2022-08-19 14:53:26 -04:00
bradrblack
eb3379d6c5 Adding new example with custom AIO parameters 2022-08-19 14:28:15 -04:00
bradrblack
97d093dc29 Moving example sketch to subdir 2022-08-19 12:17:37 -04:00
bradrblack
d98ea30a2c Revert "Adding WiFiManager Example Sketch"
This reverts commit af5f7cc170.
2022-08-19 12:15:44 -04:00
bradrblack
af5f7cc170 Adding WiFiManager Example Sketch 2022-08-18 18:14:12 -04:00
Brent Rubell
848e3eafd3
Merge pull request #159 from brentru/fix-fallthrough-error
Fix ESP8266 fallthrough patch causing memory error, add updated ssl cert
2022-08-15 13:29:36 -04:00
brentru
f2a63dfb72 fix wfallthrough continue causing memory error, add updated ssl cert, bump fwver 2022-08-15 12:44:08 -04:00
Brent Rubell
a2b63fcca9
Merge pull request #158 from brentru/remove-fingerprint-8266
Remove SSL for ESP8266 Platform
2022-08-10 17:18:26 -04:00
brentru
3aa5e6859d add vers 2022-08-09 13:47:24 -04:00
brentru
6fa5db5774 docu! 2022-08-09 13:46:47 -04:00
brentru
3750ae3c47 use official github for httpclient 2022-08-09 13:46:05 -04:00
brentru
71b59edae8 use our fork? 2022-08-09 13:40:50 -04:00
brentru
20eaa0e49c remove HTTPClient for esp32 2022-08-09 13:16:25 -04:00
brentru
a9bdeb34d5 use proper HTTPClient object for ESP32 2022-08-09 11:28:45 -04:00
brentru
126f8d0a3f use httpclient for esp32? 2022-08-09 11:09:47 -04:00
brentru
d336c04b00 fix gcc esp32 2022-08-09 11:04:40 -04:00
brentru
5ce7d66b89 fix multi-line comment error on esp32 2022-08-09 10:46:40 -04:00
brentru
bf9c3392a3 comments 2022-08-09 10:32:39 -04:00
brentru
46ae1185d9 remove fingerprint check 2022-08-09 10:20:13 -04:00
Brent Rubell
f6d762f01b
Update library.properties
bump version
2021-12-10 14:38:54 -05:00
Brent Rubell
d7f4bd28fb
Merge pull request #155 from darumsdad/master
Support for Arduino WiFi MKR 1010 and Arduino Nano 33 IOT
2021-12-10 14:38:32 -05:00
darumsdad
06474339c9 Update AdafruitIO_Definitions.h
Formatting change
2021-12-10 13:07:56 -05:00
darumsdad
fe6d93d435 formatting changes
formatting changes
2021-12-10 11:21:50 -05:00
darumsdad
3e3f93f530 Changes to support MKR 1010 and Nano 33 IOT
Added include guards
Removed not needed code
2021-12-08 20:35:38 -05:00
darumsdad
007e1357e3 updated examples
updated examples
2021-12-07 18:07:57 -05:00
darumsdad
55efac3adc Changes to support MKR 1010 and Nano 33 IOT
Changes to support MKR 1010 and Nano 33 IOT
2021-12-07 17:58:11 -05:00
Dylan Herrada
28fd173425
Bump to 4.1.1 2021-07-06 13:05:46 -04:00
Brent Rubell
c7d73db162
Merge pull request #153 from brentru/relicense-mit
Relicense Library
2021-06-29 17:09:31 -04:00
brentru
5bca6a5551 bsd->mit 2021-06-29 16:46:47 -04:00
Brent Rubell
57420735ce
Merge pull request #152 from brentru/fix-esp32-cert-issue
Update for ESP32
2021-05-17 09:36:22 -04:00
brentru
dd3b67a7bd clang format 2021-05-12 18:10:31 -04:00
brentru
f36b913698 bump lib 2021-05-12 17:57:00 -04:00
brentru
49e4453a58 ptr 2021-05-12 17:54:15 -04:00
brentru
6fe42e3978 add root CA and setter 2021-05-12 17:52:22 -04:00
Dylan Herrada
3c1ab07109
Bump to 4.0.2 2020-12-11 16:41:41 -05:00
Limor "Ladyada" Fried
59e489411a
Merge pull request #143 from mcauser/patch-1
Fix expired Discord link
2020-12-07 10:13:05 -05:00
Mike Causer
13aef07bbb
Fix expired Discord link 2020-12-08 00:48:50 +11:00
Brent Rubell
15047f09b3
Merge pull request #140 from brentru/pubsub_button_led
New Example - Pub/Sub w/ Button and LED
2020-11-13 12:30:23 -05:00
brentru
abe4320a12 add s2 to readme 2020-11-13 12:16:32 -05:00
brentru
533e82c523 add esp32s2 to lib desc 2020-11-13 12:05:53 -05:00
brentru
605a700f69 add example, bump lib props 2020-11-13 11:57:07 -05:00
Brent Rubell
acbaf4b454
Merge pull request #139 from brentru/add-iot-basics-schedule-trigger
Add IO Basics Example: Scheduled Trigger
2020-10-30 15:43:51 -04:00
brentru
13e24c5ef7 bump lib ver 2020-09-30 12:51:37 -04:00
brentru
4031a80b3e comment out use_airlifts 2020-09-28 14:39:06 -04:00
brentru
feceacd4f6 add example 2020-09-25 12:53:57 -04:00
brentru
1ee8c766da add skel. for example 2020-09-25 11:34:40 -04:00
Brent Rubell
0ef372ce34
Merge pull request #138 from brentru/blaskovicz-patch
Fix Group Feed Name length Limit
2020-09-23 13:49:17 -04:00
brentru
6c1cc5e81d bump version 2020-09-23 13:24:29 -04:00
brentru
c2d12ebf69 modifications per blaskovicz-patch-1 2020-09-23 13:22:57 -04:00
Morgan
e9ac466f97
Update AdafruitIO_WINC1500.h 2020-09-23 11:06:45 +01:00
Morgan
8570f62287
Update AdafruitIO_WiFi.h 2020-09-23 10:40:22 +01:00
Morgan
91224bc95a
Update AdafruitIO_WINC1500.h 2020-09-23 10:40:02 +01:00
Morgan
f7c62e9356
Update AdafruitIO_MKR1010.h 2020-09-23 10:39:37 +01:00
Morgan
1df91354b2
Update AdafruitIO_MKR1010.cpp 2020-09-23 10:38:54 +01:00
Morgan
a862fd9f73
Add support for the MKR1010
Added support for the Arduino MKR1010
2020-09-23 10:04:37 +01:00
Morgan
2fb6f02742
Updated to add support for the MKR1010
Added support for the Arduino MKR1010
2020-09-23 09:49:30 +01:00
Morgan
cf8597c87d
Updated to add support for the MKR1010
Added support for the Arduino MKR1010
2020-09-23 09:46:21 +01:00
Morgan
b3633cf852
Create AdafruitIO_MKR1010.h
This new file is a copy of the original AdafruitIO_MKR1000.h but modified for the Arduino MKR1010
2020-09-23 09:42:48 +01:00
Morgan
2837f73511
Create AdafruitIO_MKR1010.cpp
This new file is a copy of the original AdafruitIO_MKR1000.cpp but modified for the Arduino MKR1010
2020-09-23 09:40:38 +01:00
89 changed files with 1115 additions and 141 deletions

View file

@ -8,16 +8,17 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
arduino-platform: ["esp8266", "esp32", arduino-platform: ["esp8266", "esp32",
"pyportal", "metro_m4_airliftlite"] "pyportal", "metro_m4_airliftlite",
"picow_rp2040_tinyusb"]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-python@v1 - uses: actions/setup-python@v4
with: with:
python-version: '3.x' python-version: '3.x'
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
path: ci path: ci
@ -26,10 +27,12 @@ jobs:
run: bash ci/actions_install.sh run: bash ci/actions_install.sh
# manually install WiFi # manually install WiFi and HTTPClient
- name: extra libraries - name: extra libraries
run: | run: |
git clone --quiet https://github.com/adafruit/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA git clone --quiet https://github.com/adafruit/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA
rm -rf /home/runner/Arduino/libraries/ArduinoHttpClient
git clone --quiet https://github.com/arduino-libraries/ArduinoHttpClient.git /home/runner/Arduino/libraries/ArduinoHttpClient
- name: test platforms - name: test platforms
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }} run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}

View file

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015-2016 Adafruit Industries Copyright (c) 2015-2021 Adafruit Industries
Authors: Tony DiCola, Todd Treece Authors: Tony DiCola, Todd Treece
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View file

@ -2,11 +2,11 @@
[![Build Status](https://github.com/adafruit/Adafruit_IO_Arduino/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_IO_Arduino/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_IO_Arduino/html/index.html) [![Build Status](https://github.com/adafruit/Adafruit_IO_Arduino/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_IO_Arduino/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_IO_Arduino/html/index.html)
[![Discord](https://img.shields.io/discord/327254708534116352.svg)](https://discord.gg/nBQh6qu) [![Discord](https://img.shields.io/discord/327254708534116352.svg)](https://adafru.it/discord)
![AIOArduino](https://cdn-learn.adafruit.com/assets/assets/000/057/496/original/adafruit_io_AIOA.png?1531335660) ![AIOArduino](https://cdn-learn.adafruit.com/assets/assets/000/057/496/original/adafruit_io_AIOA.png?1531335660)
This library provides a simple device independent interface for interacting with [Adafruit IO](https://io.adafruit.com) using Arduino. It allows you to switch between WiFi (ESP8266, ESP32, AirLift, WINC1500, & WICED), Cellular (32u4 FONA), and Ethernet (Ethernet FeatherWing) This library provides a simple device independent interface for interacting with [Adafruit IO](https://io.adafruit.com) using Arduino. It allows you to switch between WiFi (ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, RP2040, Airlift, WINC1500, & WICED), Cellular (32u4 FONA), and Ethernet (Ethernet FeatherWing).
## Documentation ## Documentation
@ -22,4 +22,4 @@ for details).
Adafruit invests time and resources providing this open source code, please Adafruit invests time and resources providing this open source code, please
support Adafruit and open-source hardware by purchasing products from support Adafruit and open-source hardware by purchasing products from
[Adafruit](https://www.adafruit.com)! [Adafruit](https://www.adafruit.com)!

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -27,6 +27,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -30,9 +30,14 @@ void setup() {
// set up led pin as an analog output // set up led pin as an analog output
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
// ESP32 pinMode() #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1)
ledcAttachPin(LED_PIN, 1); // New ESP32 LEDC API
ledcSetup(1, 1200, 8); ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
#else
// Legacy ESP32 LEDC API
ledcAttachPin(LED_PIN, 1);
ledcSetup(1, 1200, 8);
#endif
#else #else
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);
#endif #endif
@ -87,12 +92,6 @@ void handleMessage(AdafruitIO_Data *data) {
Serial.print("received <- "); Serial.print("received <- ");
Serial.println(reading); Serial.println(reading);
// write the current 'reading' to the led // write the current 'reading' to the led
#if defined(ARDUINO_ARCH_ESP32) analogWrite(LED_PIN, reading);
ledcWrite(1, reading); // ESP32 analogWrite()
#else
analogWrite(LED_PIN, reading);
#endif
} }

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -39,14 +39,20 @@ void setup() {
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode #if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
// assign rgb pins to channels #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1)
ledcAttachPin(RED_PIN, 1); // New ESP32 LEDC API
ledcAttachPin(GREEN_PIN, 2); ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
ledcAttachPin(BLUE_PIN, 3); ledcAttach(GREEN_PIN, 12000, 8);
// init. channels ledcAttach(BLUE_PIN, 12000, 8);
ledcSetup(1, 12000, 8); #else
ledcSetup(2, 12000, 8); // Legacy ESP32 LEDC API
ledcSetup(3, 12000, 8); ledcAttachPin(RED_PIN, 1);
ledcAttachPin(GREEN_PIN, 2);
ledcAttachPin(BLUE_PIN, 3);
ledcSetup(1, 12000, 8);
ledcSetup(2, 12000, 8);
ledcSetup(3, 12000, 8);
#endif
#else #else
pinMode(RED_PIN, OUTPUT); pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT);
@ -108,14 +114,7 @@ void handleMessage(AdafruitIO_Data *data) {
Serial.println(data->value()); Serial.println(data->value());
// invert RGB values for common anode LEDs // invert RGB values for common anode LEDs
#if defined(ARDUINO_ARCH_ESP32) // ESP32 analogWrite analogWrite(RED_PIN, 255 - data->toRed());
ledcWrite(1, 255 - data->toRed()); analogWrite(GREEN_PIN, 255 - data->toGreen());
ledcWrite(2, 255 - data->toGreen()); analogWrite(BLUE_PIN, 255 - data->toBlue());
ledcWrite(3, 255 - data->toBlue());
#else
analogWrite(RED_PIN, 255 - data->toRed());
analogWrite(GREEN_PIN, 255 - data->toGreen());
analogWrite(BLUE_PIN, 255 - data->toBlue());
#endif
} }

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -0,0 +1 @@

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -0,0 +1 @@

View file

@ -27,6 +27,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -0,0 +1,95 @@
// Adafruit IO Schedule Trigger Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-scheduled-triggers/
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Brent Rubell for Adafruit Industries
// Copyright (c) 2020 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.
/************************** Configuration ***********************************/
// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"
/************************ Example Starts Here *******************************/
// Relay is connected to PyPortal's D3 connector
#define RELAY_POWER_PIN 3
// Set up the 'relay feed'
AdafruitIO_Feed *relay = io.feed("relay");
void setup() {
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while(! Serial);
Serial.print("Connecting to Adafruit IO");
// connect to io.adafruit.com
io.connect();
// set up a message handler for the 'relay' feed.
// the handleMessage function (defined below)
// will be called whenever a message is
// received from adafruit io
relay->onMessage(handleMessage);
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
// Get the last known value from the feed
relay->get();
}
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();
}
// this function is called whenever an 'relay' feed message
// is received from Adafruit IO. it was attached to
// the 'relay' feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {
Serial.print("feed received new data <- ");
Serial.println(data->toChar());
// Check to see if the morning scheduled trigger has executed
if (strcmp(data->toChar(), "1") == 0) {
Serial.println("Turning lights ON");
digitalWrite(RELAY_POWER_PIN, HIGH);
}
// Check to see if the evening scheduled trigger has executed
else if (strcmp(data->toChar(), "0") == 0) {
Serial.println("Turning lights OFF");
digitalWrite(RELAY_POWER_PIN, LOW);
}
else {
Serial.println("Unexpected data received from Adafruit IO");
}
}

View file

@ -0,0 +1,67 @@
/************************ Adafruit IO Config *******************************/
// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME "your_username"
#define IO_KEY "your_key"
/******************************* WIFI **************************************/
// the AdafruitIO_WiFi client will work with the following boards:
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010
// - Feather WICED -> https://www.adafruit.com/products/3056
// - Adafruit PyPortal -> https://www.adafruit.com/product/4116
// - Adafruit Metro M4 Express AirLift Lite ->
// https://www.adafruit.com/product/4000
// - Adafruit AirLift Breakout -> https://www.adafruit.com/product/4201
#define WIFI_SSID "your_ssid"
#define WIFI_PASS "your_pass"
// uncomment the following line if you are using airlift
// #define USE_AIRLIFT
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"
#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || \
defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
#define ESP32_RESETN 6 // Reset pin
#define ESP32_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
/******************************* FONA **************************************/
// the AdafruitIO_FONA client will work with the following boards:
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027
// uncomment the following two lines for 32u4 FONA,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_FONA.h"
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
/**************************** ETHERNET ************************************/
// the AdafruitIO_Ethernet client will work with the following boards:
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201
// uncomment the following two lines for ethernet,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_Ethernet.h"
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);

View file

@ -0,0 +1,116 @@
// Adafruit IO Publish & Subscribe, Digital Input and Output Example
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Modified by Brent Rubell for Adafruit Industries
// Copyright (c) 2020 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.
/************************** Configuration ***********************************/
// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"
/************************ Example Starts Here *******************************/
// Button Pin
#define BUTTON_PIN 0
// LED Pin
#define LED_PIN LED_BUILTIN
// button state
bool btn_state = false;
bool prv_btn_state = false;
// set up the 'led' feed
AdafruitIO_Feed *led = io.feed("led");
// set up the 'button' feed
AdafruitIO_Feed *button = io.feed("button");
void setup() {
// set button pin as an input
pinMode(BUTTON_PIN, INPUT);
// set LED pin as an output
pinMode(LED_PIN, OUTPUT);
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while(! Serial);
Serial.print("Connecting to Adafruit IO");
// connect to io.adafruit.com
io.connect();
// set up a message handler for the count feed.
// the handleMessage function (defined below)
// will be called whenever a message is
// received from adafruit io.
led->onMessage(handleMessage);
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
led->get();
}
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();
// grab the btn_state state of the button.
if(digitalRead(BUTTON_PIN) == LOW)
btn_state = false;
else
btn_state = true;
// return if the btn state hasn't changed
if(btn_state == prv_btn_state)
return;
// save the btn_state state to the 'button' feed on adafruit io
Serial.print("sending button -> "); Serial.println(btn_state);
button->save(btn_state);
// store last button state
prv_btn_state = btn_state;
}
// this function is called whenever a 'led' message
// is received from Adafruit IO. it was attached to
// the counter feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {
Serial.print("received <- ");
if(data->toPinLevel() == HIGH)
Serial.println("HIGH");
else
Serial.println("LOW");
digitalWrite(LED_PIN, data->toPinLevel());
}

View file

@ -0,0 +1,67 @@
/************************ Adafruit IO Config *******************************/
// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME "your_username"
#define IO_KEY "your_key"
/******************************* WIFI **************************************/
// the AdafruitIO_WiFi client will work with the following boards:
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010
// - Feather WICED -> https://www.adafruit.com/products/3056
// - Adafruit PyPortal -> https://www.adafruit.com/product/4116
// - Adafruit Metro M4 Express AirLift Lite ->
// https://www.adafruit.com/product/4000
// - Adafruit AirLift Breakout -> https://www.adafruit.com/product/4201
#define WIFI_SSID "your_ssid"
#define WIFI_PASS "your_pass"
// uncomment the following line if you are using airlift
// #define USE_AIRLIFT
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"
#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || \
defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
#define ESP32_RESETN 6 // Reset pin
#define ESP32_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
/******************************* FONA **************************************/
// the AdafruitIO_FONA client will work with the following boards:
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027
// uncomment the following two lines for 32u4 FONA,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_FONA.h"
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
/**************************** ETHERNET ************************************/
// the AdafruitIO_Ethernet client will work with the following boards:
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201
// uncomment the following two lines for ethernet,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_Ethernet.h"
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,80 @@
/* Adafruit IO Example Using WiFiManager
*
* This is a simple Adafruit feed subscribe example that uses
* WiFiManager to handle setup of WiFi credentials and connecting
* to the network instead of defining the WiFI SSID and password
* explicitly in the code.
*
* To use this example, add your Adafruit IO Username and Key
* and setup a feed called "myfeed". When you manually add data
* to the feed on io.adafruit.com, you'll see that data written to
* the serial output.
*
* Brad Black - 2022
*
*/
#include <WiFiManager.h>
#include "AdafruitIO_WiFi.h"
char IO_USERNAME[64] = "my username";
char IO_KEY[64] = "my key";
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, "", "");
AdafruitIO_Feed *myfeed = io.feed("myfeed");
WiFiManager wifiManager;
void handleMessage(AdafruitIO_Data *data)
{
Serial.print("received <- ");
Serial.println(data->toString());
} // handleMessage
void setup()
{
Serial.begin(115200); // Initialize serial port for debugging.
delay(500);
// wifiManager.resetSettings(); //uncomment to reset the WiFi settings
wifiManager.setClass("invert"); // enable "dark mode" for the config portal
wifiManager.setConfigPortalTimeout(120); // auto close configportal after n seconds
wifiManager.setAPClientCheck(true); // avoid timeout if client connected to softap
if (!wifiManager.autoConnect("WiFi Setup")) // connect to wifi with existing setting or start config
{
Serial.println("failed to connect and hit timeout");
}
else
{
// if you get here you have connected to the WiFi
Serial.println("Connected to WiFi.");
Serial.printf("Connecting to Adafruit IO with User: %s Key: %s.\n", IO_USERNAME, IO_KEY);
io.connect();
myfeed->onMessage(handleMessage);
myfeed->get();
// wait for a connection
while ((io.status() < AIO_CONNECTED))
{
Serial.print(".");
delay(500);
}
Serial.println("Connected to Adafruit IO.");
}
} // setup()
void loop()
{
io.run();
} // loop()

View file

@ -0,0 +1,192 @@
/* Adafruit IO Example Using WiFiManager with Custom Adafruit IO parameters
*
* This is a simple Adafruit feed subscribe example that uses
* WiFiManager to handle setup of WiFi credentials and connecting
* to the network instead of defining the WiFI SSID and password
* explicitly in the code.
*
* In addition, this example allows you to enter your Adafruit IO username and key
* as customer parameters in WiFiManager so that they do not need to be coded into
* the sketch.
*
* This is useful if you want to create projects and share them with others that
* may use them on a different WiFi network and use a different Adafruit IO account
* for IOT integrations such as collecting sensor data or voice command integration via
* IFFT.
*
* To use this example, setup a feed called "myfeed". When the ESP8266 or ESP32
* microcontroller starts, join the "WiFi Setup" SSID and you should be presented
* with the config portal. If the config portal does not automatically start you
* can browse to http://192.168.4.1 to access it
*
* Select the SSID and enter the password for WiFi Access in the config portal.
* Enter your Adafruit IO username and key in the config portal and select "Save".
*
* When you manually add data to the feed on io.adafruit.com, you'll see
* that data written to the serial output.
*
* Brad Black - 2022
*
*/
#include <WiFiManager.h>
#include "AdafruitIO_WiFi.h"
#include <ArduinoJson.h>
#include <LittleFS.h>
char IO_USERNAME[64] = "";
char IO_KEY[64] = "";
static uint8_t objStorage[sizeof(AdafruitIO_WiFi)]; // RAM for the object
AdafruitIO_WiFi *io; // a pointer to the object, once it's constructed
// create WiFiManager object and define our custom parameters
WiFiManager wifiManager;
WiFiManagerParameter custom_IO_USERNAME("iouser", "Adafruit IO Username", IO_USERNAME, 60);
WiFiManagerParameter custom_IO_KEY("iokey", "Adafruit IO Key", IO_KEY, 60);
void handleMessage(AdafruitIO_Data *data)
{
Serial.print("received <- ");
Serial.println(data->toString());
} // handleMessage
// callback notifying us of the need to save config
void saveConfigCallback()
{
Serial.println("Saving new config");
strcpy(IO_USERNAME, custom_IO_USERNAME.getValue());
strcpy(IO_KEY, custom_IO_KEY.getValue());
DynamicJsonDocument json(256);
json["IO_KEY"] = IO_KEY;
json["IO_USERNAME"] = IO_USERNAME;
File configFile = LittleFS.open("/config.json", "w");
if (!configFile)
{
Serial.println("Failed to open config file for writing");
}
serializeJson(json, Serial);
serializeJson(json, configFile);
configFile.close();
} // end save
void readParamsFromFS()
{
if (LittleFS.begin())
{
if (LittleFS.exists("/config.json"))
{
// file exists, reading and loading
Serial.println("Reading config file");
File configFile = LittleFS.open("/config.json", "r");
if (configFile)
{
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonDocument json(256);
auto deserializeError = deserializeJson(json, buf.get());
serializeJson(json, Serial);
Serial.println();
if (!deserializeError)
{
if (json.containsKey("IO_USERNAME"))
strcpy(IO_USERNAME, json["IO_USERNAME"]);
if (json.containsKey("IO_KEY"))
strcpy(IO_KEY, json["IO_KEY"]);
}
else
{
Serial.println("Failed to load json config");
}
configFile.close();
}
}
else
{
Serial.println("Failed to mount FS");
}
}
}
void setup()
{
Serial.begin(115200); // Initialize serial port for debugging.
delay(500);
WiFi.begin();
readParamsFromFS(); // get parameters from file system
//wifiManager.resetSettings(); //uncomment to reset the WiFi settings
wifiManager.setClass("invert"); // enable "dark mode" for the config portal
wifiManager.setConfigPortalTimeout(120); // auto close configportal after n seconds
wifiManager.setAPClientCheck(true); // avoid timeout if client connected to softap
wifiManager.addParameter(&custom_IO_USERNAME); // set custom paraeter for IO username
wifiManager.addParameter(&custom_IO_KEY); // set custom parameter for IO key
custom_IO_KEY.setValue(IO_KEY, 64); // set custom parameter value
custom_IO_USERNAME.setValue(IO_USERNAME, 64); // set custom parameter value
wifiManager.setSaveConfigCallback(saveConfigCallback); // set config save notify callback
if (!wifiManager.autoConnect("WiFi Setup")) // connect to wifi with existing setting or start config
{
Serial.println("Failed to connect and hit timeout");
}
else
{
// if you get here you have connected to the WiFi
Serial.println("Connected to WiFi.");
// connect to Adafruit IO
io = new (objStorage) AdafruitIO_WiFi(IO_USERNAME, IO_KEY, "", "");
Serial.printf("Connecting to Adafruit IO with User: %s Key: %s.\n", IO_USERNAME, IO_KEY);
io->connect();
AdafruitIO_Feed *myfeed = io->feed("myfeed");
myfeed->onMessage(handleMessage);
myfeed->get();
// wait for a connection
while ((io->status() < AIO_CONNECTED))
{
Serial.print(".");
delay(500);
}
Serial.println("Connected to Adafruit IO.");
}
} // setup()
void loop()
{
io->run();
} // loop()

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,6 +29,9 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -1,10 +1,10 @@
name=Adafruit IO Arduino name=Adafruit IO Arduino
version=3.8.0 version=4.3.2
author=Adafruit author=Adafruit
maintainer=Adafruit <adafruitio@adafruit.com> maintainer=Adafruit <adafruitio@adafruit.com>
sentence=Arduino library to access Adafruit IO. sentence=Arduino library to access Adafruit IO.
paragraph=Arduino library to access Adafruit IO using the Adafruit AirLift, ESP8266, ESP32, M0 WINC1500, WICED, MKR1000, Ethernet, or FONA hardware. paragraph=Arduino library to access Adafruit IO using WiFi, ethernet, or cellular.
category=Communication category=Communication
url=https://github.com/adafruit/Adafruit_IO_Arduino url=https://github.com/adafruit/Adafruit_IO_Arduino
architectures=* architectures=*
depends=Adafruit MQTT Library, ArduinoHttpClient, Adafruit Unified Sensor, Adafruit NeoPixel, DHT sensor library, Ethernet, Adafruit Si7021 Library, Adafruit SGP30 Sensor, Adafruit BME280 Library, Adafruit LIS3DH, Adafruit VEML6070 Library, ESP32Servo depends=Adafruit MQTT Library, ArduinoHttpClient, Adafruit Unified Sensor, Adafruit NeoPixel, DHT sensor library, Ethernet, Adafruit Si7021 Library, Adafruit SGP30 Sensor, Adafruit BME280 Library, Adafruit LIS3DH, Adafruit VEML6070 Library, ESP32Servo, WiFiManager, ArduinoJson

View file

@ -30,7 +30,7 @@
* *
* @section license License * @section license License
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "AdafruitIO.h" #include "AdafruitIO.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_DASHBOARD_H #ifndef ADAFRUITIO_DASHBOARD_H

View file

@ -419,12 +419,7 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele,
@return Feed's name if feed exists. @return Feed's name if feed exists.
*/ */
/**************************************************************************/ /**************************************************************************/
char *AdafruitIO_Data::feedName() { char *AdafruitIO_Data::feedName() { return _feed; }
if (!_feed)
return (char *)"";
return _feed;
}
/**************************************************************************/ /**************************************************************************/
/*! /*!
@ -448,12 +443,7 @@ char *AdafruitIO_Data::toChar() { return _value; }
@return String of value. @return String of value.
*/ */
/**************************************************************************/ /**************************************************************************/
String AdafruitIO_Data::toString() { String AdafruitIO_Data::toString() { return String(_value); }
if (!_value)
return String();
return String(_value);
}
/**************************************************************************/ /**************************************************************************/
/*! /*!
@ -462,13 +452,9 @@ String AdafruitIO_Data::toString() {
*/ */
/**************************************************************************/ /**************************************************************************/
bool AdafruitIO_Data::toBool() { bool AdafruitIO_Data::toBool() {
if (!_value)
return false;
if (strcmp(_value, "1") == 0 || _value[0] == 't' || _value[0] == 'T') if (strcmp(_value, "1") == 0 || _value[0] == 't' || _value[0] == 'T')
return true; return true;
else return false;
return false;
} }
/**************************************************************************/ /**************************************************************************/
@ -494,9 +480,6 @@ bool AdafruitIO_Data::isFalse() { return !toBool(); }
*/ */
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toInt() { int AdafruitIO_Data::toInt() {
if (!_value)
return 0;
char *endptr; char *endptr;
return (int)strtol(_value, &endptr, 10); return (int)strtol(_value, &endptr, 10);
} }
@ -522,9 +505,6 @@ int AdafruitIO_Data::toPinLevel() {
*/ */
/**************************************************************************/ /**************************************************************************/
unsigned int AdafruitIO_Data::toUnsignedInt() { unsigned int AdafruitIO_Data::toUnsignedInt() {
if (!_value)
return 0;
char *endptr; char *endptr;
#ifdef ESP8266 #ifdef ESP8266
// For some reason strtoul is not defined on the ESP8266 platform right now. // For some reason strtoul is not defined on the ESP8266 platform right now.
@ -542,9 +522,6 @@ unsigned int AdafruitIO_Data::toUnsignedInt() {
*/ */
/**************************************************************************/ /**************************************************************************/
float AdafruitIO_Data::toFloat() { float AdafruitIO_Data::toFloat() {
if (!_value)
return 0;
char *endptr; char *endptr;
return (float)strtod(_value, &endptr); return (float)strtod(_value, &endptr);
} }
@ -556,9 +533,6 @@ float AdafruitIO_Data::toFloat() {
*/ */
/**************************************************************************/ /**************************************************************************/
double AdafruitIO_Data::toDouble() { double AdafruitIO_Data::toDouble() {
if (!_value)
return 0;
char *endptr; char *endptr;
return strtod(_value, &endptr); return strtod(_value, &endptr);
} }
@ -570,9 +544,6 @@ double AdafruitIO_Data::toDouble() {
*/ */
/**************************************************************************/ /**************************************************************************/
long AdafruitIO_Data::toLong() { long AdafruitIO_Data::toLong() {
if (!_value)
return 0;
char *endptr; char *endptr;
return strtol(_value, &endptr, 10); return strtol(_value, &endptr, 10);
} }
@ -584,9 +555,6 @@ long AdafruitIO_Data::toLong() {
*/ */
/**************************************************************************/ /**************************************************************************/
unsigned long AdafruitIO_Data::toUnsignedLong() { unsigned long AdafruitIO_Data::toUnsignedLong() {
if (!_value)
return 0;
char *endptr; char *endptr;
#ifdef ESP8266 #ifdef ESP8266
// For some reason strtoul is not defined on the ESP8266 platform right now. // For some reason strtoul is not defined on the ESP8266 platform right now.
@ -605,9 +573,6 @@ unsigned long AdafruitIO_Data::toUnsignedLong() {
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toRed() { int AdafruitIO_Data::toRed() {
// Convert 0xRRGGBB to red. // Convert 0xRRGGBB to red.
if (!_value) {
return 0;
}
char r[5]; char r[5];
strcpy(r, "0x"); strcpy(r, "0x");
strncpy(&r[2], toChar() + 1, 2); strncpy(&r[2], toChar() + 1, 2);
@ -623,9 +588,6 @@ int AdafruitIO_Data::toRed() {
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toGreen() { int AdafruitIO_Data::toGreen() {
// Convert 0xRRGGBB to green. // Convert 0xRRGGBB to green.
if (!_value) {
return 0;
}
char g[5]; char g[5];
strcpy(g, "0x"); strcpy(g, "0x");
strncpy(&g[2], toChar() + 3, 2); strncpy(&g[2], toChar() + 3, 2);
@ -641,9 +603,6 @@ int AdafruitIO_Data::toGreen() {
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toBlue() { int AdafruitIO_Data::toBlue() {
// Convert 0xRRGGBB to blue. // Convert 0xRRGGBB to blue.
if (!_value) {
return 0;
}
char b[5]; char b[5];
strcpy(b, "0x"); strcpy(b, "0x");
strncpy(&b[2], toChar() + 5, 2); strncpy(&b[2], toChar() + 5, 2);
@ -659,9 +618,6 @@ int AdafruitIO_Data::toBlue() {
*/ */
/**************************************************************************/ /**************************************************************************/
long AdafruitIO_Data::toNeoPixel() { long AdafruitIO_Data::toNeoPixel() {
if (!_value) {
return 0;
}
char rgb[9]; char rgb[9];
strcpy(rgb, "0x"); strcpy(rgb, "0x");
strncpy(&rgb[2], toChar() + 1, 6); strncpy(&rgb[2], toChar() + 1, 6);
@ -676,11 +632,7 @@ long AdafruitIO_Data::toNeoPixel() {
*/ */
/**************************************************************************/ /**************************************************************************/
char *AdafruitIO_Data::toCSV() { char *AdafruitIO_Data::toCSV() {
if (!_value)
return _csv;
memset(_csv, 0, AIO_CSV_LENGTH); memset(_csv, 0, AIO_CSV_LENGTH);
strcpy(_csv, "\""); strcpy(_csv, "\"");
strcat(_csv, _value); strcat(_csv, _value);
strcat(_csv, "\","); strcat(_csv, "\",");
@ -689,7 +641,6 @@ char *AdafruitIO_Data::toCSV() {
strcat(_csv, charFromDouble(_lon)); strcat(_csv, charFromDouble(_lon));
strcat(_csv, ","); strcat(_csv, ",");
strcat(_csv, charFromDouble(_ele, 2)); strcat(_csv, charFromDouble(_ele, 2));
return _csv; return _csv;
} }
@ -873,6 +824,7 @@ char **parse_csv(const char *line) {
continue; continue;
case '\0': case '\0':
fEnd = 1; fEnd = 1;
break;
case ',': case ',':
*tptr = '\0'; *tptr = '\0';
*bptr = strdup(tmp); *bptr = strdup(tmp);

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_DATA_H #ifndef ADAFRUITIO_DATA_H

View file

@ -9,16 +9,16 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_DEFINITIONS_H_ #ifndef ADAFRUITIO_DEFINITIONS_H_
#define ADAFRUITIO_DEFINITIONS_H_ #define ADAFRUITIO_DEFINITIONS_H_
#define ADAFRUITIO_VERSION_MAJOR 3 ///< Adafruit IO Arduino Major Semvar #define ADAFRUITIO_VERSION_MAJOR 4 ///< Adafruit IO Arduino Major Semvar
#define ADAFRUITIO_VERSION_MINOR 5 ///< Adafruit IO Arduino Minor Semvar #define ADAFRUITIO_VERSION_MINOR 2 ///< Adafruit IO Arduino Minor Semvar
#define ADAFRUITIO_VERSION_PATCH 0 ///< Adafruit IO Arduino Patch Semvar #define ADAFRUITIO_VERSION_PATCH 1 ///< Adafruit IO Arduino Patch Semvar
// forward declaration // forward declaration
class AdafruitIO_Data; class AdafruitIO_Data;
@ -119,16 +119,20 @@ public:
// echo | openssl s_client -connect io.adafruit.com:443 | openssl x509 // echo | openssl s_client -connect io.adafruit.com:443 | openssl x509
// -fingerprint -noout // -fingerprint -noout
#define AIO_SSL_FINGERPRINT \ #define AIO_SSL_FINGERPRINT \
"59 3C 48 0A B1 8B 39 4E 0D 58 50 47 9A 13 55 60 CC A0 1D AF" ///< Latest "47 D2 CB 14 DF 38 97 59 C6 65 1A 1F 3E 00 1E 53 CC A5 17 E0" ///< Latest
///< Adafruit IO ///< Adafruit IO
///< SSL ///< SSL
///< Fingerprint ///< Fingerprint
#define AIO_FEED_NAME_LENGTH 20 ///< Maximum length of an Adafruit IO Feed name #define AIO_FEED_NAME_LENGTH \
258 ///< Maximum length of an Adafruit IO Feed: Name; 128 + 1 + 128 for the
///< group, a dot, and actual feed name.
#define AIO_DATA_LENGTH \ #define AIO_DATA_LENGTH \
45 ///< Maximum length of data sent/recieved from Adafruit IO 45 ///< Maximum length of data sent/recieved from Adafruit IO
#define AIO_CSV_LENGTH \ #define AIO_CSV_LENGTH \
150 ///< Maximum comma-separated-value length from Adafruit IO AIO_FEED_NAME_LENGTH + \
4 ///< Maximum comma-separated-value length from Adafruit IO
/** aio_status_t offers 13 status states */ /** aio_status_t offers 13 status states */
typedef enum { typedef enum {

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_ETHERNET_H #ifndef ADAFRUITIO_ETHERNET_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_FEED_H #ifndef ADAFRUITIO_FEED_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_MQTT_H #ifndef ADAFRUITIO_MQTT_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_TIME_H #ifndef ADAFRUITIO_TIME_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_WIFI_H #ifndef ADAFRUITIO_WIFI_H
@ -20,6 +20,11 @@
#include "wifi/AdafruitIO_MKR1000.h" #include "wifi/AdafruitIO_MKR1000.h"
typedef AdafruitIO_MKR1000 AdafruitIO_WiFi; typedef AdafruitIO_MKR1000 AdafruitIO_WiFi;
#elif defined(ARDUINO_SAMD_MKR1010)
#include "wifi/AdafruitIO_MKR1010.h"
typedef AdafruitIO_MKR1010 AdafruitIO_WiFi;
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \ #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
defined(USE_AIRLIFT) defined(USE_AIRLIFT)
@ -46,6 +51,11 @@ typedef AdafruitIO_ESP8266 AdafruitIO_WiFi;
#include "wifi/AdafruitIO_WICED.h" #include "wifi/AdafruitIO_WICED.h"
typedef AdafruitIO_WICED AdafruitIO_WiFi; typedef AdafruitIO_WICED AdafruitIO_WiFi;
#elif defined(ARDUINO_ARCH_RP2040)
#include "wifi/AdafruitIO_RP2040.h"
typedef AdafruitIO_RP2040 AdafruitIO_WiFi;
#else #else
#warning "Must define USE_AIRLIFT or USE_WINC1500 before including this file." #warning "Must define USE_AIRLIFT or USE_WINC1500 before including this file."

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "AdafruitIO_Block.h" #include "AdafruitIO_Block.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_BLOCK_H #ifndef ADAFRUITIO_BLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "ChartBlock.h" #include "ChartBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_CHARTBLOCK_H #ifndef ADAFRUITIO_CHARTBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_COLORBLOCK_H #ifndef ADAFRUITIO_COLORBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "GaugeBlock.h" #include "GaugeBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_GAUGEBLOCK_H #ifndef ADAFRUITIO_GAUGEBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_IMAGEBLOCK_H #ifndef ADAFRUITIO_IMAGEBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "MapBlock.h" #include "MapBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_MAPBLOCK_H #ifndef ADAFRUITIO_MAPBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "MomentaryBlock.h" #include "MomentaryBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_MOMENTARYBLOCK_H #ifndef ADAFRUITIO_MOMENTARYBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "SliderBlock.h" #include "SliderBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_SLIDERBLOCK_H #ifndef ADAFRUITIO_SLIDERBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "StreamBlock.h" #include "StreamBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_STREAMBLOCK_H #ifndef ADAFRUITIO_STREAMBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "TextBlock.h" #include "TextBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_TEXTBLOCK_H #ifndef ADAFRUITIO_TEXTBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "ToggleBlock.h" #include "ToggleBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_TOGGLEBLOCK_H #ifndef ADAFRUITIO_TOGGLEBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#include "AdafruitIO_Board.h" #include "AdafruitIO_Board.h"
@ -29,6 +29,8 @@ const char AdafruitIO_Board::_type[] = "feather_wiced";
const char AdafruitIO_Board::_type[] = "esp32"; const char AdafruitIO_Board::_type[] = "esp32";
#elif defined(ESP8266) #elif defined(ESP8266)
const char AdafruitIO_Board::_type[] = "esp8266"; const char AdafruitIO_Board::_type[] = "esp8266";
#elif defined(ARDUINO_ARCH_RP2040)
const char AdafruitIO_Board::_type[] = "rp2040";
#else #else
const char AdafruitIO_Board::_type[] = "unknown"; const char AdafruitIO_Board::_type[] = "unknown";
#endif #endif

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* BSD license, all text here must be included in any redistribution. * MIT license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_BOARD_H #ifndef ADAFRUITIO_BOARD_H

View file

@ -5,8 +5,8 @@
* Please support Adafruit and open source hardware by purchasing * Please support Adafruit and open source hardware by purchasing
* products from Adafruit! * products from Adafruit!
* *
* Copyright (c) 2015-2016 Adafruit Industries * Copyright (c) 2015-2021 Adafruit Industries
* Authors: Tony DiCola, Todd Treece * Authors: Tony DiCola, Todd Treece, Brent Rubell
* Licensed under the MIT license. * Licensed under the MIT license.
* *
* All text above must be included in any redistribution. * All text above must be included in any redistribution.
@ -42,6 +42,7 @@ void AdafruitIO_ESP32::_connect() {
delay(100); delay(100);
_status = AIO_NET_DISCONNECTED; _status = AIO_NET_DISCONNECTED;
} }
_client->setCACert(_aio_root_ca);
} }
/**************************************************************************/ /**************************************************************************/
@ -55,7 +56,6 @@ void AdafruitIO_ESP32::_disconnect() {
} }
aio_status_t AdafruitIO_ESP32::networkStatus() { aio_status_t AdafruitIO_ESP32::networkStatus() {
switch (WiFi.status()) { switch (WiFi.status()) {
case WL_CONNECTED: case WL_CONNECTED:
return AIO_NET_CONNECTED; return AIO_NET_CONNECTED;

View file

@ -5,8 +5,8 @@
* Please support Adafruit and open source hardware by purchasing * Please support Adafruit and open source hardware by purchasing
* products from Adafruit! * products from Adafruit!
* *
* Copyright (c) 2015-2016 Adafruit Industries * Copyright (c) 2015-2021 Adafruit Industries
* Authors: Tony DiCola, Todd Treece * Authors: Tony DiCola, Todd Treece, Brent Rubell
* Licensed under the MIT license. * Licensed under the MIT license.
* *
* All text above must be included in any redistribution. * All text above must be included in any redistribution.
@ -42,6 +42,36 @@ protected:
const char *_pass; const char *_pass;
WiFiClientSecure *_client; WiFiClientSecure *_client;
// io.adafruit.com root CA
const char *_aio_root_ca =
"-----BEGIN CERTIFICATE-----\n"
"MIIEjTCCA3WgAwIBAgIQDQd4KhM/xvmlcpbhMf/ReTANBgkqhkiG9w0BAQsFADBh\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n"
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n"
"MjAeFw0xNzExMDIxMjIzMzdaFw0yNzExMDIxMjIzMzdaMGAxCzAJBgNVBAYTAlVT\n"
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n"
"b20xHzAdBgNVBAMTFkdlb1RydXN0IFRMUyBSU0EgQ0EgRzEwggEiMA0GCSqGSIb3\n"
"DQEBAQUAA4IBDwAwggEKAoIBAQC+F+jsvikKy/65LWEx/TMkCDIuWegh1Ngwvm4Q\n"
"yISgP7oU5d79eoySG3vOhC3w/3jEMuipoH1fBtp7m0tTpsYbAhch4XA7rfuD6whU\n"
"gajeErLVxoiWMPkC/DnUvbgi74BJmdBiuGHQSd7LwsuXpTEGG9fYXcbTVN5SATYq\n"
"DfbexbYxTMwVJWoVb6lrBEgM3gBBqiiAiy800xu1Nq07JdCIQkBsNpFtZbIZhsDS\n"
"fzlGWP4wEmBQ3O67c+ZXkFr2DcrXBEtHam80Gp2SNhou2U5U7UesDL/xgLK6/0d7\n"
"6TnEVMSUVJkZ8VeZr+IUIlvoLrtjLbqugb0T3OYXW+CQU0kBAgMBAAGjggFAMIIB\n"
"PDAdBgNVHQ4EFgQUlE/UXYvkpOKmgP792PkA76O+AlcwHwYDVR0jBBgwFoAUTiJU\n"
"IBiV5uNu5g/6+rkS7QYXjzkwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsG\n"
"AQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMDQGCCsGAQUFBwEB\n"
"BCgwJjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMEIGA1Ud\n"
"HwQ7MDkwN6A1oDOGMWh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEds\n"
"b2JhbFJvb3RHMi5jcmwwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEW\n"
"HGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwDQYJKoZIhvcNAQELBQADggEB\n"
"AIIcBDqC6cWpyGUSXAjjAcYwsK4iiGF7KweG97i1RJz1kwZhRoo6orU1JtBYnjzB\n"
"c4+/sXmnHJk3mlPyL1xuIAt9sMeC7+vreRIF5wFBC0MCN5sbHwhNN1JzKbifNeP5\n"
"ozpZdQFmkCo+neBiKR6HqIA+LMTMCMMuv2khGGuPHmtDze4GmEGZtYLyF8EQpa5Y\n"
"jPuV6k2Cr/N3XxFpT3hRpt/3usU/Zb9wfKPtWpoznZ4/44c1p9rzFcZYrWkj3A+7\n"
"TNBJE0GmP2fhXhP1D/XVfIW/h0yCJGEiV9Glm/uGOa3DXHlmbAcxSyCRraG+ZBkA\n"
"7h4SeM6Y8l/7MBRpPCz6l8Y=\n"
"-----END CERTIFICATE-----\n";
}; };
#endif // ESP32 #endif // ESP32

View file

@ -21,9 +21,13 @@ AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char *user, const char *key,
: AdafruitIO(user, key) { : AdafruitIO(user, key) {
_ssid = ssid; _ssid = ssid;
_pass = pass; _pass = pass;
_client = new WiFiClientSecure; // Uncomment the following lines and remove the existing WiFiClient and MQTT
_client->setFingerprint(AIO_SSL_FINGERPRINT); // client constructors to use Secure MQTT with ESP8266.
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port); // _client = new WiFiClientSecure;
// _client->setFingerprint(AIO_SSL_FINGERPRINT);
// _mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
_client = new WiFiClient;
_mqtt = new Adafruit_MQTT_Client(_client, _host, 1883);
_http = new HttpClient(*_client, _host, _http_port); _http = new HttpClient(*_client, _host, _http_port);
} }

View file

@ -22,7 +22,17 @@
#include "Adafruit_MQTT_Client.h" #include "Adafruit_MQTT_Client.h"
#include "Arduino.h" #include "Arduino.h"
#include "ESP8266WiFi.h" #include "ESP8266WiFi.h"
#include "WiFiClientSecure.h" /* NOTE - Projects that require "Secure MQTT" (TLS/SSL) also require a new
* SSL certificate every year. If adding Secure MQTT to your ESP8266 project is
* important - please switch to using the modern ESP32 (and related models)
* instead of the ESP8266 to avoid updating the SSL fingerprint every year.
*
* If you've read through this and still want to use "Secure MQTT" with your
* ESP8266 project, we've left the "WiFiClientSecure" lines commented out. To
* use them, uncomment the commented out lines within `AdafruitIO_ESP8266.h` and
* `AdafruitIO_ESP8266.cpp` and recompile the library.
*/
// #include "WiFiClientSecure.h"
class AdafruitIO_ESP8266 : public AdafruitIO { class AdafruitIO_ESP8266 : public AdafruitIO {
@ -40,7 +50,10 @@ protected:
const char *_ssid; const char *_ssid;
const char *_pass; const char *_pass;
WiFiClientSecure *_client; WiFiClient *_client;
// Uncomment the following line, and remove the line above, to use
// secure MQTT with ESP8266.
// WiFiClientSecure *_client;
}; };
#endif // ESP8266 #endif // ESP8266

View file

@ -0,0 +1,83 @@
/*!
* @file AdafruitIO_MKR1010.h
*
* Adafruit invests time and resources providing this open source code.
* Please support Adafruit and open source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) 2015-2016 Adafruit Industries
* Authors: David Goldstein, Morgan Winters
* Licensed under the MIT license.
*
* All text above must be included in any redistribution.
*/
#ifndef ADAFRUITIO_MKR1010_H
#define ADAFRUITIO_MKR1010_H
#include "AdafruitIO.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Arduino.h"
#include "SPI.h"
#include "WiFiNINA.h"
#include "WiFiSSLClient.h"
class AdafruitIO_MKR1010 : public AdafruitIO {
public:
AdafruitIO_MKR1010(const char *user, const char *key, const char *ssid,
const char *pass)
: AdafruitIO(user, key) {
_ssid = ssid;
_pass = pass;
_client = new WiFiSSLClient;
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
_http = new HttpClient(*_client, _host, _http_port);
}
~AdafruitIO_MKR1010() {
if (_client)
delete _client;
if (_mqtt)
delete _mqtt;
}
aio_status_t networkStatus() {
switch (WiFi.status()) {
case WL_CONNECTED:
return AIO_NET_CONNECTED;
case WL_CONNECT_FAILED:
return AIO_NET_CONNECT_FAILED;
case WL_IDLE_STATUS:
return AIO_IDLE;
default:
return AIO_NET_DISCONNECTED;
}
}
const char *connectionType() { return "wifi"; }
protected:
void _connect() {
if (strlen(_ssid) == 0) {
_status = AIO_SSID_INVALID;
} else {
_disconnect();
WiFi.begin(_ssid, _pass);
_status = networkStatus();
}
}
void _disconnect() {
WiFi.disconnect();
delay(AIO_NET_DISCONNECT_WAIT);
}
const char *_ssid;
const char *_pass;
WiFiSSLClient *_client;
};
#endif ADAFRUITIO_MKR1010_H

View file

@ -0,0 +1,167 @@
/*!
* @file AdafruitIO_RP2040.h
*
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright 2024 Brent Rubell for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef ADAFRUITIO_RP2040_H
#define ADAFRUITIO_RP2040_H
#ifdef ARDUINO_ARCH_RP2040
#include "AdafruitIO.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Arduino.h"
#include <WiFiClientSecure.h>
/****************************************************************************/
/*!
@brief Class that stores functions for interacting with the RP2040
WiFi Client
*/
/****************************************************************************/
class AdafruitIO_RP2040 : public AdafruitIO {
public:
/**************************************************************************/
/*!
@brief Initializes the Adafruit IO class for RP2040 boards.
@param user
A reference to the Adafruit IO user, shared by AdafruitIO.
@param key
A reference to the Adafruit IO Key, shared by AdafruitIO.
@param ssid
A reference to the WiFi network SSID.
@param pass
A reference to the WiFi network password.
*/
/**************************************************************************/
AdafruitIO_RP2040(const char *user, const char *key, const char *ssid,
const char *pass)
: AdafruitIO(user, key) {
_ssid = ssid;
_pass = pass;
_mqtt_client = new WiFiClientSecure;
_mqtt = new Adafruit_MQTT_Client(_mqtt_client, _host, _mqtt_port);
_http_client = new WiFiClientSecure;
_http = new HttpClient(*_http_client, _host, _http_port);
}
/*******************************/
/*!
@brief Class dtor
*/
/*******************************/
~AdafruitIO_RP2040() {
if (_mqtt_client)
delete _http_client;
if (_http_client)
delete _mqtt_client;
}
/********************************************************/
/*!
@brief Returns the network status of the RP2040.
@return aio_status_t
*/
/********************************************************/
aio_status_t networkStatus() {
switch (WiFi.status()) {
case WL_CONNECTED:
return AIO_NET_CONNECTED;
case WL_CONNECT_FAILED:
return AIO_NET_CONNECT_FAILED;
case WL_IDLE_STATUS:
return AIO_IDLE;
default:
return AIO_NET_DISCONNECTED;
}
}
/******************************************************************/
/*!
@brief Returns the type of network connection used by AdafruitIO.
@return RP2040
*/
/******************************************************************/
const char *connectionType() { return "RP2040"; }
protected:
const char *_ssid; ///< WiFi network SSID
const char *_pass; ///< WiFi network password
WiFiClientSecure *_http_client; ///< HTTP client
WiFiClientSecure *_mqtt_client; ///< MQTT client
const char *_aio_root_ca_prod =
"-----BEGIN CERTIFICATE-----\n"
"MIIEjTCCA3WgAwIBAgIQDQd4KhM/xvmlcpbhMf/ReTANBgkqhkiG9w0BAQsFADBh\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n"
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n"
"MjAeFw0xNzExMDIxMjIzMzdaFw0yNzExMDIxMjIzMzdaMGAxCzAJBgNVBAYTAlVT\n"
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n"
"b20xHzAdBgNVBAMTFkdlb1RydXN0IFRMUyBSU0EgQ0EgRzEwggEiMA0GCSqGSIb3\n"
"DQEBAQUAA4IBDwAwggEKAoIBAQC+F+jsvikKy/65LWEx/TMkCDIuWegh1Ngwvm4Q\n"
"yISgP7oU5d79eoySG3vOhC3w/3jEMuipoH1fBtp7m0tTpsYbAhch4XA7rfuD6whU\n"
"gajeErLVxoiWMPkC/DnUvbgi74BJmdBiuGHQSd7LwsuXpTEGG9fYXcbTVN5SATYq\n"
"DfbexbYxTMwVJWoVb6lrBEgM3gBBqiiAiy800xu1Nq07JdCIQkBsNpFtZbIZhsDS\n"
"fzlGWP4wEmBQ3O67c+ZXkFr2DcrXBEtHam80Gp2SNhou2U5U7UesDL/xgLK6/0d7\n"
"6TnEVMSUVJkZ8VeZr+IUIlvoLrtjLbqugb0T3OYXW+CQU0kBAgMBAAGjggFAMIIB\n"
"PDAdBgNVHQ4EFgQUlE/UXYvkpOKmgP792PkA76O+AlcwHwYDVR0jBBgwFoAUTiJU\n"
"IBiV5uNu5g/6+rkS7QYXjzkwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsG\n"
"AQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMDQGCCsGAQUFBwEB\n"
"BCgwJjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMEIGA1Ud\n"
"HwQ7MDkwN6A1oDOGMWh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEds\n"
"b2JhbFJvb3RHMi5jcmwwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEW\n"
"HGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwDQYJKoZIhvcNAQELBQADggEB\n"
"AIIcBDqC6cWpyGUSXAjjAcYwsK4iiGF7KweG97i1RJz1kwZhRoo6orU1JtBYnjzB\n"
"c4+/sXmnHJk3mlPyL1xuIAt9sMeC7+vreRIF5wFBC0MCN5sbHwhNN1JzKbifNeP5\n"
"ozpZdQFmkCo+neBiKR6HqIA+LMTMCMMuv2khGGuPHmtDze4GmEGZtYLyF8EQpa5Y\n"
"jPuV6k2Cr/N3XxFpT3hRpt/3usU/Zb9wfKPtWpoznZ4/44c1p9rzFcZYrWkj3A+7\n"
"TNBJE0GmP2fhXhP1D/XVfIW/h0yCJGEiV9Glm/uGOa3DXHlmbAcxSyCRraG+ZBkA\n"
"7h4SeM6Y8l/7MBRpPCz6l8Y=\n"
"-----END CERTIFICATE-----\n"; ///< Root certificate for io.adafruit.com
/**************************************************************************/
/*!
@brief Attempts to establish a WiFi connection with the wireless network,
given _ssid and _pass from the AdafruitIO_RP2040 constructor.
*/
/**************************************************************************/
void _connect() {
if (strlen(_ssid) == 0) {
Serial.println("Invalid SSID!");
_status = AIO_SSID_INVALID;
} else {
_disconnect();
delay(10000);
WiFi.mode(WIFI_STA);
WiFi.setTimeout(20000);
WiFi.begin(_ssid, _pass);
Serial.println("\nConnecting");
_status = AIO_NET_DISCONNECTED;
}
_mqtt_client->setCACert(_aio_root_ca_prod);
}
/**************************************************************************/
/*!
@brief Disconnects from the wifi network.
*/
/**************************************************************************/
void _disconnect() {
WiFi.disconnect();
delay(AIO_NET_DISCONNECT_WAIT);
}
};
#endif // ADAFRUITIO_RP2040_H
#endif // ARDUINO_ARCH_RP2040

View file

@ -129,7 +129,7 @@ protected:
_status = AIO_SSID_INVALID; _status = AIO_SSID_INVALID;
} else { } else {
_disconnect(); _disconnect();
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); //
// no shield? bail // no shield? bail
if (WiFi.status() == WL_NO_SHIELD) { if (WiFi.status() == WL_NO_SHIELD) {