zbj3ji / esp32-cam_bme_280_bme680_esphome

Using ESP32-CAM (AI-Thinker) with Bosch Sensors BME280/BME680 via I2C and its integration into Home Assistant via Esphome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP32-CAM & BME280/680 & Home Assistant & ESPHome integration

Using ESP32-CAM (AI-Thinker) with Bosch Sensors BME280/BME680 via I2C and its integration into Home Assistant via Esphome. With some small modifications you can use this code also for other boards e.g. ESP01/ESP12/... which I already tried as well. Focus here is NOT to show how to do flashing via esptool, just to share YAML configuration file used for flashing of microcontroller by esptool to save your time in development phase.

Note: BME280 is a temperature sensor. BME680 has additionally a gas sensor.

Intro

I was personally struggling to find out comprehensive tutorial, how to integrate ESP32-CAM together with any kind of Bosch sensor via I2C. The main motivation had been to use just one microcontroller (in this case ESP32-CAM) for everything - camera & temperature/gas sensor.

Wiring

Here pinout of ESP32-CAM. The GPIO names are important to set I2C correctly. To this point we will come again when we write the code.

Image source: RandomNerdTutorials.com

obrazek

Here my complete wiring:

obrazek

Here you find a sketch made in Fritzing.

Be careful: BME280/680 are sensor with supply power 3.3V! ESP-CAM works with both 3.3/5V, but for better stability I recommend to use 5V.

Code

Here complete YAML file for ESP32-CAM & BME280.

Based on the ESP32 (or other microcontroller) pinout, you have to define the right I2C pins. In my case I used GPIO13 as SDA and GPIO12 as scl (see wiring above). You can change it as you wish, but then you need to use the right pins. Another very important thing is to use correct sensor address - in my case 0x76, other option is e.g. 0x77.

Here a default example from ESPHome web site about ESP32-CAM.

Integration

This is an example, how it looks like in Home Assistant:

obrazek

Image

obrazek obrazek

About

Using ESP32-CAM (AI-Thinker) with Bosch Sensors BME280/BME680 via I2C and its integration into Home Assistant via Esphome

License:MIT License