This Arduino IDE project is the code to power an ESP32 Thing connected via I2C to a BME680 environmental sensor. The microcontroller connects to your WiFi network and publishes to an MQTT broker of your choice at a configurable interval.
This was purpose-built to be used in conjunction with other MQTT-compatible software... In this case, Home Assistant, but the same setup will work with anything similar.
- ESP32 Thing
- BME680
- MQTT Broker of your choice (e.g. mosquitto)
- Arduino IDE
- Espressif's library for the ESP32
- If using Linux, your user will need to be in the
dialout
group.
- Attach your BME680 to the ESP32 board using a convenient Qwiic connector.
- Open the project in Arduino IDE
- Modify at least the following code constants:
- NETWORK_ID
- PASSWORD
- MQTT_TOPIC
- MQTT_URI
- Plug your ESP32 board into your computer using a micro USB cable, and flash the software.
LED | Meaning | Actions |
---|---|---|
Off | No power or starting up. | Check power and wait at least 30 seconds. |
Flashes once, with 2 seconds in between | BME680 wasn't found | Make sure the BME680 is wired in and working. If using a non-standard I2C mode, you may have to update the BME680_I2C_MODE configuration. |
Flashes twice | WiFi error | Make sure wifi can reach the ESP32, and the NETWORK_ID/PASSWORD configuration is correct. |
Flashes Trebly | MQTT client error | Make sure your MQTT broker is running and the connection settings are correct. |
Lit Steady | No Error | Have some tea. Relax. Read a book. |
All other issues should be debugged using the IDE, with the DEBUG constant defined for verbose output to the console. Make sure to set the baud rate in the IDE to match SERIAL_SPEED (115200 unless changed).