This project shows you you to create a visual alert to notify you if your internet service has gone down.
Functional Parts in the Project:
- Arduino WiFi Rev 2 – https://store.arduino.cc/usa/arduino-uno-wifi-rev2
- Breadboard Kit – https://amzn.to/2Xih5ei
- 560 Piece Jumper Wire Kit – https://amzn.to/2MsCLjL
- LED Kit – https://amzn.to/2Rjhs2N
- 220 Ohm Resistors – https://amzn.to/2RiiMD9
#include <WiFiNINA.h>
#define googleOnlineLED 9
#define googleOfflineLED 10
char ssid[] = "test";
char pass[] = "";
int status = WL_IDLE_STATUS;
char google[] = "google.com";
WiFiClient client;
void setup() {
pinMode(googleOnlineLED, OUTPUT);
pinMode(googleOfflineLED, OUTPUT);
Serial.begin(9600);
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(10000);
}
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
IPAddress gateway = WiFi.gatewayIP();
Serial.print("IP Address: ");
Serial.println(ip);
Serial.print("Default Gateway: ");
Serial.println(gateway);
}
void loop() {
if (client.connect(google, 80)) {
Serial.print("Google is ONLINE at: ");
Serial.println(client.remoteIP());
digitalWrite(googleOnlineLED, HIGH);
digitalWrite(googleOfflineLED, LOW);
}
else {
Serial.println("Google is OFFLINE");
digitalWrite(googleOnlineLED, LOW);
digitalWrite(googleOfflineLED, HIGH);
}
delay(2000);
}
Be the first to comment