Introduction: Uploading BME280 Sensor Data to ThingSpeak Using ESP32
In this tutorial, we will show you how to connect a BME280 sensor to an ESP32 to read temperature, humidity, and atmospheric pressure data
Supplies
Step 1:
In this tutorial, we will show you how to connect a BME280 sensor to an ESP32 to read temperature, humidity, and atmospheric pressure data, and upload this data to ThingSpeak in real time. This type of project is ideal for IoT applications such as home weather stations or environmental monitoring systems.
What is BME280?
The BME280 is an advanced sensor from Bosch that can measure three environmental variables: temperature , relative humidity and atmospheric pressure . Thanks to its low consumption and compact size, it is widely used in IoT projects.
Main features:
- Temperature range: -40 to 85 °C
- Humidity range: 0% to 100%
- Pressure range: 300 to 1100 hPa
- Communication: I2C (used in this tutorial) and SPI
Necessary components
Before you begin, make sure you have the following components:
- ESP32
- BME280 Sensor (I2C version)
- Connection cables
- Account on ThingSpeak
An Esp32
Features of the ESP32-T module
Connectivity
The ESP32 module has all the WiFi variants :
- 802.11 b/g/n/e/i/n
- Wi-Fi Direct (P2P), P2P Discovery, P2P Group Owner mode and P2P Power Management
This new version includes connectivity via low-consumption Bluetooth
- Bluetooth v4.2 BR/EDR and BLE
- BLE Beacon
In addition, it can communicate using SPI, I2C, UART, MAC Ethernet, Host SD protocols
Microcontroller Features
The CPU is made up of a Tensilica LX6 model SoC with the following features and memory
- Dual core 32-bit with 160MHz speed
- Memoria ROM de 448 kBytes
- 520kBytes SRAM memory
Dyspnea at 48 Pines
- 18 ADC de 12 bits
- 2 8-bit DACs
- 10 pin contact sensors
- 16 PWM
- 20 Digital inputs/outputs
Food and consumption patterns
For the correct operation of the ESP32, it is necessary to supply a voltage between 2.8V and 3.6V. The energy it consumes depends on the operating mode. It contains a mode, the Ultra Low Power Solution (ULP) , in which basic tasks (ADC, RTC...) continue to be performed in Sleep mode.
Female pins
Dupont cables female male
PCB
Download gerber file –> Gerber_esp32
Circuit
Connecting the BME280 Sensor to the ESP32
We will use the I2C interface to connect the BME280 to the ESP32. Below are the necessary connections:
I2C Connections:
- VCC (BME280) → 3.3V (ESP32)
- GND (BME280) → GND (ESP32)
- SDA (BME280) → GPIO 21 (ESP32)
- SCL (BME280) → GPIO 22 (ESP32)
Tip : If your BME280 sensor does not have built-in pull-up resistors on the SDA and SCL lines , add external 4.7kΩ resistors between each line and the 3.3V voltage.
Tip : If your BME280 sensor does not have built-in pull-up resistors on the SDA and SCL lines , add external 4.7kΩ resistors between each line and the 3.3V voltage.
ThingSpeak Setup
Before uploading the data, we need to configure ThingSpeak:
- Create a ThingSpeak account if you don't have one.
- Create a new channel with the required fields (e.g. “Temperature”, “Humidity” and “Pressure”).
- Once created, copy the channel write API key , which we will use in the code to send the data.