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, 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.
#include <WiFi.h>
#include <HTTPClient.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// Definiciones para el sensor BME280
#define PRESION_NIVEL_MAR_HPA (1013.25)
// Reemplaza con tus credenciales Wi-Fi
const char* red_wifi = "Tu_Red_Wifi";
const char* contrasena_wifi = "Tu_Contraseña";
// API Key de ThingSpeak
const char* clave_api = "Tu_Clave_Api";
// Dirección URL de ThingSpeak
const char* servidor_thingspeak = "http://api.thingspeak.com/update";
// Objeto del sensor BME280
Adafruit_BME280 sensor_bme;
void setup() {
Serial.begin(115200);
// Inicializar WiFi
WiFi.begin(red_wifi, contrasena_wifi);
Serial.print("Conectando a WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConectado a WiFi");
// Inicializar el sensor BME280
if (!sensor_bme.begin(0x76)) {
Serial.println("No se encuentra el sensor BME280. Revisa la conexión.");
while (1);
}
}
void loop() {
// Leer datos del sensor BME280
float temperatura = sensor_bme.readTemperature();
float humedad = sensor_bme.readHumidity();
float presion = sensor_bme.readPressure() / 100.0F; // Conversión a hPa
// Mostrar datos en el monitor serial
Serial.print("Temperatura = ");
Serial.print(temperatura);
Serial.println(" *C");
Serial.print("Humedad = ");
Serial.print(humedad);
Serial.println(" %");
Serial.print("Presión = ");
Serial.print(presion);
Serial.println(" hPa");
// Enviar datos a ThingSpeak
if(WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = String(servidor_thingspeak) + "?api_key=" + clave_api + "&field1=" + String(temperatura) + "&field2=" + String(humedad) + "&field3=" + String(presion);
http.begin(url);
int codigo_http = http.GET();
if(codigo_http > 0) {
Serial.printf("Código de respuesta: %d\n", codigo_http);
if(codigo_http == HTTP_CODE_OK) {
String respuesta = http.getString();
Serial.println("Datos enviados a ThingSpeak");
}
} else {
Serial.printf("Error en la conexión: %s\n", http.errorToString(codigo_http).c_str());
}
http.end();
} else {
Serial.println("Error de conexión WiFi");
}
// Intervalo de actualización (15 segundos)
delay(15000);
}
Uploading BME280 Sensor Data to ThingSpeak Using ESP32
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by CarlosVolt Tutoriales
- Infrared stepper motor control with speed control More info and updates https://rogerbit.com/wprb/2024/09/motor-paso-a-paso-x-infrarrojo/In this proje...
- 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, h...
- Water pump control for irrigation via telegram and esp32 Water Pump Control by Telegram and ESP32 is an automated system that allows you to remotely control ...
- Air conditioning on/off control via telegram and esp32 In this tutorial we will see how to control an air conditioner, with an esp32 and the telegram appli...
- 35 watt stereo amplifier In this video we will see how to build an audio amplifier, with the TDA7377 integrated circuit, and ...
- Laser alarm with RFID module More info and updates in https://rogerbit.com/wprb/2024/08/alarma-laser-rfid/In this project, we bui...
- Control lights by voice commands and keys In this tutorial we will see how to create a device to control lights by voice commands, with a modu...
- Stepper motor control x bluetooth and app In this tutorial we will see a circuit, which controls a stepper motor, with an application made in ...
- DFplayermini x bluetooth mp3 player control More info and updates in https://rogerbit.com/wprb/2022/12/dfplayermini-x-bluetooth/In this tutorial...
- Robot with WiFi control and servos driven by ESP32 More info and updates in https://rogerbit.com/wprb/2023/07/robot-wifi/A robot controlled by Wi-Fi, s...
- How to make a water level meter with uln2803 In this tutorial we will see how to make a water level meter circuit with the built-in uln2803.The p...
- DTMF decoder for handy with arduino, control over several kilometers In this tutorial we will see how to make a circuit to connect to our handy, in this case a Baofeng U...
- Turn on light from thindspeak with esp32 In this tutorial, we will show you how to control lights over the Internet using an ESP32 and the Th...
- MP3 player control with webserver using ESP32 WIFI In this tutorial, you will learn how to build a web server using the ESP32 to control the YX5300 mod...
- Time clock with fingerprint IoT module, uploading data to thingspeak More info in and updates in https://rogerbit.com/wprb/2022/07/reloj-de-control-fingerprint/In this t...
- Make your own logic tip (includes printed circuit board) In this video tutorial we will see how to make a logic tip, on a printed circuit, with the integrate...
- Coil or inductor meter with Arduino and OLED display More info and updates in https://rogerbit.com/wprb/2022/06/medidor-inductores/In this tutorial we wi...
- Turn on Light with Reyax RYLR896 LoRa Modules with Acknowledgement In this tutorial, you will learn how to use the Reyax RYLR896 LoRa modules to wirelessly and reliabl...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-