Merge pull request #2 from siddacious/add_bitsy_pinmapping
added and updated ifdef block to include ITSYBITSY M4/M0/32u4 3V
This commit is contained in:
commit
3f251f03dd
12 changed files with 705 additions and 330 deletions
|
|
@ -12,7 +12,48 @@
|
|||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
|
@ -23,6 +64,8 @@ void setup() {
|
|||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
|
|
@ -22,6 +22,46 @@
|
|||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
|
|
@ -36,6 +76,7 @@ void setup() {
|
|||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
|
|
@ -12,7 +12,48 @@
|
|||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
|
||||
|
|
@ -25,6 +66,7 @@ void setup() {
|
|||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
|
|
@ -17,15 +17,45 @@ last revision November 2015
|
|||
// uncomment the next line if you have a 128x32 OLED on the I2C pins
|
||||
//#define USE_OLED
|
||||
|
||||
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#define SPIWIFI SPI
|
||||
#define SPIWIFI_SS 10 // Chip select pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#if defined(USE_OLED)
|
||||
|
|
@ -206,4 +236,4 @@ void printWifiStatus() {
|
|||
Serial.print("signal strength (RSSI):");
|
||||
Serial.print(rssi);
|
||||
Serial.println(" dBm");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,157 +1,160 @@
|
|||
/*
|
||||
|
||||
This example prints the board's MAC address, and
|
||||
scans for available Wifi networks using the NINA module.
|
||||
Every ten seconds, it scans again. It doesn't actually
|
||||
connect to any network, so no encryption scheme is specified.
|
||||
|
||||
Circuit:
|
||||
* Board with NINA firmware on it (In this case its an Adafruit AirLift)
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 21 Junn 2012
|
||||
by Tom Igoe and Jaymes Dec
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 10
|
||||
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
Serial.println("WiFi Scanning test");
|
||||
|
||||
// Set up the pins!
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
|
||||
// check for the WiFi module:
|
||||
while (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
// don't continue
|
||||
delay(1000);
|
||||
}
|
||||
String fv = WiFi.firmwareVersion();
|
||||
Serial.println(fv);
|
||||
if (fv < "1.0.0") {
|
||||
Serial.println("Please upgrade the firmware");
|
||||
while (1) delay(10);
|
||||
}
|
||||
Serial.println("Firmware OK");
|
||||
|
||||
// print your MAC address:
|
||||
byte mac[6];
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
printMacAddress(mac);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// scan for existing networks:
|
||||
Serial.println("Scanning available networks...");
|
||||
listNetworks();
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
void listNetworks() {
|
||||
// scan for nearby networks:
|
||||
Serial.println("** Scan Networks **");
|
||||
int numSsid = WiFi.scanNetworks();
|
||||
if (numSsid == -1) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while (true);
|
||||
}
|
||||
|
||||
// print the list of networks seen:
|
||||
Serial.print("number of available networks:");
|
||||
Serial.println(numSsid);
|
||||
|
||||
// print the network number and name for each network found:
|
||||
for (int thisNet = 0; thisNet < numSsid; thisNet++) {
|
||||
Serial.print(thisNet);
|
||||
Serial.print(") ");
|
||||
Serial.print(WiFi.SSID(thisNet));
|
||||
Serial.print("\tSignal: ");
|
||||
Serial.print(WiFi.RSSI(thisNet));
|
||||
Serial.print(" dBm");
|
||||
Serial.print("\tEncryption: ");
|
||||
printEncryptionType(WiFi.encryptionType(thisNet));
|
||||
}
|
||||
}
|
||||
|
||||
void printEncryptionType(int thisType) {
|
||||
// read the encryption type and print out the name:
|
||||
switch (thisType) {
|
||||
case ENC_TYPE_WEP:
|
||||
Serial.println("WEP");
|
||||
break;
|
||||
case ENC_TYPE_TKIP:
|
||||
Serial.println("WPA");
|
||||
break;
|
||||
case ENC_TYPE_CCMP:
|
||||
Serial.println("WPA2");
|
||||
break;
|
||||
case ENC_TYPE_NONE:
|
||||
Serial.println("None");
|
||||
break;
|
||||
case ENC_TYPE_AUTO:
|
||||
Serial.println("Auto");
|
||||
break;
|
||||
case ENC_TYPE_UNKNOWN:
|
||||
default:
|
||||
Serial.println("Unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printMacAddress(byte mac[]) {
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
if (mac[i] < 16) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(mac[i], HEX);
|
||||
if (i > 0) {
|
||||
Serial.print(":");
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
/*
|
||||
|
||||
This example prints the board's MAC address, and
|
||||
scans for available Wifi networks using the NINA module.
|
||||
Every ten seconds, it scans again. It doesn't actually
|
||||
connect to any network, so no encryption scheme is specified.
|
||||
|
||||
Circuit:
|
||||
* Board with NINA firmware on it (In this case its an Adafruit AirLift)
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 21 Junn 2012
|
||||
by Tom Igoe and Jaymes Dec
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 10
|
||||
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
Serial.println("WiFi Scanning test");
|
||||
|
||||
// Set up the pins!
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
|
||||
// check for the WiFi module:
|
||||
while (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
// don't continue
|
||||
delay(1000);
|
||||
}
|
||||
String fv = WiFi.firmwareVersion();
|
||||
Serial.println(fv);
|
||||
if (fv < "1.0.0") {
|
||||
Serial.println("Please upgrade the firmware");
|
||||
while (1) delay(10);
|
||||
}
|
||||
Serial.println("Firmware OK");
|
||||
|
||||
// print your MAC address:
|
||||
byte mac[6];
|
||||
WiFi.macAddress(mac);
|
||||
Serial.print("MAC: ");
|
||||
printMacAddress(mac);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// scan for existing networks:
|
||||
Serial.println("Scanning available networks...");
|
||||
listNetworks();
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
void listNetworks() {
|
||||
// scan for nearby networks:
|
||||
Serial.println("** Scan Networks **");
|
||||
int numSsid = WiFi.scanNetworks();
|
||||
if (numSsid == -1) {
|
||||
Serial.println("Couldn't get a wifi connection");
|
||||
while (true);
|
||||
}
|
||||
|
||||
// print the list of networks seen:
|
||||
Serial.print("number of available networks:");
|
||||
Serial.println(numSsid);
|
||||
|
||||
// print the network number and name for each network found:
|
||||
for (int thisNet = 0; thisNet < numSsid; thisNet++) {
|
||||
Serial.print(thisNet);
|
||||
Serial.print(") ");
|
||||
Serial.print(WiFi.SSID(thisNet));
|
||||
Serial.print("\tSignal: ");
|
||||
Serial.print(WiFi.RSSI(thisNet));
|
||||
Serial.print(" dBm");
|
||||
Serial.print("\tEncryption: ");
|
||||
printEncryptionType(WiFi.encryptionType(thisNet));
|
||||
}
|
||||
}
|
||||
|
||||
void printEncryptionType(int thisType) {
|
||||
// read the encryption type and print out the name:
|
||||
switch (thisType) {
|
||||
case ENC_TYPE_WEP:
|
||||
Serial.println("WEP");
|
||||
break;
|
||||
case ENC_TYPE_TKIP:
|
||||
Serial.println("WPA");
|
||||
break;
|
||||
case ENC_TYPE_CCMP:
|
||||
Serial.println("WPA2");
|
||||
break;
|
||||
case ENC_TYPE_NONE:
|
||||
Serial.println("None");
|
||||
break;
|
||||
case ENC_TYPE_AUTO:
|
||||
Serial.println("Auto");
|
||||
break;
|
||||
case ENC_TYPE_UNKNOWN:
|
||||
default:
|
||||
Serial.println("Unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printMacAddress(byte mac[]) {
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
if (mac[i] < 16) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(mac[i], HEX);
|
||||
if (i > 0) {
|
||||
Serial.print(":");
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,46 @@
|
|||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,46 @@
|
|||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
|
|
@ -33,6 +73,7 @@ void setup() {
|
|||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,13 @@ last revision November 2015
|
|||
#include <WiFiNINA.h>
|
||||
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || defined(ADAFRUIT_FEATHER_M0_EXPRESS) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_NRF52840_FEATHER)
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
|
|
@ -148,4 +154,4 @@ void printWifiStatus() {
|
|||
Serial.print("signal strength (RSSI):");
|
||||
Serial.print(rssi);
|
||||
Serial.println(" dBm");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,47 @@
|
|||
|
||||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
|
@ -45,6 +86,7 @@ void setup() {
|
|||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
|
|
@ -13,6 +13,47 @@
|
|||
|
||||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
int status = WL_IDLE_STATUS;
|
||||
|
|
@ -36,6 +77,7 @@ void setup() {
|
|||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
|
|
@ -1,163 +1,167 @@
|
|||
|
||||
/*
|
||||
Web client
|
||||
|
||||
This sketch connects to a website (wifitest.adafruit.com/testwifi/index.html)
|
||||
using the WiFi module.
|
||||
|
||||
This example is written for a network using WPA encryption. For
|
||||
WEP or WPA, change the Wifi.begin() call accordingly.
|
||||
|
||||
This example is written for a network using WPA encryption. For
|
||||
WEP or WPA, change the Wifi.begin() call accordingly.
|
||||
|
||||
Circuit:
|
||||
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || defined(ADAFRUIT_FEATHER_M0_EXPRESS) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_NRF52840_FEATHER)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
|
||||
int keyIndex = 0; // your network key Index number (needed only for WEP)
|
||||
|
||||
int status = WL_IDLE_STATUS;
|
||||
// if you don't want to use DNS (and reduce your sketch size)
|
||||
// use the numeric IP instead of the name for the server:
|
||||
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
|
||||
|
||||
char server[] = "wifitest.adafruit.com"; // name address for adafruit test
|
||||
char path[] = "/testwifi/index.html";
|
||||
|
||||
// Initialize the Ethernet client library
|
||||
// with the IP address and port of the server
|
||||
// that you want to connect to (port 80 is default for HTTP):
|
||||
WiFiClient client;
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// check for the WiFi module:
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
while (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
// don't continue
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if (fv < "1.0.0") {
|
||||
Serial.println("Please upgrade the firmware");
|
||||
}
|
||||
Serial.print("Found firmware "); Serial.println(fv);
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
Serial.println(ssid);
|
||||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
|
||||
do {
|
||||
status = WiFi.begin(ssid, pass);
|
||||
delay(100); // wait until connection is ready!
|
||||
} while (status != WL_CONNECTED);
|
||||
|
||||
Serial.println("Connected to wifi");
|
||||
printWifiStatus();
|
||||
|
||||
Serial.println("\nStarting connection to server...");
|
||||
// if you get a connection, report back via serial:
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("connected to server");
|
||||
// Make a HTTP request:
|
||||
client.print("GET "); client.print(path); client.println(" HTTP/1.1");
|
||||
client.print("Host: "); client.println(server);
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there are incoming bytes available
|
||||
// from the server, read them and print them:
|
||||
while (client.available()) {
|
||||
char c = client.read();
|
||||
Serial.write(c);
|
||||
}
|
||||
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
Serial.println();
|
||||
Serial.println("disconnecting from server.");
|
||||
client.stop();
|
||||
|
||||
// do nothing forevermore:
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printWifiStatus() {
|
||||
// print the SSID of the network you're attached to:
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(WiFi.SSID());
|
||||
|
||||
// print your board's IP address:
|
||||
IPAddress ip = WiFi.localIP();
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(ip);
|
||||
|
||||
// print the received signal strength:
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("signal strength (RSSI):");
|
||||
Serial.print(rssi);
|
||||
Serial.println(" dBm");
|
||||
}
|
||||
|
||||
/*
|
||||
Web client
|
||||
|
||||
This sketch connects to a website (wifitest.adafruit.com/testwifi/index.html)
|
||||
using the WiFi module.
|
||||
|
||||
This example is written for a network using WPA encryption. For
|
||||
WEP or WPA, change the Wifi.begin() call accordingly.
|
||||
|
||||
This example is written for a network using WPA encryption. For
|
||||
WEP or WPA, change the Wifi.begin() call accordingly.
|
||||
|
||||
Circuit:
|
||||
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)
|
||||
|
||||
created 13 July 2010
|
||||
by dlf (Metodo2 srl)
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
|
||||
int keyIndex = 0; // your network key Index number (needed only for WEP)
|
||||
|
||||
int status = WL_IDLE_STATUS;
|
||||
// if you don't want to use DNS (and reduce your sketch size)
|
||||
// use the numeric IP instead of the name for the server:
|
||||
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
|
||||
|
||||
char server[] = "wifitest.adafruit.com"; // name address for adafruit test
|
||||
char path[] = "/testwifi/index.html";
|
||||
|
||||
// Initialize the Ethernet client library
|
||||
// with the IP address and port of the server
|
||||
// that you want to connect to (port 80 is default for HTTP):
|
||||
WiFiClient client;
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// check for the WiFi module:
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
while (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
// don't continue
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if (fv < "1.0.0") {
|
||||
Serial.println("Please upgrade the firmware");
|
||||
}
|
||||
Serial.print("Found firmware "); Serial.println(fv);
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
Serial.println(ssid);
|
||||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
|
||||
do {
|
||||
status = WiFi.begin(ssid, pass);
|
||||
delay(100); // wait until connection is ready!
|
||||
} while (status != WL_CONNECTED);
|
||||
|
||||
Serial.println("Connected to wifi");
|
||||
printWifiStatus();
|
||||
|
||||
Serial.println("\nStarting connection to server...");
|
||||
// if you get a connection, report back via serial:
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("connected to server");
|
||||
// Make a HTTP request:
|
||||
client.print("GET "); client.print(path); client.println(" HTTP/1.1");
|
||||
client.print("Host: "); client.println(server);
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there are incoming bytes available
|
||||
// from the server, read them and print them:
|
||||
while (client.available()) {
|
||||
char c = client.read();
|
||||
Serial.write(c);
|
||||
}
|
||||
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
Serial.println();
|
||||
Serial.println("disconnecting from server.");
|
||||
client.stop();
|
||||
|
||||
// do nothing forevermore:
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printWifiStatus() {
|
||||
// print the SSID of the network you're attached to:
|
||||
Serial.print("SSID: ");
|
||||
Serial.println(WiFi.SSID());
|
||||
|
||||
// print your board's IP address:
|
||||
IPAddress ip = WiFi.localIP();
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(ip);
|
||||
|
||||
// print the received signal strength:
|
||||
long rssi = WiFi.RSSI();
|
||||
Serial.print("signal strength (RSSI):");
|
||||
Serial.print(rssi);
|
||||
Serial.println(" dBm");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,46 @@
|
|||
#include <SPI.h>
|
||||
#include <WiFiNINA.h>
|
||||
|
||||
#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
|
||||
defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_FEATHER32U4) || \
|
||||
defined(ARDUINO_NRF52840_FEATHER) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M0_EXPRESS) || \
|
||||
defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
|
||||
defined(ARDUINO_AVR_ITSYBITSY32U4_3V)
|
||||
// Configure the pins used for the ESP32 connection
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 13 // Chip select pin
|
||||
#define ESP32_RESETN 12 // Reset pin
|
||||
#define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_AVR_FEATHER328P)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 4 // Chip select pin
|
||||
#define ESP32_RESETN 3 // Reset pin
|
||||
#define SPIWIFI_ACK 2 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 5 // Chip select pin
|
||||
#define ESP32_RESETN 6 // Reset pin
|
||||
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif defined(ARDUINO_NRF52832_FEATHER )
|
||||
#define SPIWIFI SPI // The SPI port
|
||||
#define SPIWIFI_SS 16 // Chip select pin
|
||||
#define ESP32_RESETN 15 // Reset pin
|
||||
#define SPIWIFI_ACK 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_GPIO0 -1
|
||||
#elif !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 7 // a.k.a BUSY or READY pin
|
||||
#define ESP32_RESETN 5 // Reset pin
|
||||
#define ESP32_GPIO0 -1 // Not connected
|
||||
#endif
|
||||
|
||||
#include "arduino_secrets.h"
|
||||
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
|
||||
char ssid[] = SECRET_SSID; // your network SSID (name)
|
||||
|
|
@ -42,6 +82,7 @@ void setup() {
|
|||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
|
||||
// check for the WiFi module:
|
||||
if (WiFi.status() == WL_NO_MODULE) {
|
||||
Serial.println("Communication with WiFi module failed!");
|
||||
|
|
|
|||
Loading…
Reference in a new issue