Monday, February 1, 2016

Temperature and Humidity Sensing using Raspberry Pi

This experiment shows how easy it is to have our own temperature and Humidity monitoring device using DHT11 Sensor and Pi. Here in this experiment I used the google spreadsheet to have live data of temperature and Humidity.

Things Required:

  1. Raspberry Pi Kit
  2. DHT11 Sensor
  3. 10 K ohms Resistor
  4. Bread Board
  5. Jumper Wires


DHT11 Sensor: 


             The DHT11 is a basic, ultralow-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed).

DHT11 Sensor

DHT11 Pin Description:

    Pin                 Name                Description

      1                   VDD                 Power supply 3-5.5 V DC
      2                   DATA               Serial data output
      3                   NC                    Not connected
      4                   GND                 Ground 

Wiring Connections:




Connect the Sensor to the Pi as shown below:




  1. Connect pin1 of DHT11 to VCC (3.3V), pin1 of Pi.
  2. Connect pin2, the Digital output pin of sensor to GPIO4, input pin of Pi (Pin7).
  3. Connect pin 4 of DHT to GND (pin39 of Pi).
  4. Connect resistor across DHT11 output(pin2 of DHT11) and VCC(pin1 of Pi).

Code:


Programs for the experiment are available at:

Experiment 1:

To read the temperature and humidity using DHT11.

Simply run the program AdafruitDHT.py program

Inorder to run this from the command prompt we need to give inputs from the command line arguments. First argument is sensor model number(11) and second GPIO pin number(4), this is not the actual pin number.

1. In the terminal, navigate to the program location.
2. Run sudo ./AdafruitDHT.py 11 4

Output:




Experiment 2:


To update a google spreedsheet live with the temperature and humidity data.

This experiment requires groundwork such as setting up google developer account, giving google drive access, getting service account for the google drive.
The process is well explained at https://learn.adafruit.com/downloads/pdf/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging.pdf

After all the setup run the google_spreadsheet.py

sudo ./google_spreedsheet.py

you can visualize the output on the terminal and also you can view in the spreedsheet.
Below are the demos of the results of the reading updated in terminal and spreedsheet.

You can view the output sheet at https://docs.google.com/spreadsheets/d/13vqXOYCvRSJF-jHkdAd0JfaP3wr4pGCxg-nhBk3LmWU/edit?usp=sharing


Output Demo:





No comments:

Post a Comment