Skip to content

Commit

Permalink
Merge pull request #202 from brentru/add-nano33-iot
Browse files Browse the repository at this point in the history
Add support for Arduino Nano 33 IoT, MKR1010 WiFi
  • Loading branch information
brentru authored Jan 6, 2022
2 parents 4746949 + ace150b commit c05a050
Show file tree
Hide file tree
Showing 23 changed files with 398 additions and 70 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,66 @@ jobs:
wippersnapper.${{ matrix.arduino-platform }}.${{ env.WS_VERSION }}.uf2
wippersnapper.${{ matrix.arduino-platform }}.${{ env.WS_VERSION }}.hex
# NOTE: This does NOT release artifacts, it only builds
build-samd-non-fs:
name: Build WipperSnapper SAMD (NO-TINYUSB)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arduino-platform: ["mkrwifi1010", "nano_33_iot"]
steps:
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v2
- name: Get WipperSnapper version
run: |
git fetch --prune --unshallow --tags
git describe --dirty --tags
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
- uses: actions/checkout@v2
with:
repository: brentru/ci-arduino
path: ci
- name: Install CI-Arduino
run: bash ci/actions_install.sh
- name: Install extra Arduino libraries
run: |
git clone --quiet https://github.com/arduino-libraries/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA
git clone --quiet https://github.com/brentru/Adafruit_MQTT_Library.git /home/runner/Arduino/libraries/Adafruit_MQTT_Library
- name: build platforms
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}

# NOTE: This does NOT release artifacts, it only builds
build-esp8266:
name: Build WipperSnapper ESP8266
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arduino-platform: ["esp8266"]
steps:
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v2
- name: Get WipperSnapper version
run: |
git fetch --prune --unshallow --tags
git describe --dirty --tags
echo >>$GITHUB_ENV WS_VERSION=$(git describe --dirty --tags)
- uses: actions/checkout@v2
with:
repository: brentru/ci-arduino
path: ci
- name: Install CI-Arduino
run: bash ci/actions_install.sh
- name: Install extra Arduino library
run: |
git clone --quiet https://github.com/brentru/Adafruit_MQTT_Library.git /home/runner/Arduino/libraries/Adafruit_MQTT_Library
- name: build platforms
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}

clang_and_doxy:
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@

# Doxygen
*.bak
html/*

# Clang-format Python Script
*.py

# VSCode artifacts
./vscode/*
src/.vscode/settings.json
src/.vscode/settings.json

# macOS
.DS_STORE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


3 changes: 3 additions & 0 deletions examples/Wippersnapper_NoFS/.pyportal_tinyusb.test.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@



45 changes: 45 additions & 0 deletions examples/Wippersnapper_NoFS/Wippersnapper_NoFS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Adafruit IO WipperSnapper Beta
//
//
// NOTE: This software is a BETA release and in active development.
// Please report bugs or errors to
// https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/issues
//
// This sketch is for devices which lack USB-MSD or LittleFS support such
// as the Arduino MKR WiFi 1010, Arduino Nano 33 IoT.
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Brent Rubell for Adafruit Industries, 2021
//
// All text above must be included in any redistribution.

#include "Wippersnapper_Networking.h"

/************************ 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_AIO_USERNAME"
#define IO_KEY "YOUR_AIO_PASSWORD"

/**************************** WiFi Config ***********************************/
#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASS "YOUR_WIFI_PASSWORD"

#include "Wippersnapper_Networking.h"
Wippersnapper_WiFi wipper(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

void setup() {
// Provisioning must occur prior to serial init.
wipper.provision();

Serial.begin(115200);
// while (!Serial) delay(10);

wipper.connect();
}

void loop() { wipper.run(); }
1 change: 1 addition & 0 deletions examples/Wippersnapper_demo/.nano_33_iot.test.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

This file was deleted.

2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit WipperSnapper Beta
version=1.0.0-beta.20
version=1.0.0-beta.21
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Arduino client for Adafruit.io WipperSnapper
Expand Down
29 changes: 12 additions & 17 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,13 @@ void Wippersnapper::provision() {
#elif defined(USE_NVS)
_nvs = new Wippersnapper_ESP32_nvs();
_nvs->parseSecrets();
#else
set_user_key(); // non-fs-backed, sets global credentials within network iface
#endif

// Set WiFi credentials within network interface
set_ssid_pass();
}

/****************************************************************************/
/*!
@brief Configures the device's Adafruit IO credentials. This method
should be used only if provisioning is not avaliable.
@param aio_username
Your Adafruit IO username.
@param aio_key
Your Adafruit IO active key.
*/
/****************************************************************************/
void Wippersnapper::set_user_key(const char *aio_username,
const char *aio_key) {
WS._username = aio_username;
WS._key = aio_key;
}

/**************************************************************************/
/*!
@brief Disconnects from Adafruit IO+ Wippersnapper.
Expand Down Expand Up @@ -186,6 +171,16 @@ void Wippersnapper::set_ssid_pass() {
WS_DEBUG_PRINTLN("ERROR: Please define a network interface!");
}

/****************************************************************************/
/*!
@brief Configures the device's Adafruit IO credentials. This method
should be used only if filesystem-backed provisioning is
not avaliable.
/****************************************************************************/
void Wippersnapper::set_user_key() {
WS_DEBUG_PRINTLN("ERROR: Please define a network interface!");
}

// Decoders //
/****************************************************************************/
/*!
Expand Down
2 changes: 1 addition & 1 deletion src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Wippersnapper {
false; ///< True if status LED is using the status dotstar
bool lockStatusLED = false; ///< True if status LED is using the built-in LED

void set_user_key(const char *aio_username, const char *aio_key);
virtual void set_user_key();
virtual void set_ssid_pass(const char *ssid, const char *ssidPassword);
virtual void set_ssid_pass();

Expand Down
8 changes: 8 additions & 0 deletions src/Wippersnapper_Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
#define USE_STATUS_LED
#define STATUS_LED_PIN 13
#define USE_NVS
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#define BOARD_ID "nano-33-iot"
#define USE_STATUS_LED
#define STATUS_LED_PIN 13
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#define BOARD_ID "mkr-wifi-1010"
#define USE_STATUS_LED
#define STATUS_LED_PIN 6
#else
#warning "Board type not identified within Wippersnapper_Boards.h!"
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/Wippersnapper_Networking.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ typedef Wippersnapper_ESP8266 Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_ESP32)
#include "network_interfaces/Wippersnapper_ESP32.h"
typedef Wippersnapper_ESP32 Wippersnapper_WiFi;
#elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRWIFI1010)
#include "network_interfaces/Wippersnapper_WIFININA.h"
typedef Wippersnapper_WIFININA Wippersnapper_WiFi;
#else
#warning "Must define network interface in config.h!"
#endif
Expand Down
7 changes: 6 additions & 1 deletion src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ WipperSnapper_Component_I2C::WipperSnapper_Component_I2C(

// Initialize I2C bus
#if defined(ARDUINO_ARCH_ESP32)
// ESP32, ESP32-S2
_i2c = new TwoWire(msgInitRequest->i2c_port_number);
if (!_i2c->begin(msgInitRequest->i2c_pin_sda,
msgInitRequest->i2c_pin_scl)) {
Expand All @@ -68,13 +67,19 @@ WipperSnapper_Component_I2C::WipperSnapper_Component_I2C(
_isInit = true; // if the peripheral was configured incorrectly
}
_i2c->setClock(msgInitRequest->i2c_frequency);
#elif defined(ARDUINO_ARCH_ESP8266)
_i2c = new TwoWire();
_i2c->begin(msgInitRequest->i2c_pin_sda, msgInitRequest->i2c_pin_scl);
_i2c->setClock(msgInitRequest->i2c_frequency);
_isInit = true;
#else
// SAMD
_i2c = new TwoWire(&PERIPH_WIRE, msgInitRequest->i2c_pin_sda,
msgInitRequest->i2c_pin_scl);
_i2c->begin();
_isInit = true;
#endif

// set i2c obj. properties
_portNum = msgInitRequest->i2c_port_number;
_busStatusResponse = wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_SUCCESS;
Expand Down
21 changes: 16 additions & 5 deletions src/network_interfaces/Wippersnapper_ESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,23 @@ class Wippersnapper_ESP8266 : public Wippersnapper {
/**************************************************************************/
/*!
@brief Initializes the Adafruit IO class for ESP8266 devices.
@param aioUsername
Adafruit IO username
@param aioKey
Adafruit IO key
@param netSSID
Wireless Network SSID
@param netPass
Wireless Network password
*/
/**************************************************************************/
Wippersnapper_ESP8266() : Wippersnapper() {
_ssid = 0;
_pass = 0;
Wippersnapper_ESP8266(const char *aioUsername, const char *aioKey,
const char *netSSID, const char *netPass)
: Wippersnapper() {
_ssid = netSSID;
_pass = netPass;
_username = aioUsername;
_key = aioKey;
_mqtt_client = new WiFiClientSecure;
_mqtt_client->setFingerprint(WS_SSL_FINGERPRINT);
}
Expand Down Expand Up @@ -107,8 +119,7 @@ class Wippersnapper_ESP8266 : public Wippersnapper {
*/
/*******************************************************************/
void setupMQTTClient(const char *clientID) {
if (WS._mqttBrokerURL == nullptr)
WS._mqttBrokerURL = "io.adafruit.com";
WS._mqttBrokerURL = "io.adafruit.com";
WS._mqtt =
new Adafruit_MQTT_Client(_mqtt_client, WS._mqttBrokerURL, WS._mqtt_port,
clientID, WS._username, WS._key);
Expand Down
Loading

0 comments on commit c05a050

Please sign in to comment.