Home (Room) Temprature and Humidity Monitor With Web Based Chart - Raspberry Pi

Introduction: Home (Room) Temprature and Humidity Monitor With Web Based Chart - Raspberry Pi

About: Systems / Virtualization with nearly four years’ hands-on technical experience and exposure in multiple platforms such as Windows and Linux. Proven ability to design, develop and implement network or systems...

Simple way to monitor your, Home ,room, garage small factory or any other places Temperature and Humidity from anywhere in the world via internet.

It very fun and very simple.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: The Concept

  • The Raspberry Pi will get the Home(Room) Temperature and the Humidity from the DHT11 sensor.
  • All the data will be POST to the web server via JSON RAW data method.
  • Data will store in a data base and publish to a chart.
  • We can monitor the Temperature and Humidity with the chart.

Step 2: Required Items and Pre Requests

Step 3: Connecting the Device

  • Make sure the power is switched off.
  • Connect the VCC to the +3 V.
  • Connect the DATA to the GPIO 4.
  • Connect the GND to the GND.
  • Power on the Raspberry Pi

Step 4: Setup the Python File in the Raspberry Pi

Connect to the Raspberry Pi via SSH or connect directly. select a proper folder or location to create the file.

example :Desktop

nano dht11.py

And Download the attached dht11.py file and copy the source to your file in the Raspberry Pi.

All the functions and methods i have explained in the code with comments.

My web server IP address is "104.236.91.122" and the web service PHP file is "/rpi/rpi.php"

Attachments

Step 5: Setup the PHP Web Service

Download the rpi.rar file and extract the files.

Open phpMyadmin and create a new database example : "rpi_themo".

Download the "pi.sql" file and import to your new database. (i have inserted few sample data)

Change the data base credentials in the following files

  1. \rpi\db-con.php
  2. \rpi\temp\assets\php\getTemp.php

Step 6: Testing the Device

Connect to the Raspberry Pi and go to your dht11.py file location.

run the below comand

sudo python dht11.py

you will get something like this :

New record created successfully

if you get something like this :

no_data

don't worry this has a chance to lose data. This is because Raspberry Pi is not running at a real-time system, the delay in the program is not accurate enough, and sometimes that leads to a failure of transmission.we can run the program for several times can pick the correct result.

Step 7: Automating This Process

As you know in Linux we can run any script using cron jobs hence i have added a record in the cron jobs for run the script every minute. Use the following script for add the script.

crontab -e

add the following line in the bottom

*/1 * * * * sudo python /home/pi/Desktop/dht11/dht11.py

save and exit, for make sure the record has added. type the following comand

crontab -l

then you can see the record.

Step 8: The Chart

Now all done. open a web browser and go to the web server.

Example : http:// ip address or webs address>/rpi/temp/

then you can able to view a nice chart with the data.

Please free to comment and ask questions i would happy to help :).

i am working to add more sensors and get a full dash board in the future.

Raspberry Pi Contest

Participated in the
Raspberry Pi Contest

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    23 Discussions

    1
    Samrid
    Samrid

    3 years ago

    Hello I tried your tutorials but when i try to run dht11.py then a error comes:
    How to solve this error?

    sudo python dht11.py

    ERR_RANGE

    0
    arshadzackeriya
    arshadzackeriya

    Reply 3 years ago

    Hi guys sorry for the late reply.

    That means your sensor is not detecting the GPIO ports.

    Make sure your GPIO numbers are same as to the PORTS assigned in the code.

    Thanks

    0
    linhuetvnu
    linhuetvnu

    Reply 3 days ago

    Hi, i have this problem too. I think your codes in file dht11.py don't correct. Please help me :((((

    0
    KokY2
    KokY2

    Reply 2 years ago

    Hi, i have this problem too. And i'm sure the GPIO number is correct as the port assigned in the code. Can you give some suggestion to solve ERR_RANGE?

    0
    mimiya
    mimiya

    Reply 2 years ago

    i have the same problem ..please if you find the solution i will be thankful if you could help me

    0
    JuriB
    JuriB

    Reply 2 years ago

    I got the same error.. i've double check i'm using gpio4

    did you solve?

    thanks!

    Juri

    0
    HaP18
    HaP18

    Reply 3 years ago

    Can u do that? I have too ..... HELP HELP HELP

    0
    tuann2
    tuann2

    Reply 3 years ago

    i have too. did you solved it ?

    0
    kkagnets
    kkagnets

    11 months ago on Step 8

    it would have been nice to put some comments in your code

    0
    林煊林
    林煊林

    3 years ago

    Hello u have done a nice work:)

    I followed your guideline but at the end when I python dht11.py, I got some error message as below:

    Traceback (most recent call last):

    File "dht11.py", line 81, in <module>

    sample_1 = { "nodata" : no_data }

    NameError: name 'no_data' is not defined

    what did it exactly happend on this?

    0
    HaP18
    HaP18

    3 years ago

    Line $handle = fopen('php://input','r'); in rpi.php. What I must change that?

    0
    HyperV2012
    HyperV2012

    4 years ago on Introduction

    Awesome project.. Well done..
    Quick question can we change between Celsius and Fahrenheit?

    0
    arshadzackeriya
    arshadzackeriya

    Reply 4 years ago on Introduction

    yes we can, simple formula to convert the Celcius to Fahrenheit.

    Then we can use a Drop down in the Main page to view the Fahrenheit version.

    0
    PraveenN3
    PraveenN3

    4 years ago

    Good work buddy. Well done

    0
    ShanakaS
    ShanakaS

    4 years ago

    Good work bro keep it up