#include <SPI.h>
#include <WiFiNINA.h>
#include "arduino_secrets.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27, 20, 4);//change the addresse line 6 to 0x27,16,2) if you have a 16x2 screen
///////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[] = "www.google.com"; // name address for Google (using DNS)
// 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() {
lcd.init();
lcd.backlight();
lcd.setCursor (0, 0);
//Initialize serial and wait for port to open:
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
// don't continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
lcd.setCursor(0, 0);
lcd.print("Connecting to:");
lcd.print(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(1000);
lcd.clear();
}
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
lcd.print("connected to server");
delay(3000);
lcd.clear();
}
delay(2000);
}
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);
}
lcd.setCursor(0, 0);
lcd.print("SSID: ");
lcd.print(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
lcd.setCursor(0, 1);
lcd.print("IP : ");
lcd.print(WiFi.localIP());
// print the received signal strength:
long rssi = WiFi.RSSI();
lcd.setCursor(0, 2);
lcd.print("(RSSI):");
lcd.print(rssi);
lcd.print(" dBm");
// if the server's disconnected, stop the client:
if (!client.connected()) {
lcd.clear();
lcd.print("disconnecting from server.");
}
}
Comments
Please log in or sign up to comment.