Skip to content

Commit 5af8a00

Browse files
committed
Merge remote-tracking branch 'adafruit/master'
2 parents 44235e8 + edd29bb commit 5af8a00

76 files changed

Lines changed: 422974 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Binary file not shown.
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
SerialNINAPassthrough - Use esptool to flash the ESP32 module
3+
For use with PyPortal, Metro M4 WiFi...
4+
5+
Copyright (c) 2018 Arduino SA. All rights reserved.
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public
18+
License along with this library; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
*/
21+
22+
unsigned long baud = 115200;
23+
24+
void setup() {
25+
Serial.begin(baud);
26+
27+
SerialNina.begin(baud);
28+
29+
pinMode(13, OUTPUT);
30+
pinMode(ESP32_GPIO0, OUTPUT);
31+
pinMode(ESP32_RESETN, OUTPUT);
32+
33+
// manually put the ESP32 in upload mode
34+
digitalWrite(ESP32_GPIO0, LOW);
35+
36+
digitalWrite(ESP32_RESETN, LOW);
37+
delay(100);
38+
digitalWrite(ESP32_RESETN, HIGH);
39+
40+
}
41+
42+
void loop() {
43+
if (Serial.available()) {
44+
digitalWrite(13, HIGH);
45+
SerialESP32.write(Serial.read());
46+
digitalWrite(13, LOW);
47+
}
48+
49+
if (SerialESP32.available()) {
50+
Serial.write(SerialESP32.read());
51+
}
52+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
This example creates a client object that connects and transfers
3+
data using always SSL.
4+
5+
It is compatible with the methods normally related to plain
6+
connections, like client.connect(host, port).
7+
8+
Written by Arturo Guadalupi
9+
last revision November 2015
10+
11+
*/
12+
13+
#include <SPI.h>
14+
#include <WiFiNINA.h>
15+
16+
#include "arduino_secrets.h"
17+
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
18+
char ssid[] = SECRET_SSID; // your network SSID (name)
19+
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
20+
int keyIndex = 0; // your network key Index number (needed only for WEP)
21+
22+
int status = WL_IDLE_STATUS;
23+
// if you don't want to use DNS (and reduce your sketch size)
24+
// use the numeric IP instead of the name for the server:
25+
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
26+
27+
//#define SERVER "www.google.com" // name address for Google (using DNS)
28+
//#define PATH "/search?q=arduino"
29+
30+
#define SERVER "cdn.syndication.twimg.com"
31+
#define PATH "/widgets/followbutton/info.json?screen_names=adafruit"
32+
33+
//#define SERVER "img.shields.io"
34+
//#define PATH "/discord/327254708534116352.svg"
35+
36+
//#define SERVER "cdn.thingiverse.com"
37+
//#define PATH "/renders/77/0c/f0/f6/2e/dbc6c3056540bdf03757ecc90fbe4b5f_preview_featured.jpg"
38+
39+
40+
// Initialize the SSL client library
41+
// with the IP address and port of the server
42+
// that you want to connect to (port 443 is default for HTTPS):
43+
WiFiSSLClient client;
44+
45+
void setup() {
46+
//Initialize serial and wait for port to open:
47+
Serial.begin(9600);
48+
while (!Serial) {
49+
; // wait for serial port to connect. Needed for native USB port only
50+
}
51+
52+
// check for the WiFi module:
53+
while (WiFi.status() == WL_NO_MODULE) {
54+
Serial.println("Communication with WiFi module failed!");
55+
delay(1000);
56+
}
57+
58+
String fv = WiFi.firmwareVersion();
59+
if (fv < "1.0.0") {
60+
Serial.println("Please upgrade the firmware");
61+
}
62+
63+
// attempt to connect to Wifi network:
64+
Serial.print("Attempting to connect to SSID: ");
65+
Serial.println(ssid);
66+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
67+
do {
68+
status = WiFi.begin(ssid, pass);
69+
delay(100); // wait until connected
70+
} while (status != WL_CONNECTED);
71+
Serial.println("Connected to wifi");
72+
printWifiStatus();
73+
74+
Serial.println("\nStarting connection to server...");
75+
// if you get a connection, report back via serial:
76+
if (client.connect(SERVER, 443)) {
77+
Serial.println("connected to server");
78+
// Make a HTTP request:
79+
client.println("GET " PATH " HTTP/1.1");
80+
client.println("Host: " SERVER);
81+
client.println("Connection: close");
82+
client.println();
83+
}
84+
}
85+
86+
uint32_t bytes = 0;
87+
88+
void loop() {
89+
// if there are incoming bytes available
90+
// from the server, read them and print them:
91+
while (client.available()) {
92+
char c = client.read();
93+
Serial.write(c);
94+
bytes++;
95+
}
96+
97+
// if the server's disconnected, stop the client:
98+
if (!client.connected()) {
99+
Serial.println();
100+
Serial.println("disconnecting from server.");
101+
client.stop();
102+
Serial.print("Read "); Serial.print(bytes); Serial.println(" bytes");
103+
104+
// do nothing forevermore:
105+
while (true);
106+
}
107+
}
108+
109+
110+
void printWifiStatus() {
111+
// print the SSID of the network you're attached to:
112+
Serial.print("SSID: ");
113+
Serial.println(WiFi.SSID());
114+
115+
// print your board's IP address:
116+
IPAddress ip = WiFi.localIP();
117+
Serial.print("IP Address: ");
118+
Serial.println(ip);
119+
120+
// print the received signal strength:
121+
long rssi = WiFi.RSSI();
122+
Serial.print("signal strength (RSSI):");
123+
Serial.print(rssi);
124+
Serial.println(" dBm");
125+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define SECRET_SSID "ssid name"
2+
#define SECRET_PASS "ssid password"
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
2+
/*
3+
Web client
4+
5+
This sketch connects to a website (wifitest.adafruit.com/testwifi/index.html)
6+
using the WiFi module.
7+
8+
This example is written for a network using WPA encryption. For
9+
WEP or WPA, change the Wifi.begin() call accordingly.
10+
11+
This example is written for a network using WPA encryption. For
12+
WEP or WPA, change the Wifi.begin() call accordingly.
13+
14+
Circuit:
15+
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)
16+
17+
created 13 July 2010
18+
by dlf (Metodo2 srl)
19+
modified 31 May 2012
20+
by Tom Igoe
21+
*/
22+
23+
24+
#include <SPI.h>
25+
#include <WiFiNINA.h>
26+
27+
// if the wifi definition isnt in the board variant
28+
#if !defined(SPIWIFI_SS)
29+
// Don't change the names of these #define's! they match the variant ones
30+
#define SPIWIFI_SS 10
31+
#define SPIWIFI_ACK 7
32+
#define ESP32_RESETN 5
33+
#define ESP32_GPIO0 -1
34+
#define SPIWIFI SPI
35+
#endif
36+
37+
38+
#include "arduino_secrets.h"
39+
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
40+
char ssid[] = SECRET_SSID; // your network SSID (name)
41+
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
42+
int keyIndex = 0; // your network key Index number (needed only for WEP)
43+
44+
int status = WL_IDLE_STATUS;
45+
// if you don't want to use DNS (and reduce your sketch size)
46+
// use the numeric IP instead of the name for the server:
47+
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
48+
49+
char server[] = "wifitest.adafruit.com"; // name address for adafruit test
50+
char path[] = "/testwifi/index.html";
51+
52+
// Initialize the Ethernet client library
53+
// with the IP address and port of the server
54+
// that you want to connect to (port 80 is default for HTTP):
55+
WiFiClient client;
56+
57+
void setup() {
58+
//Initialize serial and wait for port to open:
59+
Serial.begin(9600);
60+
while (!Serial) {
61+
; // wait for serial port to connect. Needed for native USB port only
62+
}
63+
64+
// check for the WiFi module:
65+
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
66+
while (WiFi.status() == WL_NO_MODULE) {
67+
Serial.println("Communication with WiFi module failed!");
68+
// don't continue
69+
delay(1000);
70+
}
71+
72+
String fv = WiFi.firmwareVersion();
73+
if (fv < "1.0.0") {
74+
Serial.println("Please upgrade the firmware");
75+
}
76+
Serial.print("Found firmware "); Serial.println(fv);
77+
78+
// attempt to connect to Wifi network:
79+
Serial.print("Attempting to connect to SSID: ");
80+
Serial.println(ssid);
81+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
82+
do {
83+
status = WiFi.begin(ssid, pass);
84+
delay(100); // wait until connection is ready!
85+
} while (status != WL_CONNECTED);
86+
87+
Serial.println("Connected to wifi");
88+
printWifiStatus();
89+
90+
Serial.println("\nStarting connection to server...");
91+
// if you get a connection, report back via serial:
92+
if (client.connect(server, 80)) {
93+
Serial.println("connected to server");
94+
// Make a HTTP request:
95+
client.print("GET "); client.print(path); client.println(" HTTP/1.1");
96+
client.print("Host: "); client.println(server);
97+
client.println("Connection: close");
98+
client.println();
99+
}
100+
}
101+
102+
void loop() {
103+
// if there are incoming bytes available
104+
// from the server, read them and print them:
105+
while (client.available()) {
106+
char c = client.read();
107+
Serial.write(c);
108+
}
109+
110+
// if the server's disconnected, stop the client:
111+
if (!client.connected()) {
112+
Serial.println();
113+
Serial.println("disconnecting from server.");
114+
client.stop();
115+
116+
// do nothing forevermore:
117+
while (true);
118+
}
119+
}
120+
121+
122+
void printWifiStatus() {
123+
// print the SSID of the network you're attached to:
124+
Serial.print("SSID: ");
125+
Serial.println(WiFi.SSID());
126+
127+
// print your board's IP address:
128+
IPAddress ip = WiFi.localIP();
129+
Serial.print("IP Address: ");
130+
Serial.println(ip);
131+
132+
// print the received signal strength:
133+
long rssi = WiFi.RSSI();
134+
Serial.print("signal strength (RSSI):");
135+
Serial.print(rssi);
136+
Serial.println(" dBm");
137+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define SECRET_SSID "your wifi ssid"
2+
#define SECRET_PASS "your wifi password"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define SECRET_SSID "ssid"
2+
#define SECRET_PASS "password"

0 commit comments

Comments
 (0)