Projects / Dew point and mould risk alarm

Dew point and mould risk alarm

Beginner1 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANOSHT3123.1°CSSD1306

    Wire the I2C devices

    SDA to A4 and SCL to A5 for both the SHT31 and the OLED. They share the bus.

  2. NANOSHT3123.1°C

    Add the buzzer

    Active buzzer between D8 and GND.

  3. NANOSHT3123.1°C

    Upload and check the display

    Temperature, humidity and dew point appear.

  4. NANOSHT3123.1°C

    Breathe on the sensor

    Humidity jumps and the dew point rises towards the air temperature.

  5. NANOSHT3123.1°C

    Set the wall offset

    Measure a wall near the sensor with a thermometer and set WALL_OFFSET to air minus wall.

  6. NANO

    Place it

    Put it in the cupboard or bathroom where mould appears, away from the shower stream.

In short

How do you build a dew point and mould risk alarm?

An SHT31 sensor works out the dew point in a cupboard or bathroom and beeps when walls are likely to sweat and grow mould. You need Arduino Nano, SHT31 temperature and humidity sensor, SSD1306 OLED Display, Active buzzer 5 V, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and USB A to micro-USB cable (data). It takes 6 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
7

Parts list

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

Wiring

FromToWhy
SHT31 VCCNano 3.3V or 5V (check your breakout)Sensor supply
SHT31 GNDNano GNDCommon ground
SHT31 SDANano A4I2C data
SHT31 SCLNano A5I2C clock
OLED VCCNano 5V (or 3.3V on a 3.3 V board)Display supply
OLED GNDNano GNDCommon ground
OLED SDANano A4Shared I2C data
OLED SCLNano A5Shared I2C clock
Buzzer +Nano D8Alarm
Buzzer -Nano GNDReturn

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "Adafruit SHT31 Library", "Adafruit SSD1306" and "Adafruit GFX Library". Most OLEDs use address 0x3C and the SHT31 0x44, and an I2C scanner sketch will confirm them.

Runs on a virtual Arduino Nano 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_SHT31.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <math.h>

Adafruit_SHT31 sht;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const byte BUZZ = 8;
const float WALL_OFFSET = 3.0;          // outside walls are a few degrees cooler than the air; set it by measuring
const float RH_LIMIT = 70.0;
const unsigned long RH_HOURS_MS = 3600000UL;
unsigned long humidSince = 0;
bool humidTimerOn = false;

float dewPoint(float t, float rh) {      // Magnus formula, valid roughly 0 to 60 C
  const float a = 17.62, b = 243.12;
  float g = log(rh / 100.0) + a * t / (b + t);
  return b * g / (a - g);
}

void setup() {
  pinMode(BUZZ, OUTPUT);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  sht.begin(0x44);                       // use 0x45 if the ADDR pin is high
  oled.setTextColor(SSD1306_WHITE);
}

void loop() {
  float t = sht.readTemperature(), rh = sht.readHumidity();
  if (isnan(t) || isnan(rh)) { delay(1000); return; }
  float td = dewPoint(t, rh);
  float wall = t - WALL_OFFSET;

  if (rh > RH_LIMIT) {
    if (!humidTimerOn) { humidTimerOn = true; humidSince = millis(); }
  } else humidTimerOn = false;
  bool longHumid = humidTimerOn && millis() - humidSince > RH_HOURS_MS;
  bool sweating = wall - td < 2.0;       // wall within 2 C of the dew point
  bool alarm = longHumid || sweating;

  oled.clearDisplay();
  oled.setCursor(0, 0);  oled.setTextSize(1); oled.print("Temp "); oled.print(t, 1); oled.print(" C");
  oled.setCursor(0, 14); oled.print("Humidity "); oled.print(rh, 0); oled.print(" %");
  oled.setCursor(0, 28); oled.print("Dew point "); oled.print(td, 1); oled.print(" C");
  oled.setCursor(0, 46); oled.setTextSize(2); oled.print(alarm ? "MOULD RISK" : "OK");
  oled.display();

  digitalWrite(BUZZ, alarm && (millis() / 500) % 20 == 0);   // short beep every 10 s, not constant
  delay(2000);
}

Test checklist

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

CheckExpected
Breathe on the sensorHumidity rises above 90 % and MOULD RISK appears briefly
Compare dew pointAt 30 °C and 60 % the dew point should be about 21 °C
Leave it in a damp roomAfter an hour above 70 % the alarm beeps
Dry roomShows OK and stays silent

If it does not work

Display and sensor do not both work

Two devices cannot share an address. Run an I2C scanner and fix the address in the code.

Readings are NaN

Check SDA and SCL are not swapped and the sensor has power.

Humidity seems too high near a heater

The sensor is warmed by something nearby. Move it away from the board and regulator.

Alarm never stops in a bathroom

That may be correct after showers. Raise RH_LIMIT or add a fan.

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

Ask Lark AI

Common questions

What parts do I need for the dew point and mould risk alarm?

Arduino Nano, SHT31 temperature and humidity sensor, SSD1306 OLED Display, Active buzzer 5 V, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and USB A to micro-USB cable (data).

How long does the dew point and mould risk alarm take to build?

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

How do I know the dew point and mould risk alarm works?

Breathe on the sensor: Humidity rises above 90 % and MOULD RISK appears briefly. Compare dew point: At 30 °C and 60 % the dew point should be about 21 °C. Leave it in a damp room: After an hour above 70 % the alarm beeps.

Display and sensor do not both work: what should I check?

Two devices cannot share an address. Run an I2C scanner and fix the address in the code.

Readings are NaN: what should I check?

Check SDA and SCL are not swapped and the sensor has power.

Humidity seems too high near a heater: what should I check?

The sensor is warmed by something nearby. Move it away from the board and regulator.

Alarm never stops in a bathroom: what should I check?

That may be correct after showers. Raise RH_LIMIT or add a fan.