I2C bus with three sensors
Build it step by step
0 of 6 doneWire one device
Add the OLED first and run the scanner.
Add the second
Wire the BME280 and run the scanner again.
Add the third
Wire the BH1750 and note all three addresses.
Read each sensor
Check the Serial Monitor values for temperature, humidity and light.
Show them together
Watch all four values on the OLED.
Force a clash
Set the BH1750 ADDR pin high and see its address change to 0x5C.
How do you build an I2C bus with three sensors?
Put an OLED, a BME280 and a light sensor on one I2C bus and read them all. You need Arduino Uno R3, SSD1306 OLED Display, BME280 Environmental Sensor, BH1750 light sensor, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 45 minutes.
- Level
- Intermediate
- Time
- About 45 min
- Parts
- 6
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Uno 5V | OLED, BME280 and BH1750 VCC | Power (check each board accepts 5 V, otherwise use 3V3) |
| Uno GND | OLED, BME280 and BH1750 GND | Ground |
| Uno A4 (SDA) | All three SDA pins | Shared data |
| Uno A5 (SCL) | All three SCL pins | Shared clock |
Code
Arduino IDE, board "Arduino Uno". Install "Adafruit BME280 Library" with "Adafruit Unified Sensor", "BH1750" by Christopher Laws and "U8g2". The BME280 address is 0x76 or 0x77 depending on its SDO pin, and the BH1750 is 0x23 (0x5C if its ADDR pin is pulled high). If two devices share an address, change one with its address pin.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <Adafruit_BME280.h>
#include <BH1750.h>
#include <U8x8lib.h>
U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
Adafruit_BME280 bme;
BH1750 light;
void scan() { // step 1: print every address found
Serial.println("Scanning...");
for (byte a = 1; a < 127; a++) {
Wire.beginTransmission(a);
if (Wire.endTransmission() == 0) { Serial.print("Found 0x"); Serial.println(a, HEX); }
}
}
void setup() {
Serial.begin(9600);
Wire.begin();
scan(); // expect 0x23 (BH1750), 0x3C (OLED), 0x76 or 0x77 (BME280)
if (!bme.begin(0x76) && !bme.begin(0x77)) Serial.println("BME280 not found");
light.begin();
oled.begin();
oled.setFont(u8x8_font_chroma48medium8_r);
}
void loop() {
char b[17], v[8];
dtostrf(bme.readTemperature(), 5, 1, v); snprintf(b, sizeof b, "Temp %s C ", v); oled.drawString(0, 1, b);
dtostrf(bme.readHumidity(), 5, 1, v); snprintf(b, sizeof b, "Hum %s %% ", v); oled.drawString(0, 3, b);
dtostrf(bme.readPressure() / 100.0, 6, 0, v); snprintf(b, sizeof b, "Pres %s hPa", v); oled.drawString(0, 5, b);
snprintf(b, sizeof b, "Lux %u ", (unsigned)light.readLightLevel()); oled.drawString(0, 7, b);
delay(1000);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Scanning... Found 0x3C Found 0x76
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Scanner | Lists 0x23, 0x3C and 0x76 or 0x77 |
| Finger over the BH1750 | Lux drops |
| Breath on the BME280 | Humidity rises |
| Unplug one device | It disappears from the scan |
If it does not work
Scanner finds nothing
Check SDA on A4, SCL on A5 and the power pins.
BME280 not found
Try the other address or check its VCC level.
OLED blank
Check 0x3C appears in the scan and the display wiring.
Values freeze
A loose wire has stopped the bus. Check all joints.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the I2C bus with three sensors?
Arduino Uno R3, SSD1306 OLED Display, BME280 Environmental Sensor, BH1750 light sensor, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the I2C bus with three sensors take to build?
About 45 minutes for a intermediate maker, in 6 steps.
How do I know the I2C bus with three sensors works?
Scanner: Lists 0x23, 0x3C and 0x76 or 0x77. Finger over the BH1750: Lux drops. Breath on the BME280: Humidity rises.
Scanner finds nothing: what should I check?
Check SDA on A4, SCL on A5 and the power pins.
BME280 not found: what should I check?
Try the other address or check its VCC level.
OLED blank: what should I check?
Check 0x3C appears in the scan and the display wiring.
Values freeze: what should I check?
A loose wire has stopped the bus. Check all joints.
