Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
I am going to show you how to monitor your home using the Arduino
Wi-Fi Shield along with the Arduino UNO board. You will be able to
monitor some sensors in your home which are installed on your doors
and you are able to know if the door has been opened or not.
Hardware Requirements:
Software Requirement:
1. Arduino IDE
Here the function setDoorStatus will set a variable to indicate that the
door has been opened.
Now we make our board answer with the status of the sensor if
something access the board and for this we have to connect the shield
to the wireless network.
Full Code:
Sign up
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "yourSSID"; // your network SSID (name)
char pass[] = "yourPass"; // your network password
int status = WL_IDLE_STATUS;
boolean door_status = false;
WiFiServer server(80);
void setup() {
// start serial port for debugging purposes
Serial.begin(9600);
if (door_status == false){
client.print("Everything is ok");
}
else {
client.print("Alert ! The door has been opened");
}
client.println("<br />");
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield'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");
}
void setDoorStatus() {
door_status = true;
}
Now upload the code into the board and wait until the “link” LED turns
green on the board.
Now just open your browser and type the IP address.
Everything is OK.
Now press the button and return to the page. The message should be
changed.
You can now monitor what is going on in your home directly from your
computer.