Skip to content

Commit bfdece4

Browse files
authored
Merge pull request #155 from brentru/add-airlift-example
Update AirLift Example
2 parents 4b32850 + 3c71f1c commit bfdece4

File tree

4 files changed

+36
-20
lines changed

4 files changed

+36
-20
lines changed

examples/adafruitio_secure_pyportal/adafruitio_secure_pyportal.ino renamed to examples/adafruitio_secure_airlift/adafruitio_secure_airlift.ino

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
1-
/***************************************************
2-
Adafruit MQTT Library PyPortal Adafruit IO SSL/TLS Example
1+
/****************************************************************
2+
Adafruit MQTT Library, Adafruit IO SSL/TLS Example for AirLift
33
44
Must use the latest version of nina-fw from:
55
https://github.com/adafruit/nina-fw
66
7-
Adafruit PyPortal: https://www.adafruit.com/product/4116
7+
Works great with Adafruit AirLift ESP32 Co-Processors!
8+
--> https://www.adafruit.com/product/4201
9+
--> https://www.adafruit.com/product/4116
810
911
Adafruit invests time and resources providing this open source code,
1012
please support Adafruit and open-source hardware by purchasing
1113
products from Adafruit!
1214
1315
Written by Brent Rubell for Adafruit Industries.
1416
MIT license, all text above must be included in any redistribution
15-
****************************************************/
17+
*******************************************************************/
18+
1619
#include <WiFiNINA.h>
1720
#include <SPI.h>
21+
22+
// For AirLift Breakout/Wing/Shield: Configure the following to match the ESP32 Pins!
23+
#if !defined(SPIWIFI_SS)
24+
// Don't change the names of these #define's! they match the variant ones
25+
#define SPIWIFI SPI
26+
#define SPIWIFI_SS 11 // Chip select pin
27+
#define SPIWIFI_ACK 10 // a.k.a BUSY or READY pin
28+
#define ESP32_RESETN 9 // Reset pin
29+
#define ESP32_GPIO0 -1 // Not connected
30+
#define SET_PINS 1 // Pins were set using this IFNDEF
31+
#endif
32+
1833
#include "Adafruit_MQTT.h"
1934
#include "Adafruit_MQTT_Client.h"
2035

2136
/************************* WiFi Access Point *********************************/
2237

2338
#define WLAN_SSID "WLAN_SSID"
24-
#define WLAN_PASS "WLAN_PASSWORD"
39+
#define WLAN_PASS "WIFI_PASSWORD"
2540
int keyIndex = 0; // your network key Index number (needed only for WEP)
2641

2742
int status = WL_IDLE_STATUS;
@@ -59,13 +74,16 @@ void setup()
5974
; // wait for serial port to connect. Needed for native USB port only
6075
}
6176

62-
// check for the WiFi module:
63-
if (WiFi.status() == WL_NO_MODULE)
77+
// if the AirLift's pins were defined above...
78+
#ifdef SET_PINS
79+
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
80+
#endif
81+
82+
// check for the wifi module
83+
while (WiFi.status() == WL_NO_MODULE)
6484
{
6585
Serial.println("Communication with WiFi module failed!");
66-
// don't continue
67-
while (true)
68-
;
86+
delay(1000);
6987
}
7088

7189
String fv = WiFi.firmwareVersion();
@@ -74,17 +92,15 @@ void setup()
7492
Serial.println("Please upgrade the firmware");
7593
}
7694

77-
// attempt to connect to WiFi network:
78-
while (status != WL_CONNECTED)
95+
// attempt to connect to Wifi network:
96+
Serial.print("Attempting to connect to SSID: ");
97+
Serial.println(WLAN_SSID);
98+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
99+
do
79100
{
80-
Serial.print("Attempting to connect to WLAN_SSID: ");
81-
Serial.println(WLAN_SSID);
82-
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
83101
status = WiFi.begin(WLAN_SSID, WLAN_PASS);
84-
85-
// wait 10 seconds for connection:
86-
delay(10000);
87-
}
102+
delay(100); // wait until connected
103+
} while (status != WL_CONNECTED);
88104
Serial.println("Connected to wifi");
89105
printWiFiStatus();
90106
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit MQTT Library
2-
version=1.0.0
2+
version=1.0.1
33
author=Adafruit
44
maintainer=Adafruit <info@adafruit.com>
55
sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware.

0 commit comments

Comments
 (0)