Tutorials

Interfacing SHT31 with ESP32 TTGO LoRa32 and display on its OLED display

Learn how to interface SHT31 temperature and humidity sensor with ESP32 TTGO LoRa32 and display the sensor data on its own OLED display

Overview:

In this quick tutorial learn how to connect SHT31 temperature and humidity sensor with ESP32 TTGO LoRa32 SX1276 OLED display board to read the temperature and humidity values from the sensor and display over the built in OLED display.

SHT31 Temperature and Humidity sensor

SHT31 sensor is the standard one among its SHT3x family where it can measure temperature and relative humidity accurately and precisely than its predecessor SHT2x series. SHT3x family also has a base SHT30 and High end model SHT35 which you can choose according to your requirement.

SHT3x is packed with a completely new CMO Sens Chip, which will increase reliability along with improved accuracy in measuring.

The SHT3x offers a range of new features when compared with SHT2x and other sensors, such as enhanced signal processing, two distinctive and user-selectable I2C addresses(0x44 or 0x45), an alert mode with programmable humidity and temperature limits, and communication speeds of up to 1 MHz.

SHT31 Technical Specifications:

  • Communication:   I2C
  • Supply voltage range: 2.15 to 5.5 V
  • Temperature range: -40 to +125°C (-40 to +257°F)
  • Temperature accuracy:±0.3 @-40-90 °C
  • Humidity range: 0 – 100% RH
  • Humidity accuracy: ±2 @0-100% RH
  • RH response time: 8 sec (tau63%)
  • Energy consumption: 4.8µW (at 2.4 V, low repeatability, 1 measurement/s)

SHT31 Pinout diagram:

Below is the pinout diagram of SHT31 Temperature and Humidity Sensor.

SHT31 Temperature and Humidity Sensor pinout diagram

From the above pinout diagram, There you can see 4 pins two pins for Voltage input and Ground and another two pins for I2C connection SCL and SDA.

ESP32 TTGO LoRa32 module pinout diagram

This board has the ESP32 chip with Built in WiFi and Bluetooth same as ESP32. It has few other features like an in built OLED display and SX1276 LoRa module for long range transmissions which we can learn in our other articles.

esp32 ttgo lora module pinout with scl and sda circuitschools

As you can see from the above pin diagram the board has built in OLED display and few types of GPIO and analog pins which we discussed in our previous article.

Interfacing SHT31 Temperature and Humidity sensor with ESP32 TTGO LoRa32

Before getting started with interfacing lets know what are the required components.

Required components:

  • Sensirion SHT31 Humidity Temperature Sensor
  • ESP32 TTGO LoRa32 SX1276 OLED display board
  • Few connecting wires

Circuit Diagram:

Connect all the required components listed above as per the below schematic diagram.

esp32 ttgo lora with sht31 circuit diagramAs you can see from the above circuit diagram we had connected SDA and SCL pins of SHT31 to 21(GPIO21) and 22(GPIO22) pins of TTGO LoRa32 board respectively through I2C connection. And we powered the SHT31 pins VIN and GND through 5V and GND pins of TTGO board. The I2C OLED display is already connected to 4(SDA) and 15(SCL) by default.

After Connecting everything according to the above image, Its time to upload the code which you can find below.

Source Code:

Connect TTGO LoRa32 board to PC where Arduino IDE is installed. Copy the below code and paste it in the Arduino workspace and Choose the Board as TTGO LoRa32-OLED V1 from the Tools menu. Choose the correct Port where the board is connected. Install the required libraries from the below links or from the library manager and hit Upload.

Required Libraries:

  • Adafruit_SHT31.h : Link
  • Adafruit_SSD1306: Link
  • Adafruit-GFX-Library: Link
After uploading the code press reset button on the TTGO board and open serial monitor to check the values and SHT31 status which you can also check on OLED display as shown in the below output image.

Output or result:

esp32 ttgo lora32 output with sht31 temperature and humidity

Few other ESP32 TTGO LoRa32 boards have different SDA and SCL pins so check with the manufacturer and pinouts to make a correct connection. If you got any errors while working on this project, please feel free to comment below. And if you like this tutorial please follow our Facebook Meta pageCircuit Schools” for interesting projects.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button