Skip to content

Commit 10720aa

Browse files
committed
update for Portenta H7
replace google search with page from example.com
1 parent 719c0b5 commit 10720aa

File tree

2 files changed

+13
-29
lines changed

2 files changed

+13
-29
lines changed

libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,34 @@
1-
21
/*
32
Web client
43
5-
This sketch connects to a website (http://www.google.com)
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.
4+
This sketch connects to a website (http://example.com) using the WiFi module.
105
116
This example is written for a network using WPA encryption. For
127
WEP or WPA, change the Wifi.begin() call accordingly.
138
149
Circuit:
15-
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)
10+
* Arduino Portenta H7
1611
1712
created 13 July 2010
1813
by dlf (Metodo2 srl)
1914
modified 31 May 2012
2015
by Tom Igoe
2116
*/
2217

23-
24-
#include <SPI.h>
25-
#include <WiFiNINA.h>
18+
#include <WiFi.h>
2619

2720
#include "arduino_secrets.h"
2821
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
2922
char ssid[] = SECRET_SSID; // your network SSID (name)
30-
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
31-
int keyIndex = 0; // your network key Index number (needed only for WEP)
23+
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
24+
int keyIndex = 0; // your network key Index number (needed only for WEP)
3225

3326
int status = WL_IDLE_STATUS;
3427
// if you don't want to use DNS (and reduce your sketch size)
3528
// use the numeric IP instead of the name for the server:
36-
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
37-
char server[] = "www.google.com"; // name address for Google (using DNS)
29+
// IPAddress server(93,184,216,34); // IP address for example.com (no DNS)
30+
char server[] = "example.com"; // host name for example.com (using DNS)
3831

39-
// Initialize the Ethernet client library
40-
// with the IP address and port of the server
41-
// that you want to connect to (port 80 is default for HTTP):
4232
WiFiClient client;
4333

4434
void setup() {
@@ -49,26 +39,21 @@ void setup() {
4939
}
5040

5141
// check for the WiFi module:
52-
if (WiFi.status() == WL_NO_MODULE) {
42+
if (WiFi.status() == WL_NO_SHIELD) {
5343
Serial.println("Communication with WiFi module failed!");
5444
// don't continue
5545
while (true);
5646
}
5747

58-
String fv = WiFi.firmwareVersion();
59-
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
60-
Serial.println("Please upgrade the firmware");
61-
}
62-
6348
// attempt to connect to Wifi network:
6449
while (status != WL_CONNECTED) {
6550
Serial.print("Attempting to connect to SSID: ");
6651
Serial.println(ssid);
6752
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
6853
status = WiFi.begin(ssid, pass);
6954

70-
// wait 10 seconds for connection:
71-
delay(10000);
55+
// wait 3 seconds for connection:
56+
delay(3000);
7257
}
7358
Serial.println("Connected to wifi");
7459
printWifiStatus();
@@ -78,8 +63,9 @@ void setup() {
7863
if (client.connect(server, 80)) {
7964
Serial.println("connected to server");
8065
// Make a HTTP request:
81-
client.println("GET /search?q=arduino HTTP/1.1");
82-
client.println("Host: www.google.com");
66+
client.println("GET /index.html HTTP/1.1");
67+
client.print("Host: ");
68+
client.println(server);
8369
client.println("Connection: close");
8470
client.println();
8571
}
@@ -104,7 +90,6 @@ void loop() {
10490
}
10591
}
10692

107-
10893
void printWifiStatus() {
10994
// print the SSID of the network you're attached to:
11095
Serial.print("SSID: ");
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
21
#define SECRET_SSID ""
32
#define SECRET_PASS ""

0 commit comments

Comments
 (0)