Introduction: HOME MONITORING USING ARDUINO AND IOT

About: ARDUINO AND RASPBERRY PI

HI, This is a simple arduino based home monitoring project. here we use some sensors that can monitor the conditions of the home and upload it to cloud. the internet of platform we use here is dweet.io and freeboard.io

both are free to use, hence you can try this at home and also the sensors we use are cheaper and works well.

components required:

  1. arduino uno or mega
  2. ethernet shield
  3. ethernet cable
  4. working net connection
  5. laptop
  6. rain sensor
  7. DHT11
  8. ultrasonic sensor
  9. connecting wires (few)

Step 1:

STEP 2:

now we can create account in the cloud platform. follow the steps given below

  1. go to www.freeboard.io
  2. click on startup. create an account in that website
  3. after completing signup in freeboard.io now go to www.dweet.io
  4. scroll down the page till you see topic dweeting, below that you will see the link"https://dweet.io/dweet/for/my-thing-name?hello=wor...
  5. here you can change the my-thing-name to your required name, this will act like your profile name. make sure it is smaller and remember-able. after changing the thingname go to that URL
  6. for example the thingname i keep is tutorial yo need to type like "https://dweet.io/dweet/for/tutorial?hello=world"
  7. next the word hello can be replaced with some other name you want,
  8. in this tutorial we are going to show the values of temperature, humidity, waterlevel in tank,door condition, and the outdoor condition, hence in the place of hello we are going to replace with temperature, humidity, waterlevel,doorcondition,outdoorcondition. make sure everything has = symbol and should be connected by & symbol
  9. now our cloud platform is ready, in the next step we can discuss about the arduino connections

Step 2: Arduino Connections

arduino connections:

assemble all the components required arduino, ethernet shield, rain sensor,hall sensor, DHT11 sensor, breadboard

  • mount the ethernet shield correctly on your arduino shield, connect it to the lan if you dont have lan in your home its okay, we can connect it to the laptop ethernet, make sure you bridge the lan connection with the ethernet so that only arduino can get internet connection.
  • connect the 5v and ground to the breadboard
  • now first we take the DHT11 sensor

connect the 5v to 5v connection and ground to gnd correctly, the second pin in that sensor is the signal connect it to

pin no 2, if you already have dht11 library it will work, if you dont have the library, download it in the manage library search for dht library and download it,

next we connect the ultrasonic sensor

connect the 5v to 5v ground to gnd, trig pin to arduino pin 7 and echo pin to arduino pin 5. include the ultrasonic library to your compiler

rain sensor

asusual 5v and ground are connected . here we are going to use the digital pin so connect the digital pin to arduino pin 4

hall sensor

connect the 5v and ground, connect the third pin to the arduino pin 8. in case if you dont know the pinouts of hall sensor see the above image

now your connections are over lets go to coding in next step

Step 3: Arduino Coding

#include <SPI.h>
#include <Ethernet.h>

#include <SimpleDHT.h >

#include <Ultrasonic.h>

Ultrasonic Ultrasonic(7, 5);

int pinDHT11 = 2;

byte temperature = 0;

byte humidity = 0;

int ultra1;

int hallstate=0;

int hallpin=8;

SimpleDHT11 dht11;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, xxx, xx, xx);

EthernetClient client; char server[] = "www.dweet.io";

unsigned long lastConnectionTime = 0;

const unsigned long postingInterval = 10L * 1000L;

void setup() {

Serial.begin(9600);

Serial.println("--- Start ---");

delay(1000);

Ethernet.begin(mac, ip);

Serial.print("My IP address: ");

Serial.println(Ethernet.localIP());

pinMode(hallpin,INPUT);

}

void loop() {

if (client.available()) {

char c = client.read();

Serial.write(c);

}

if (millis() - lastConnectionTime > postingInterval) {

httpRequest();

}

dht11.read(pinDHT11, &temperature, &humidity, NULL);

}

void httpRequest() {

client.stop();

if (client.connect(server, 80))

{

Serial.println("connected");

String s = "POST /dweet/for/home?temperature=";

s.concat((int)temperature);

s.concat("&humidity=");

s.concat((int)humidity);

s.concat("&watertank=");

s.concat(Ultrasonic.distanceRead());

s.concat("&room=");

s.concat(hallsen());

s.concat("&outdoor=");

s.concat(rainsen());

Serial.println(s);

client.println(s);

client.println("Host: https://www.dweet.io");

client.println("Connection: close");

client.println();

lastConnectionTime = millis();

}

else

{

Serial.println("connection failed");

}

}

String hallsen()

{

hallstate=digitalRead(hallpin);

if(hallstate==1){

return ("dooropen");

}

else

{

return ("doorclose");

}

}

String rainsen()

{ int rain=digitalRead(4); //rain sensor

if (rain==0){

return ("raining");

}

if (rain==1) {

return ("clear");

}

}

Step 4: Final Step

the code should be uploaded to the arduino

note that the ipaddress above should be changed to your ip address

now we are going to create the panels in freeboard.io

login to the freeboard.io

in the freeboard.io after login create a new freeboard enter any name you want no retrictions here

enter in to your freeboard

in the data sources, click on add in select a type drop box select "dweet.io in the name enter any name you need thingname should be "home" click on save

now in the left side of the webpage you can see add pane button click on it, a new pane will be created

you can see the plus button click on it select type as gauge title can be anything

in the value click on the +datasource you can see your data source click on the datasource you created, you will see the thing names you created click anything ex temperature, and click ok

like this create panes for humidity, water level, create strings for the door condition and outdoor conditions. upload your code now , the datas will change real time as you see in the video

if you have any doubt or errors comment here

Sensors Contest 2017

Participated in the
Sensors Contest 2017

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017