Projects / Desk climate monitor

Desk climate monitor

Beginner1.5 hGuided buildReviewed
Guided project · simulationDesk climate monitorT 23.4°C · RH 48% · LED off
Live simulation · tap any part

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 6 done
  1. ESP32

    Place the ESP32

    Seat the ESP32 across the centre gap of the breadboard so each row of pins has free holes on both sides.

  2. ESP32

    Make the power rails

    Run 3V3 to the + rail and GND to the − rail. Check whether your rails are split halfway along.

  3. ESP32BME28024.8°C

    Wire the BME280

    VIN to 3.3 V, GND to ground, SDA to GPIO21, SCL to GPIO22.

  4. ESP3213.1 mASSD1306

    Add the OLED on the same bus

    VCC to 3.3 V, GND to ground, SDA to GPIO21, SCL to GPIO22. Read the pin labels: some modules swap VCC and GND.

  5. ESP3213.1 mA

    Add the alert LED

    GPIO25 to a 220 Ω resistor, resistor to the LED's long leg, short leg to ground.

  6. ESP32

    Upload and watch

    Upload the code, open the serial monitor at 115200 baud, and check the readings against the test checklist.

In short

How do you build a desk climate monitor?

An ESP32 reads temperature, humidity and pressure from a BME280, shows them on an OLED and lights an LED when the desk gets too warm. You need ESP32 DevKit V1, BME280 Environmental Sensor, SSD1306 OLED Display, LED 5 mm red, Resistor 220 Ω and Breadboard 830 Tie Points. It takes 6 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
ESP32 3V3BME280 VIN and OLED VCCShared 3.3 V rail
ESP32 GNDBME280 GND, OLED GND, LED cathodeShared ground rail
ESP32 GPIO21BME280 SDA and OLED SDAI2C data
ESP32 GPIO22BME280 SCL and OLED SCLI2C clock
ESP32 GPIO25220 Ω resistor, then LED anodeAlert output

Code

Arduino IDE with the ESP32 board package. Install the Adafruit BME280, Adafruit SSD1306 and Adafruit GFX libraries.

Runs on a virtual ESP32 Dev Module 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 <Adafruit_SSD1306.h>

Adafruit_BME280 bme;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int ALERT_LED = 25;
const float ALERT_C = 28.0;

void setup() {
  Serial.begin(115200);
  pinMode(ALERT_LED, OUTPUT);
  Wire.begin(21, 22);
  if (!bme.begin(0x76)) {
    Serial.println("BME280 not found at 0x76. Try 0x77.");
    while (true) delay(1000);
  }
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED not found at 0x3C.");
    while (true) delay(1000);
  }
}

void loop() {
  float t = bme.readTemperature();
  float h = bme.readHumidity();
  float p = bme.readPressure() / 100.0F;
  Serial.printf("T=%.1f C  H=%.0f %%  P=%.1f hPa\n", t, h, p);

  oled.clearDisplay();
  oled.setTextColor(SSD1306_WHITE);
  oled.setTextSize(2);
  oled.setCursor(0, 0);  oled.printf("%.1f C", t);
  oled.setCursor(0, 24); oled.printf("%.0f %%RH", h);
  oled.setTextSize(1);
  oled.setCursor(0, 52); oled.printf("%.1f hPa", p);
  oled.display();

  digitalWrite(ALERT_LED, t >= ALERT_C ? HIGH : LOW);
  delay(2000);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Serial monitor prints a line every 2 secondsT=24.1 C H=48 % P=1009.6 hPa (your values will differ)
Temperature indoorsRoughly 15 to 35 °C
HumidityRoughly 20 to 80 %RH; a steady 0 or nan means a BMP280
PressureAbout 1013 hPa at sea level, lower at altitude (around 950 hPa at 550 m)
Warm the sensor with your finger for 30 sTemperature rises by 1 to 3 °C, then falls back
Set ALERT_C a degree above room temperature and warm the sensorThe LED lights, then turns off as it cools

If it does not work

"BME280 not found at 0x76"

Try 0x77 in bme.begin(). Check SDA and SCL are not swapped. Run an I2C scanner sketch to see which addresses answer.

Humidity reads 0 or nan

Your board is probably a BMP280, which has no humidity sensor.

OLED stays blank

Try address 0x3D. Check it is a 128 × 64 module, and that VCC and GND are not swapped.

Temperature reads several degrees high

Move the sensor away from the ESP32 and regulator, which warm it.

Upload fails

Use a data-capable USB cable, select the right port, and hold BOOT while uploading if needed.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the desk climate monitor?

ESP32 DevKit V1, BME280 Environmental Sensor, SSD1306 OLED Display, LED 5 mm red, Resistor 220 Ω and Breadboard 830 Tie Points. BME280 Environmental Sensor: Make sure it is a BME280, not a BMP280. SSD1306 OLED Display: 128 × 64, I2C.

How long does the desk climate monitor take to build?

About 90 minutes for a beginner maker, in 6 steps.

How do I know the desk climate monitor works?

Serial monitor prints a line every 2 seconds: T=24.1 C H=48 % P=1009.6 hPa (your values will differ). Temperature indoors: Roughly 15 to 35 °C. Humidity: Roughly 20 to 80 %RH; a steady 0 or nan means a BMP280.

BME280 not found at 0x76: what should I check?

Try 0x77 in bme.begin(). Check SDA and SCL are not swapped. Run an I2C scanner sketch to see which addresses answer.

Humidity reads 0 or nan: what should I check?

Your board is probably a BMP280, which has no humidity sensor.

OLED stays blank: what should I check?

Try address 0x3D. Check it is a 128 × 64 module, and that VCC and GND are not swapped.

Temperature reads several degrees high: what should I check?

Move the sensor away from the ESP32 and regulator, which warm it.