DHT11 Temperature Humidity Logging And Prediction

View project on GitHub

DHT11 Data Logging

Objective

This project results how to log and upload the data into the cloud that results from the DHT11 sensor connected to the Raspberry Pi. Global Warming issue is the increase of Earth’s average surface temperature due to effect of greenhouse gases, such as carbon dioxide emissions from burning fossil fuels or from deforestation, which trap heat that would otherwise escape from Earth. This may cause severe problems and diseases to human beings. As prevention we can collect the data of the temperature variations and humidity at that particular area throughout the year and updating the data to the cloud using the cloud service such as ThinkSpeak and by getting the data from the cloud service, can analyze the data using Data Analytics and predict future conditions of temperature at that particular area. If prediction tells any severe situations of environment at that particular area, safety measures can be taken by people at that area.

Components

  • Raspberry Pi 3 Model B
  • DHT11 Sensor
  • Jumper Wires (Female to Male)
  • Breadboard
  • Ethernet cable
  • SD card (Minimum 8GB class 4 upto 32 GB )
  • SDHC Card Adapter for MicroSD card
  • 10k Resistor
  • USB Power Supply

Softwares & Libraries

  • Raspbian Jessie OS
  • Adafruit python package for DHT11 Sensor
  • Python-dev Library
  • Putty
  • Win32diskimager
  • Thingspeak (cloud service)
  • Wnetwatcher
  • Microsoft Excel

Block Diagram

Block Diagram

Circult Diagram

Circult Diagram 1


Circult Diagram 2

Pre Connection Procedure


Step 1: Prepare Your SD Card

  1. Download the latest version of Raspbian Jessie operating system and unzip the `.img` file.Download it from here. [ CLICK HERE ]
  2. Download and install win32diskimager.Download the software from here. [CLICK HERE]
  3. This Software is used for booting the Raspbian-Jessie OS to the sd card
  4. Take SD card of minimum 8GB class 4, tested up to 32GB and connect to the Windows PC via card reader.
  5. Open Win32DiskImager.exe. If you're running Windows 7 or 8, right click on it and choose "Run as Administrator" instead.
  6. If your SD card isn’t detected automatically, click the dropdown menu and select drive letter of your SD card.
  7. In the image file section of the application,click the folder icon and choose disk image of raspbian jessie os `.img` file.
  8. Click write button and wait for Win32DiskImager to write image file into the SD card.

Step 2: Finding IP address of Raspberry Pi

  1. Enable DHCP on your router.
  2. Connect your Windows PC to the router.
  3. Connect your Raspberry Pi to your PC via Ethernet cable with a proper SD card inserted and Power Supply.
  4. In your Windows PC move your cursor to bottom left of the monitor and right click your mouse. There in the menu choose “control panel”. Go to sub-options of “Network and Internet” and click “View network status and tasks”. In the left side of the menu. Click “Change adapter settings”.
  5. Select both connection of your Wi-Fi and Ethernet (Which is connected to the Raspberry Pi) connection. Press CTRL and select both connections. Right click on any of the two connections and click “Bridge connections” and wait for while until your new bridge connection is identified.
  6. New connection is identified note the type of Network Adapter used.
  7. Download wnetwatcher and unzip the folder inside. Download from here. [ CLICK HERE ]
  8. This software is used for finding the devices connected to the network of your Windows PC along with IP address of the device.
  9. Open the folder unzipped and double click wnetwatcher.exe
  10. This application will list the ip addresses of the devices on same network. Here you can identify your Raspberry Pi ip address.
  11. If you can’t find Press “F9” or Go to “options” and select “Advanced options”.Choose your wireless network adapter.
  12. Network Adapter
  13. Start scan again. Note the ip address of Raspberry Pi.

Step 3: Assigning static IP address ( Instead of step 2 )

  1. Connect the pi with your laptop using Ethernet cable. Now, on your pc open command prompt by typing ‘cmd’ in start menu. Write ‘ipconfig’ to show the list of connections. Note down the ipv4 address under Ethernet. It should be something like this `192.169.254.12`
  2. Remove the power cable. Remove SD card and insert in your laptop. Open the drive of your SD card. Find and open ‘cmdline.txt’ using notepad++.
  3. At the end of the first line type ip=`192.169.254.X` where x is any number from 0 to 255 and others are the same as the ipv4 address you noted.
  4. This one line of text should be followed by one blank line. Make sure there are only 2 lines. This is an important step. If your pi doesn’t get connected in next steps for some reason check this step first. Save the ‘cmdline.txt’ file. Remove your SD card and insert it in pi.

Step 4: Configuring putty

  1. Connect pi to your laptop. Start an application putty. It can be downloaded from here. [ CLICK HERE ]
  2. In the host name, write the ip address noted in step 2 or assigned in step 3. Don’t change port number.
  3. Click ‘Open’. A terminal will open and a message will be displayed. Click on ‘Yes’. If there is an error message ‘Connection Refused’, wait for 1 minute more and try again. If there is an error message ‘No route to host’, the problem is with your ip address. Check it again.
  4. After connecting to the terminal, it will ask for login name. Enter ‘pi’ as login id and ‘raspberry’ as your password. This is set by default.
  5. You will get access to your pi.

Step 5: Configuring GPIO and Installing Adafruit library

  1. To program the GPIO ports in Python, we need to install a library called Rpi.GPIO.
  2. This install process can be done through commands in putty.
  3.         sudo apt-get update
            sudo apt-get install python-dev  
            sudo apt-get install python-rpi.gpio  
    
  4. Next the process for installing the adafruit python DHT library from github.
  5. This is link of the library in github. (https://github.com/adafruit/Adafruit_Python_DHT)
  6. This is the link for cloning into your pc.(https://github.com/adafruit/Adafruit_Python_DHT.git)
  7. Commands for installing adafruit DHT11 python library.
  8.     sudo apt-get update
        sudo apt-get install git  
        git clone https://github.com/adafruit/Adafruit_Python_DHT.git
        cd Adafruit-Raspberry-Pi-Python-Code
        sudo python setup.py install
    

Step 6: Creating a channel in Thingspeak cloud service

  1. Go to thingspeak.com and create a account.
  2. Create a new channel and fill the requirements and save it.
  3. Thingspeak
  4. Now go to option called API keys of that particular channels. And Note the Write Key of that particular channel.

Predicting the data

Microsoft Excel is the simple data analytics tool for analyzing the data and predicting the data using FORECAST function. FORECAST is time series forecasting functions can be used to predict future values based on historical data. These functions use advanced machine learning algorithms.
Applies To: Excel 2016, Excel 2013, Excel 2010, Excel 2007, Excel 2016 for Mac, Excel for Mac 2011, Excel Online, Excel for iPad, Excel for iPhone, Excel for Android tablets, Excel Starter, Excel Mobile, Excel for Android phones, Less. NOTE: In Excel 2016, this function has been replaced with FORECAST.LINEAR as part of the new Forecasting functions. It's still available for backward compatibility, but consider using the new function in Excel 2016.

Description:

Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value. The known values are existing x-values and y-values, and the new value is predicted by using linear regression. You can use this function to predict future sales, inventory requirements, or consumer trends.

Syntax:

FORECAST(x, known_y's, known_x's)

The FORECAST function syntax has the following arguments:

  • X Required. The data point for which you want to predict a value.
  • Known_y's Required. The dependent array or range of data.
  • Known_x's Required. The independent array or range of data.


------------------------Predict to Get Benefit----------------------------



-Powered By IoT Alliance ,SRM University,KTR Campus,Chennai.