Skip to content

Commit d7f4bd2

Browse files
authored
Merge pull request #155 from darumsdad/master
Support for Arduino WiFi MKR 1010 and Arduino Nano 33 IOT
2 parents 28fd173 + 0647433 commit d7f4bd2

File tree

30 files changed

+170
-1
lines changed

30 files changed

+170
-1
lines changed

examples/adafruitio_00_publish/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_01_subscribe/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_02_pubsub/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
// uncomment the following line if you are using winc1500
2828
// #define USE_WINC1500
2929

30+
// uncomment the following line if you are using mrk1010 or nano 33 iot
31+
//#define ARDUINO_SAMD_MKR1010
32+
3033
// comment out the following lines if you are using fona or ethernet
3134
#include "AdafruitIO_WiFi.h"
3235

examples/adafruitio_03_multiple_feeds/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_04_location/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_05_type_conversion/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_06_digital_in/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_07_digital_out/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_08_analog_in/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_09_analog_out/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_10_dashboard_creation/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_11_group_pub/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_12_group_sub/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_13_rgb/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_14_neopixel/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_15_temp_humidity/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_16_servo/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_17_time_subscribe/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_18_device_info/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_19_deepsleep/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_20_shared_feed_write/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_21_feed_read/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_22_environmental_monitor/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/adafruitio_23_ifttt/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
// uncomment the following line if you are using winc1500
2828
// #define USE_WINC1500
2929

30+
// uncomment the following line if you are using mrk1010 or nano 33 iot
31+
//#define ARDUINO_SAMD_MKR1010
32+
3033
// comment out the following lines if you are using fona or ethernet
3134
#include "AdafruitIO_WiFi.h"
3235

examples/adafruitio_24_zapier/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/io_home_series/io_home_security/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

examples/io_home_series/neopixel_and_thermometer/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// uncomment the following line if you are using winc1500
3030
// #define USE_WINC1500
3131

32+
// uncomment the following line if you are using mrk1010 or nano 33 iot
33+
//#define ARDUINO_SAMD_MKR1010
34+
3235
// comment out the following lines if you are using fona or ethernet
3336
#include "AdafruitIO_WiFi.h"
3437

src/AdafruitIO_WiFi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#include "wifi/AdafruitIO_MKR1000.h"
2121
typedef AdafruitIO_MKR1000 AdafruitIO_WiFi;
2222

23+
#elif defined(ARDUINO_SAMD_MKR1010)
24+
25+
#include "wifi/AdafruitIO_MKR1010.h"
26+
typedef AdafruitIO_MKR1010 AdafruitIO_WiFi;
27+
2328
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
2429
defined(USE_AIRLIFT)
2530

src/wifi/AdafruitIO_MKR1010.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*!
2+
* @file AdafruitIO_MKR1010.h
3+
*
4+
* Adafruit invests time and resources providing this open source code.
5+
* Please support Adafruit and open source hardware by purchasing
6+
* products from Adafruit!
7+
*
8+
* Copyright (c) 2015-2016 Adafruit Industries
9+
* Authors: David Goldstein, Morgan Winters
10+
* Licensed under the MIT license.
11+
*
12+
* All text above must be included in any redistribution.
13+
*/
14+
15+
#ifndef ADAFRUITIO_MKR1010_H
16+
#define ADAFRUITIO_MKR1010_H
17+
18+
#include "AdafruitIO.h"
19+
#include "Adafruit_MQTT.h"
20+
#include "Adafruit_MQTT_Client.h"
21+
#include "Arduino.h"
22+
#include "SPI.h"
23+
#include "WiFiNINA.h"
24+
#include "WiFiSSLClient.h"
25+
26+
class AdafruitIO_MKR1010 : public AdafruitIO {
27+
28+
public:
29+
AdafruitIO_MKR1010(const char *user, const char *key, const char *ssid,
30+
const char *pass)
31+
: AdafruitIO(user, key) {
32+
_ssid = ssid;
33+
_pass = pass;
34+
_client = new WiFiSSLClient;
35+
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
36+
_http = new HttpClient(*_client, _host, _http_port);
37+
}
38+
~AdafruitIO_MKR1010() {
39+
if (_client)
40+
delete _client;
41+
if (_mqtt)
42+
delete _mqtt;
43+
}
44+
45+
aio_status_t networkStatus() {
46+
switch (WiFi.status()) {
47+
case WL_CONNECTED:
48+
return AIO_NET_CONNECTED;
49+
case WL_CONNECT_FAILED:
50+
return AIO_NET_CONNECT_FAILED;
51+
case WL_IDLE_STATUS:
52+
return AIO_IDLE;
53+
default:
54+
return AIO_NET_DISCONNECTED;
55+
}
56+
}
57+
58+
const char *connectionType() { return "wifi"; }
59+
60+
protected:
61+
void _connect() {
62+
if (strlen(_ssid) == 0) {
63+
_status = AIO_SSID_INVALID;
64+
} else {
65+
_disconnect();
66+
67+
WiFi.begin(_ssid, _pass);
68+
_status = networkStatus();
69+
}
70+
}
71+
72+
void _disconnect() {
73+
WiFi.disconnect();
74+
delay(AIO_NET_DISCONNECT_WAIT);
75+
}
76+
77+
const char *_ssid;
78+
const char *_pass;
79+
80+
WiFiSSLClient *_client;
81+
};
82+
83+
#endif ADAFRUITIO_MKR1010_H

src/wifi/AdafruitIO_WINC1500.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class AdafruitIO_WINC1500 : public AdafruitIO {
129129
_status = AIO_SSID_INVALID;
130130
} else {
131131
_disconnect();
132-
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en);
132+
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); //
133133

134134
// no shield? bail
135135
if (WiFi.status() == WL_NO_SHIELD) {

0 commit comments

Comments
 (0)