members
Basics: Project 072l ESP32 Development board - How to publish sensor readings to Google Sheets
of Acoptex.com in ESP8266 ESP-32
Basics: Project 072l
Project name: ESP32 Development board - How to publish sensor readings to Google Sheets
Tags: Arduino, ESP32 Dev Module, ESP32 development board, ESP32 Development board with WiFi and Bluetooth, ESP32-DevKitC V4 development board, ESP-WROOM-32 module with ESP32‑D0WDQ6 chip, Espressif Systems, ESP32-based development board, ESP32 modules, ESP32-WROOM-32, ESP32-WROOM-32U, ESP32-WROOM-32D, ESP32-SOLO-1, USB-UART bridge, IOT, ESP-WROOM-32 Dev Module, ESP32 DEVKITV1, Installing the ESP32 Board in Arduino IDE, Uploading sketch, DHT11, DHT21, DHT22 module,
Attachments: sketch1, library1, library2
In this project, you need these parts :
1. ESP32 development board with WiFi and Bluetooth and USB A / micro USB B cable 1 pc
2.Arduino IDE ( you can download it from here )
3.Jumper cables F-M, F-F, M-M
4. Breadboard 1 pc
5. Resistor 1 pc (10 KOhm)
6. DHT11 21 22 Humidity and temperature module 1pc
General
We will learn how to publish sensor readings to Google Sheets using ESP32 development board. In this project we publish temperature, humidity readings with the DHT11/21/22 module to a Google Sheets spreadsheet every 30 minutes using IFTTT.
There are a lot of different development boards made. You can find more information about them here.
Steps:
- The ESP32 development board connects to your Wi-Fi network;
- The DHT11/21/22 module takes the temperature, humidity readings;
- Your ESP32 development board communicates with the IFTTT Webhooks service that publishes the readings to a spreadsheet on Google Sheets that is saved in your Google Drive’s folder;
- After publishing the readings, the ESP32 development board goes into deep sleep mode for 10 minutes;
- After 10 minutes the ESP32 development board wakes up;
- After waking up, the ESP32 development board connects to Wi-Fi, and the process repeats.
Understanding the DHT 11 21 22 module
You can read more about it here.
Understanding the ESP32 Development board with WiFi and Bluetooth
We will discuss here an Espressif Systems products. Our development board is using ESP-WROOM-32 module from Espressif Systems.
Espressif offers a wide range of fully-certified Wi-Fi & BT modules powered by their own advanced SoCs.
1. Dual-core Modules with Wi-Fi & Dual-mode Bluetooth
Features
- Two independently-controlled CPU cores with adjustable clock frequency, ranging from 80 MHz to 240 MHz
- +19.5 dBm output at the antenna ensures a good physical range
- Classic Bluetooth for legacy connections, also supporting L2CAP, SDP, GAP, SMP, AVDTP, AVCTP, A2DP (SNK) and AVRCP (CT)
- Support for Bluetooth Low Energy (BLE) profiles including L2CAP, GAP, GATT, SMP, and GATT-based profiles like BluFi, SPP-like, etc
- Bluetooth Low Energy (BLE) connects to smart phones, broadcasting low-energy beacons for easy detection
- Sleep current is less than 5 μA, making it suitable for battery-powered and wearable-electronics applications
- Integrates 4 MB flash
- Peripherals include capacitive touch sensors, Hall sensor, low-noise sense amplifiers, SD card interface, Ethernet, high-speed SPI, UART, I2S and I2C
- Fully certified with integrated antenna and software stacks
2. Single-core Modules with Wi-Fi & Dual-mode Bluetooth
Features
- High-performance 160 MHz single-core CPU
- +19.5 dBm output at the antenna ensures a good physical range
- Classic Bluetooth for legacy connections, also supporting L2CAP, SDP, GAP, SMP, AVDTP, AVCTP, A2DP (SNK) and AVRCP (CT)
- Support for Bluetooth Low Energy (BLE) profiles including L2CAP, GAP, GATT, SMP, and GATT-based profiles like BluFi, SPP-like, etc
- Bluetooth Low Energy (BLE) connects to smart phones, broadcasting low-energy beacons for easy detection
- Sleep current is less than 5 μA, making it suitable for battery-powered and wearable-electronics applications
- Peripherals include capacitive touch sensors, Hall sensor, low-noise sense amplifiers, SD card interface, Ethernet, high-speed SPI, UART, I2S and I2C
- Fully certified with integrated antenna and software stacks
3. Single-core Modules with 802.11b/g/n 2.4 GHz Wi-Fi
Features
- High-performance 160 MHz single-core CPU
- +19.5 dBm output at the antenna ensures a good physical range
- Sleep current is less than 20 μA, making it suitable for battery-powered and wearable-electronics applications
- Peripherals include UART, GPIO, I2C, I2S, SDIO, PWM, ADC and SPI
- Fully certified with integrated antenna and software stacks
There are different development Boards made by Espressif Systems and other manufacturers. We will publish some information about Espressif Systems boards but you can also find out more information about other development boards here.
1. 2.4 GHz Wi-Fi & BT/BLE Development Boards
Features
- PC connectivity: USB
- Power supply options: USB (by default), or 5V/GND header pins, or 3V3/GND header pins
- SDK: ESP-IDF source code and example applications
2. 2.4 GHz Wi-Fi Development Boards
Features
- PC connectivity: USB
- SDK: ESP8266 SDK source code and example applications
3. 2.4 GHz Wi-Fi + BT/BLE + Sensor Development Boards
Features
- PC connectivity: USB
- SDK: ESP-IOT-SOLUTION source code and example applications
You can find more information (datasheets, schematics, pins descriptions, functional desgn descriptions) about each board by pressing Getting started link close to each board here.
ESP32 chip
ESP32 is a series of low cost, low power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. The ESP32 series employs a Tensilica Xtensa LX6 microprocessor in both dual-core and single-core variations and includes in-built antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules. ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese company, and is manufactured by TSMC using their 40 nm process. It is a successor to the ESP8266 microcontroller.
ESP32 can perform as a complete standalone system or as a slave device to a host MCU, reducing communication stack overhead on the main application processor. ESP32 can interface with other systems to provide Wi-Fi and Bluetooth functionality through its SPI / SDIO or I2C / UART interfaces.
ESP32 is highly-integrated with in-built antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules. ESP32 adds priceless functionality and versatility to your applications with minimal Printed Circuit Board (PCB) requirements.
ESP32 is capable of functioning reliably in industrial environments, with an operating temperature ranging from –40°C to +125°C. Powered by advanced calibration circuitries, ESP32 can dynamically remove external circuit imperfections and adapt to changes in external conditions.
Engineered for mobile devices, wearable electronics and IoT applications, ESP32 achieves ultra-low power consumption with a combination of several types of proprietary software. ESP32 also includes state-of-the-art features, such as fine-grained clock gating, various power modes and dynamic power scaling.
Functional Block Diagram:

Features of the ESP32 include the following:
Processors:
- CPU: Xtensa dual-core (or single-core) 32-bit LX6 microprocessor, operating at 160 or 240 MHz and performing at up to 600 DMIPS
- Ultra low power (ULP) co-processor
- Memory: 520 KiB SRAM
Wireless connectivity:
- Wi-Fi: 802.11 b/g/n
- Bluetooth: v4.2 BR/EDR and BLE
Peripheral interfaces:
- 12-bit SAR ADC up to 18 channels
- 2 × 8-bit DACs
- 10 × touch sensors (capacitive sensing GPIOs)
- Temperature sensor
- 4 × SPI
- 2 × I²S interfaces
- 2 × I²C interfaces
- 3 × UART
- SD/SDIO/CE-ATA/MMC/eMMC host controller
- SDIO/SPI slave controller
- Ethernet MAC interface with dedicated DMA and IEEE 1588 Precision Time Protocol support
- CAN bus 2.0
- Infrared remote controller (TX/RX, up to 8 channels)
- Motor PWM
- LED PWM (up to 16 channels)
- Hall effect sensor
- Ultra low power analog pre-amplifier
Security:
- IEEE 802.11 standard security features all supported, including WFA, WPA/WPA2 and WAPI
- Secure boot
- Flash encryption
- 1024-bit OTP, up to 768-bit for customers
- Cryptographic hardware acceleration: AES, SHA-2, RSA, elliptic curve cryptography (ECC), random number generator (RNG)
Power management:
- Internal low-dropout regulator
- Individual power domain for RTC
- 5uA deep sleep current
- Wake up from GPIO interrupt, timer, ADC measurements, capacitive touch sensor interrupt
You can find ESP32 chip datasheet here, hardware design here, technical reference manual here.
Signals and connections of the DHT 11 21 22 module
There are two different versions of the DHT11 you might come across. One type has four pins, and the other type has three pins and is mounted to a small PCB. The PCB mounted version is nice because it includes a surface mounted 10K Ohm pull up resistor for the signal line. Here are the pin outs for both versions:
Signals and connections of the ESP32 Development board with WiFi and Bluetooth
You can find more information (datasheets, schematics, pins descriptions, functional desgn descriptions) about each board (made by Espresiff Systems) by pressing Getting started link close to each board here.
Let's check our development board - ESP32 DEVKITV1 with ESP-WROOM-32 module from Espressif Systems:
Pinout diagram for the ESP Wroom 32 breakout:
ESP32-WROOM-32 - ESP32-WROOM-32 module soldered to the development board. Optionally ESP32-WROOM-32D, ESP32-WROOM-32U or ESP32-SOLO-1 module may be soldered instead of the ESP32-WROOM-32.
USB-UART Bridge - A single chip USB-UART bridge provides up to 3 Mbps transfers rates.
BOOT button - Download button: holding down the Boot button and pressing the EN button initiates the firmware download mode. Then user can download firmware through the serial port.
EN button - Reset button: pressing this button resets the system.
Micro USB Port - USB interface. It functions as the power supply for the board and the communication interface between PC and the ESP module.
TX0, TX2 - transmit pin. GPIO pin
RX0, RX2 - receive pin. GPIO pin
3V3 (or 3V or 3.3V) - power supply pin (3-3.6V).
GND - ground pin.
EN - Chip enable. Keep it on high (3.3V) for normal operation.
Vin - External power supply 5VDC.
Wiring
DHT sensor requires 5V to operate properly, so make sure you use the Vin pin from your ESP32 that outputs 5V.
Step by Step instruction
The ESP32 is currently being integrated with the Arduino IDE like it was done for the ESP8266. There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language.
- Download and install the latest Arduino IDE Windows Installer from arduino.cc
- Download and install Git and Git GUI from git-scm.com
- Search for Git GUI, right-click the icon and select “Run as administrator“
- Select the Clone Existing Repository option.
- Select source and destination. Source Location: https://github.com/espressif/arduino-esp32.git
- Target Directory:C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32
- Do not create the espressif/esp32 folders, because they will be created automatically.
- Click Clone to start cloning the repository.Wait a few seconds while the repository is being cloned.
- Open the folder: C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools
- Right-click the get.exe file and select “Run as administrator“.
- You will see that necessary files will be downloaded and upzipped. It will take some time.
- When get.exe finishes, you should see the following files in the directory.
- Do wiring.
- Plug the ESP32 development board to your PC and wait for the drivers to install (or install manually any that might be required).
- Open Arduino IDE.
- Open Boards manager. Go to Tools -> Board -> Boards Manager… (in our case it’s the DOIT ESP32 DEVKIT V1)
- Select COM port that the board is attached to (if you don’t see the COM Port in your Arduino IDE, you need to install the ESP32 CP210x USB to UART Bridge VCP Drivers)
- You need to create your IFTTT account. It's free of charge.
Go the official site: ifttt.com and enter your email to get started.Go to the ifttt.com website, enter your email address and click on get started button.
- Enter password and click on Sign up button.
- You need to create a new applet. Go to My Applets and create a new applet by clicking the New Applet button.
- Click on the this word that is in a blue color.
- Search for the Webhooks service and select the Webhooks icon.
- Choose the Receive a web request trigger.
- Give a name to the event, for example DHTreadings and click on Create trigger button.
- Click on that word to proceed ahead.
- Search for the Google Sheets service and select the Google Sheets icon.
- Click on Connect button to connect with the Google Sheets service.
- You will need to sign in this Google Gmail/or Sign up if you do not have avy account there and Allow IFTTT to access it.
- Click on Add a row to spreadsheet action.
- Complete the action fields. Give the spreadsheet a name, leave Formatted row field as default, and then, choose a Google Drive folder path. If you leave this field empty, IFTTT will create a folder named IFTTT in your Google Drive folder to save the spreadsheet. Click on Create action button.
- Your applet will be created after you click on Finish button.
- We need to test applet. Go to the Webhooks Service page and click on Documentation button.
- A page will appear. This page shows your unique API key and IFTTT URL resource (save them as we will need them later, for example we had bsA-7n0Ms0FOl-mlOMqIx_ and /trigger/DHTreadings/with/key/bsA-7n0Ms0FOl-mlOMqIx_ . You must not share your unique API key with anyone. Fill in To trigger an Event section as shown below – it is highlighted with red rectangles. Click on Test it button.
- The event should be successfully triggered and you will get a green message as shown below - Event has been triggered.
- Go to your Google Drive. The IFTTT service created a folder named IFTTT with DHTreadings spreadsheet inside.
- Open the spreadsheet and you will see the values you filled in previously to test the applet.
- Modify sketch1 with your SSID and password data. Replace with your unique IFTTT URL resource: const char* resource = "REPLACE_WITH_YOUR_IFTTT_URL_RESOURCE"; For example we had: const char* resource = "/trigger/DHTreadings/with/key/bsA-7n0Ms0FOl-mlOMqIx_";
- Compile and upload the sketch1 to your ESP32 development board. If everything went as expected, you should see a “Done uploading” message. (You need to hold the ESP32 on-board Boot button while uploading).
- Open the Serial Monitor at a baud rate of 115200.
- Press the ESP32 on-board EN button to reboot it.
- Every 10 minutes, the ESP32 development board wakes up to take sensor readings and publishes the readings in a spreadsheet on Google Sheets.
Code
The sleep time is set in the TIME_TO_SLEEP variable in seconds: uint64_t TIME_TO_SLEEP = 600;
If you set a very short period, you may exceed the limit of requests imposed the IFTTT service.
The DHT sensor readings are sent using the jsonObject variable as shown in the following line (highlighted in bold):
String jsonObject = String("{\"value1\":\"") + h + "\",\"value2\":\"" + t + "\",\"value3\":\"" + f + "\"}";
If you want to send other sensor readings, you just need to replace the DHT readings in bold with the readings for the sensor you are using.
Summary
We have learnt how to publish sensor readings to Google Sheets using ESP32 development board. In this project we publish temperature, humidity readings with the DHT11/21/22 module to a Google Sheets spreadsheet every 30 minutes using IFTTT.
Libraries
- All libraries attached on the begining of this project description.
- Adafruit_Sensor library included.Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
- DHT-sensor library included. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. OR You can install it in Arduino IDE too: select Sketch-> Include library->Manage your libraries->type DHT in Filter your search line and you will see DHT sensor library by Adafruit->More info->select version->install. If it will be problem with compilation - remove 2 files from the library - DHT_U.cpp and DHT_U.h.
Sketch
- See attachments on the begining of this project
Other projects of Acoptex.com










Viewed: 5145 times