FluxBench.AIShared project · read-only

I2C Multi-Sensor Dashboard

ESP32 DevKit (WROOM-32)·Arduino C++·Updated Jul 27, 2026·by FluxBench TeamIncludes Lab + Schematic + PCB

Four I2C devices share one two-wire bus (SDA GPIO21 / SCL GPIO22): a BME280 environment sensor at 0x76, a BH1750 light meter at 0x23, an MPU-6050 IMU at 0x68 and an SSD1306 OLED at 0x3C. The sketch scans the bus at boot and lists every address it finds, then streams a live serial dashboard while the OLED rotates between environment, light and motion pages. The simulator answers real register reads - chip IDs, WHO_AM_I and measurement registers - so the bus scan and every library call behave like real silicon. Bundled Lab bench, schematic and routed PCB included.

sketch.ino
// I2C Multi-Sensor Dashboard - three sensors and an OLED on one shared bus
// BME280 @0x76, BH1750 @0x23, MPU-6050 @0x68, SSD1306 @0x3C (SDA=21, SCL=22)
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_BME280.h>
#include <BH1750.h>
#include <MPU6050.h>

#define SDA_PIN 21
#define SCL_PIN 22

Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_BME280 bme;
BH1750 lightMeter;
MPU6050 imu;

int page = 0;
int tick = 0;

void scanBus() {
  Serial.println("Scanning I2C bus...");
  int found = 0;
  for (int addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    if (Wire.endTransmission() == 0) {
      Serial.print("  device at 0x");
      Serial.println(addr, HEX);
      found++;
    }
  }
  Serial.print("Found ");
  Serial.print(found);
  Serial.println(" device(s)");
}

void setup() {
  Serial.begin(115200);
  Wire.begin(SDA_PIN, SCL_PIN);
  scanBus();
  bme.begin(0x76);
  lightMeter.begin();
  imu.initialize();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println("I2C dashboard ready");
  display.display();
  Serial.println("Dashboard ready");
}

void loop() {
  float t = bme.readTemperature();
  float h = bme.readHumidity();
  float p = bme.readPressure() / 100.0;
  float lux = lightMeter.readLightLevel();
  float ax = imu.getAccelerationX() / 16384.0;
  float ay = imu.getAccelerationY() / 16384.0;
  float az = imu.getAccelerationZ() / 16384.0;

  Serial.print("T=");
  Serial.print(t, 1);
  Serial.print("C  RH=");
  Serial.print(h, 0);
  Serial.print("%  P=");
  Serial.print(p, 1);
  Serial.print("hPa  Lux=");
  Serial.print(lux, 0);
  Serial.print("  Acc=");
  Serial.print(ax, 2);
  Serial.print("/");
  Serial.print(ay, 2);
  Serial.print("/");
  Serial.println(az, 2);

  display.clearDisplay();
  display.setCursor(0, 0);
  if (page == 0) {
    display.println("ENVIRONMENT");
    display.print("Temp: "); display.print(t, 1); display.println(" C");
    display.print("Hum:  "); display.print(h, 0); display.println(" %");
    display.print("Pres: "); display.print(p, 1); display.println(" hPa");
  } else if (page == 1) {
    display.println("LIGHT");
    display.print("Lux: "); display.println(lux, 0);
    int bar = (int)(lux / 6);
    if (bar > 120) bar = 120;
    display.fillRect(0, 40, bar, 10, SSD1306_WHITE);
  } else {
    display.println("MOTION (g)");
    display.print("X: "); display.println(ax, 2);
    display.print("Y: "); display.println(ay, 2);
    display.print("Z: "); display.println(az, 2);
  }
  display.display();

  tick++;
  if (tick % 6 == 0) page = (page + 1) % 3;
  delay(500);
}

Built with FluxBench.AI — the AI workbench for embedded projects.