Implementation
Let's discuss the hardware first. The following Fritzing diagram shows the connections between ESP32 and other hardware components:
The interesting point here is the Inter-Integrated Circuit (I2C) connections. I2C is a bus, so we can connect multiple devices on the same bus, as long as they have different bus addresses. Therefore, we connect BME280 and TSL2561 to the same pins of ESP32, GPIO21
and GPIO22
. The OLED screen is also an I2C device, but its driver uses the second I2C channel of ESP32, so it is a good idea to connect the OLED screen to other GPIO pins to avoid any configuration conflicts.
Before delving into the code, we need to update the configuration files. Let's start with platformio.ini
, as follows:
[env:az-delivery-devkit-v4] platform = espressif32 board = az-delivery-devkit-v4 framework = espidf monitor_speed = 115200 lib_extra_dirs = ...