banner



How To Send Sensor Data Using Raspi To Website

In some IoT projects data is generated continuously. One manner to permanently store them is by saving the information in a local database, however there are other alternatives also available. One of these alternatives is ThingSpeak. Here y'all tin can create a complimentary account for small applications and transfer your information very easily. And that's exactly what this tutorial is virtually on How to send sensor data to Thingspeak using Raspberry Pi.

Things Needed

For building this project yous need beneath components.

  • Raspberry Pi
  • DHT11 Sensor
  • Jumper Cables

How it works?

The working of this project is simple and piece of cake. DHT11 sensor will collect the temperature and humidity information and send information technology to Raspberry Pi. Afterward Raspberry Pi will send it to Thingspeak channel.

how to send sensor data to Thingspeak using Raspberry Pi

Setting Up Thingspeak Business relationship

Before starting, you need a ThingSpeak account. Create an account by clicking on this link hither. Afterwards creating the account login and click on New Channel to create a channel.

How to send sensor data to Thingspeak using Raspberry Pi

We will define the channels by entering the a proper proper noun, description, and up to 8 fields tin be used to name the parameter. For the Field 1 and Field 2 nosotros have named Temperature and humidity. These field values ​​that you fix can exist modified later on. These values will be in Degree Centigrade and Relative Humidity in %. Once you update the name, click on Salve.

How to send sensor data to Thingspeak using Raspberry Pi

One time you take saved the channel, y'all will be automatically redirected to the "Private View" tab. Here the mapped fields are shown as a diagram. You will find the "Channel ID" (we will demand it later). Below Y'all will also run into API Keys option.

How to send sensor data to Thingspeak using Raspberry Pi

Later, click on the "API Keys" tab. The two values ​​of "Write API key" and "Read API key" are as necessary for us to write or recollect data. Copy these keys and keep information technology condom as we need to put it in the code.

How to send sensor data to Thingspeak using Raspberry Pi

Connexion Diagram

This is how you accept to make the connectedness with the sensor to the Pi board. Data or signal pin of DHT11 sensor is connected with GPIO four with Raspberry Pi.

How to send sensor data to Thingspeak using Raspberry Pi

Installing Required Libraries

Before installing the libraries we need to update the packages installed in Raspberry Pi. For installing the bones updates run these commands in a terminal window on your Raspberry Pi

                  sudo apt                                    -                                    become                                    update sudo apt                                    -                                    get                                    install build                                    -                                    essential python                                    -                                    dev python                                    -                                    openssl git                

Now we install the library to read the DHT11  or DHT22 sensors. Below library will work for both the sensor types.

                  git clone https                  :                  //github.com/adafruit/Adafruit_Python_DHT.git && cd                                    Adafruit_Python_DHT                

We have to run the beneath command to install Python

                  sudo python setup.py install                

Installing Raspberry Pi Thingspeak Library

In lodge to use the service, it is possible to only send the data via "Mail service" or retrieve it via "Get". The functions are available in almost whatsoever programming language. If y'all don't have plenty feel or but don't feel like writing information technology, you can also use the ThingSpeak library. For this we just install information technology using below control

sudo pip install thingspeak

The python script will read the DHT11 temperature and humidity every 15 seconds and transport information technology to our aqueduct.

sudo nano thingspeak_DHT11.py

Inside this new file nosotros volition re-create this python code

Now Update the code with Channel ID and write key values from Thingspeak portal. Now save information technology and your code is ready to run.

channel_id = 1391845 # put here the ID of the channel yous created before write_key = 'TNXXJJII892UHJ1C' # update the "WRITE KEY"

Code

If y'all are using a unlike GPIO for the sensor apart from GPIO4 then you have to make changes in pin variable in the lawmaking. For DHT22 sensor, the code needs to exist adjusted a bit more.

You tin download the code from the below link and excerpt it in the root of Raspberry pi directory (/home/pi).

Edifice and Testing

How To Send Sensor Data Using Raspi To Website,

Source: https://www.iotstarters.com/how-to-send-sensor-data-to-thingspeak-using-raspberry-pi/

Posted by: bakerbeforning1959.blogspot.com

0 Response to "How To Send Sensor Data Using Raspi To Website"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel