In this project we use an ESP32 microcontroller model devkit v1 together with a BME280 I2C sensor as shown in the image above. Thus, the ESP32 captures the temperature, pressure, humidity and altitude measurements through the BME280 sensor and sends them to an mqtt broker. The project was built using the platformio extension for VScode.
The ESP32 can be connected to the wi-fi network, the device containing the mqtt broker can be on the web or on the local network.
Open the integrated terminal by clicking on the PlatformIO: New Terminal icon and typing:
pio lib install
Now rename the env.example folder that is inside the include folder to env. Now edit the files:
env.wifi.h
// your wifi network credentials
const char *WIFI_SSID = "YOUR_SSID";
const char *WIFI_PASS = "YOUR_PASSWORD";
env.mqtt.h
const char *MQTT_SERVER = "YOUR_SERVER_DNS_OR_IP";
const int MQTT_PORT = 1883;
const char *MQTT_USER = "mosquitto";
const char *MQTT_PASS = "mosquitto";
const char *MQTT_TOPIC = "esp32/bme280";
Now upload the firmware to the ESP32 by clicking on the Platformio:Upload icon. Logically the ESP32 must be plugged into your computer's USB.
👋 My contacts!