Keep your bathroom dry using a Raspberry Pi

Program your Raspberry Pi to keep tabs on your bathroom's humidity levels with this handy tutorial

David Hunt noticed one day that, every time he took a shower, his bathroom would become humid 
for hours after. "I could have just bought a fan, but that's boring. There would have been no challenge," Hunt says.

Instead, he programmed a Raspberry Pi to keep tabs on the bathroom's humidity level, and to operate the fan automatically above a certain threshold; he called his invention the "DampPi". Here's how to build your own – but read our disclaimer first (see below).

WHAT YOU'LL NEED:
  • Raspberry Pi
  • 230V extractor fan
  • Two Adafruit DHT22 temperature and humidity sensors
  • A/C relay board
  • Breakout board
  • 30cm2 acrylic sheet
  • Electrical cables and wires
  • Cable plastic conduits
  • Drill
  • Screws
  • Glue
  • USB power cable and Ethernet cable for Raspberry Pi

The programs to install on the Pi can be found on GithHub here and here

GET THE HARDWARE BUILT

You could pay someone to do this, or use a drill to make a hole in the bathroom's wall, and install the fan. "I used a drill bit for a 120mm hole," Hunt says. After that, locate a power outlet from which you can run a mains cable to power the fan. When you find it, do not connect the cable to the fan (yet).

CONNECT TO THE MAINS

Switch your home's power off before you do this. Connect the mains cable to the relay board and run a cable from the board to the fan. Shield the wiring with the plastic conduits. "There's a mains coming in and an output to the fan. The board basically works as a switch," Hunt explains.

PROGRAM THE RASPBERRY

Install the Adafruit library and WiringPi on your Pi. Using the Adafruit program, set it to check the humidity periodically. Hunt says: "I set a threshold: when humidity goes above 90 per cent, it will switch on the relays and the fan goes on," he says. "When humidity goes below 85 per cent, it turns it off."

SET THE SENSORS

Place your sensors in a spot where they can effectively detect the bathroom's temperature and humidity. To obtain more accurate data, Hunt recommends mounting them somewhere near the ceiling, but not too close to the shower cabin. Plaster, screw them or glue them in place.

KEEP IT NEAT

For practicality and aesthetics, Hunt suggests fixing the Raspberry Pi, the relay board and the breakout board on the acrylic sheet. "In this way, it is easier to move them all around," he says. "And once everything is ready, you can fasten the sheet somewhere – I screwed it on to a rafter."

LINK IT ALL – THEN GET STEAMY

Connect the humidity sensors to the Raspberry Pi. Link the Pi to the relay via the breakout board, and plug the Pi in through the USB cable. If you are uploading your data to the internet, use the Ethernet cable to connect the Pi to a LAN port (or use Wi-Fi if you have a Pi 3). Now enjoy your shower.

Disclaimer: Be sure to always switch your home's power off when you are working with electrical cables. In general, engage in this "How To" only if you are confident working with A/C and mains levels of voltage

This article was originally published by WIRED UK