Publishing DHT 11Sensor Readings from ESP32 to Google Sheets using Arduino IDE

Hello there!

As you know (or not) I'm currently writing 4 articles, each about experiments with the ESP32. This one, is the second! All of these experiments (as well as the 2 previous ones I did: this and this one) were held during this awful pandemic. To complete them me and my 2 friends went to several GoogleMeets. Sometimes, my equipment failed sometimes theirs did, and eventually something else did, so I apologise for the poor documentation job. Alright here we go!

These are the 4 experiments I'm writing about:
1. Plotting Real Time Sensor Readings on a web server from an ESP32
2. Publishing Sensor Readings from an ESP32 to Google Sheets
3. Receiving data on an ESP32 from an HTML form on a web server
4. Inserting and Displaying recorded sensor readings from an ESP to a MySQL database
All of them are based on https://randomnerdtutorials.com.

Let's start the second project!

The basic idea of this project is to periodically log sensor measurements into a Google Sheet. The measurements will be taken periodically over the ESP32 using a DHT11 sensor.

Step 1 - Hardware Requirements

Since my BME280 is damaged, me and my friends continued to use the DHT11 for this project.
Therefore he hardware essentials needed were:

1. DHT11 sensor
2. Enough Jumper wires
3. A resistor

Step 2 - Software Requirements

You fill find everything you need to know about Software Requirements on your computer (and everything else) on using the DHT11 on my Trying out the DHT11 post.

Step 3 - Code Create Applet


3.1 The Applet
An Applet is a small application that will run out a specific task we require it to do within or between engines or programs.

Following the guidelines on randomnerdtutorials we first created an account on IFTTT. This is needed to integrate to Google Sheets. It's free and as simple as providing your email address.


Next we go to My Applets and create a new Applet in which we have to determine a trigger  (this) and a response action to it (that). In our case we will use webhooks's "receive a web request" service as our triggering event. Here, we will have to specify our Event Name. As our response action we will fill it with Google Sheets using the "Add row to spreadsheet" service. Here, we will be asked to specify Spreadsheet name, Formatted row, and Drive folder path.

3.2 The code
The sketch/code that we upload to the ESP32 is responsible for making HTTP requests and that way sending sensor readings to Webhooks in form of a json object. Here is the code we used:



You can set how long you want your ESP32 to sleep before it wakes up and makes a new request (sends a new json).




If all of the above is done we can continue and test our Applet. On the Webhooks Service page we go to Documentation that will give us a secret key. Here, we can make an artificial trigger and fill out the json body ourself.



Note: the API key used in the code where I censored it with a red line.

Step 4 - Create Circuit and Upload

As I said in step 2, you can find out how to make your DHT11 function on my previously mentioned article. When everything is done, we can finally upload our code.

Step 5 - Observe and Troubleshoot



Above is a documentation of how the Serial Monitor reports every time a reading event was fired.



Above are the readings (with the weird measurements of our DHT11) that succeeded to appear!


That's it for now. See you!

Comments

Popular posts from this blog

Inserting Data from an ESP32 to a MySQL database using PHP and Arduino IDE

Receiving Data on ESP32 from a HTML form of its Web Server using Arduino IDE

Plotting Real Time Sensor Readings on Web Servers using ESP32 and Arduino IDE