Skip to main content
Tutorials

I2C Environmental Sensor Module

Overviewโ€‹

In this tutorial, we will build a compact I2C Environmental Sensor Module. This board is designed to measure ambient temperature, relative humidity, and barometric pressure, and display the live readings on a local OLED screen.

We will use I2C (Inter-Integrated Circuit), which is a popular serial communication protocol that allows multiple slave devices (the BME280 sensor and SSD1306 OLED) to communicate with a single master host using only two signal wires:

  • SDA (Serial Data)
  • SCL (Serial Clock)

๐Ÿ“‹ Components Checklistโ€‹

Our module will consist of:

  1. BME280 Environmental Sensor (U1) โ€” Digital sensor for temperature, humidity, and pressure in an LGA-8 package.
  2. SSD1306 OLED Display (U2) โ€” Standard 0.96-inch 128x64 I2C display panel.
  3. I2C Pull-Up Resistors (R1, R2) โ€” 4.7kฮฉ resistors to pull the SDA and SCL signal lines high.
  4. Decoupling Capacitors (C1, C2) โ€” 0.1ยตF capacitors to stabilize power supply inputs.
  5. 4-pin Male Header (J1) โ€” Connecting interface for power (VCC/GND) and communication (SDA/SCL) to a host microcontroller.

๐Ÿ› ๏ธ Step-by-Step Implementationโ€‹

Create a new file in your project or editor and paste the following tscircuit design code.

Complete Circuit Codeโ€‹


๐Ÿ’ก Crucial Hardware Design Notesโ€‹

  1. CSB & SDO Configuration:
    • The BME280 requires the CSB (Chip Select Bar) pin to be pulled to VCC to enable the I2C communication interface (pulling it low selects SPI mode).
    • SDO is the address select pin. Connecting it to GND sets the 7-bit slave address to 0x76. Connecting it to VCC sets it to 0x77.
  2. I2C Bus Pull-Ups:
    • The I2C protocol uses open-drain/open-collector outputs. This means the lines can only pull down to GND; they cannot pull high themselves.
    • External pull-up resistors (like R1 and R2) are mandatory to pull SCL and SDA lines up to VCC. Without these, the signals will stay low and the bus will not function.