There isn’t a more important and less pleasant part of your home than the crawl space. Unless you enjoy dark, dirty, claustrophobic places, there is a good chance you rarely visit your crawl space. The health of your home is highly dependent on the health of your crawl space. Nothing wreaks havoc on your crawl space like excess moisture problems. Mold growth, wood rot, and insects thrive in dark, wet spaces. If you want to keep an eye on the health of your crawl space, you need to monitor its humidity levels.
This tutorial will show you how to remotely monitor your crawl space humidity from your mobile device and/or laptop. This will allow you to not only see the current humidity level but also see the historical data over time without having to frequently go down there. This tutorial will also show you how to set up trigger alarms to text/email you whenever your humidity exceeds a certain threshold.
Crawl Space Types
Like most new houses in Tennessee, my house has a vented crawl space. Several crawl space vents around the house let outside air circulate under the floor, which, in theory, helps dry out any condensation that may form. There is a crawl space vapor barrier installed which covers the entire floor. This barrier keeps the moisture in the soil from being absorbed by everything in the crawl space including the floor joists. If everything works like it should, my crawl space should stay dry and mold free.
Other types include encapsulated and conditioned crawl spaces. These types are sealed from the outside and may include mechanical dehumidifiers to pull moisture out of the air.
When we measure humidity, we are measuring relative humidity. Relative humidity is the amount of water vapor in the air relative to how much water vapor the air can hold. Relative humidity is expressed in %. This is different than absolute humidity, which is the actual amount of water vapor contained in the air. Absolute humidity is expressed as grams of moisture per cubic meter of air (g/m3).
Warm air can hold more water vapor than cold air. If warm air moves from the outside into a cooler crawl space, the relative humidity will increase ~2.2% for every 1 °F decrease in temperature. For example, if the temperature is 90 °F and 60% humidity outside and that air moves into a vented crawl space that is 70 °F, the relative humidity inside the crawl space (assuming no other influences) would be (90–70)*2.2 + 60% = 104%. If our crawl space reaches 100% humidity, condensation forms (what we don’t want).
Any analysis of humidity in my vented crawl space requires monitoring the temperature of my crawl space as well as the humidity and temperature outside. Otherwise, I will have no idea if there are any other influencers affecting humidity.
The Hardware You Need
- Power outlet or extension cord in your crawl space (I had an electrician put an outlet in for $100).
- WiFi in your house.
- Raspberry Pi (3 or 4) or Raspberry Pi Zero W(H). $35 or $10 respectively.
- Micro SD card ($4).
- Raspberry Pi power supply ($8).
- BME280 temperature/humidity sensor ($4.50/ea).
- Female to female jumper wires ($5).
I bought a Raspberry Pi Zero W kit for $29 which also includes a case, a mini HDMI adapter, and a micro USB adapter. The Zero W requires you to solder the pin headers onto the board. If you can find a Pi Zero WH, the headers are pre-soldered. The Raspberry Pi 3 and 4 have pre-soldered pin headers. The BME280 linked above also requires you to solder a four-pin header. There are some versions of this sensor available that have the headers pre-soldered.
I have a wireless keyboard/mouse that I keep around for setting up each of my Raspberry Pis the first time. Once that Pi is set up, the keyboard/mouse is no longer needed. I use something like this.
*note: I experimented with multiple BME280 sensors as well as multiple DHT22 sensors. The BME280 sensors were, by far, the most consistent and accurate humidity sensors. The DHT22 humidity readings were all over the place from sensor to sensor.
The Software You Need
- The free Raspbian operating system for your Raspberry Pi.
- A Python script (included in this tutorial).
- An Initial State account for data streaming and visualizations ($9.99/mo).
This tutorial will utilize a paid web service, Initial State, for creating the dashboards, storing historical data, retrieving local weather data, and sending SMS/email alerts. All of these functions are fully hosted and available in a web app (hence the $9.99/mo). You can replace this part of the tutorial with another web service or build your own if the $9.99/mo is a no-go for you.
The BME280 sensor will have four pins you need to connect to your Raspberry Pi (same pinout for either a Pi Zero or Pi 3/4).
- BME280 VIN pin connects to Pi pin 1 (3.3V).
- BME280 GND pin connects to Pi pin 6 (GND).
- BME280 SCL pin connects to Pi pin 5 (SCL).
- BME280 SDA pin connects to Pi pin 3 (SDA).
You will need a monitor and keyboard to set up your Raspberry Pi the first time. Once it is set up, you won’t need either a monitor or a keyboard to run when deployed in your crawl space.
Raspberry Pi Setup
- You need to install the Raspbian operating system on your Pi. Follow the instructions at https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up.
- Connect your Pi to your WiFi network https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/6.
- The BME280 sensor requires you to enable i2c on your Pi. At the Pi terminal type:
5 Interfacing Options,
P5 I2C, and select
<YES> to enable i2c. Select
<Finish> to save and exit.
- Let’s test out the connection to the sensor. On your Pi,
sudo i2cdetect -y 1
You should see something like the following:
This should show your sensor at address 0x76 (possibly address 0x77). If you don’t see either, check your wiring, make sure i2c is enabled in
raspi-config, and reboot.
- (optional) If you want to remotely configure your Pi (which you do because you don’t want to have to go down to your crawl space unnecessarily), enable SSH on your Pi:
sudo raspi-config, Select
5 Interfacing Options,
P2 SSH, and
<YES>to enable SSH.
<Finish>to save and exit.
- (optional) If you want to test out remotely configuring your Pi, at the Pi terminal type:
This will return the IP address of your Pi. At your laptop terminal, type:
ssh pi@<insert Pi ip address>
Once you can successfully SSH into your Pi, you may want to make it boot directly to the console instead of loading the desktop UI. You can do this as follows:
sudo raspi-config ->
3 Boot Options->
B1 Desktop / CLI->
B2 Console Autologin->
- There are two Python modules you need to install, one to communicate with the BME280 sensor and one to send data to your Initial State account. On your Pi, run the commands:
sudo pip install RPi.bme280sudo pip install ISStreamer
- Register for an account at https://api.init.st/auth/#/register .
- This will start a 14-day free trial (no credit card required for the trial).
- The following script will read temperature and humidity from your BME280 and send the results to your Initial State account every ten minutes.
- Place this script onto your Pi.
- Your Initial State account access key has to be specified on line 10. Copy+paste this key from your Initial State account (more info).
- If you want to change to metric units or change the number of minutes between sensor reads, modify lines 11 and 12.
- If the i2c address was different than 0x76 in the Raspberry Pi setup section, change the value accordingly on line 17.
- Kick off the script on your Pi to start streaming sensor data to your Initial State account:
Building a Web Dashboard
Go to your Initial State account (https://iot.app.initialstate.com), click on the “💦 Crawl Space” bucket name on your bucket shelf, and view the data coming into your dashboard. You can customize your dashboard by adding and sizing line graphs, gauges, statistics, etc. (more info).
Bringing in Local Weather
There is no way to do proper analysis of humidity in a vented crawl space without also logging the outside temperature/humidity. Luckily, Initial State has a nice integration with Weatherstack which lets you bring local weather data into your dashboard. You can add your local weather data to your existing data bucket by following the steps outlined in this support article. A more detailed tutorial can be found in this Medium article.
Instead of bringing in every available weather signal from Weatherstack, I recommend selecting only the most relevant data such as
curr_humidity. Too many unncessary data streams make it hard to create an effective dashboard.
If you want a good starting point for a dashboard layout, you can import one of the two dashboards designed for this tutorial by following the instructions in this support article. All you need are the share URLs for the dashboards above (https://go.init.st/fcpp6ll for the desktop version and https://go.init.st/ol4pfy0 for the mobile version).
You can create a second view of the same data by following this support article. This will allow you to have both a desktop and a mobile version of your data.
Pi IP Address
If you would like to add the IP address of your Pi to your dashboard (always handy in case you need to SSH into it and don’t remember the IP address or DHCP changes it), use the following modified Python script (make the same modifications to ACCESS_KEY, METRIC_UNITS, etc. as before).
You will need to install the psutil Python module before using this script:
sudo pip install psutil
Lines 34–36 stream the current IP address to your dashboard with every read.
Adding a SMS/Email Alert
If your humidity ever gets above a certain threshold (e.g. 80%), you probably want to get a notification so you can investigate why. Follow the instructions at this support article to set up a custom SMS and/or email trigger alert.
Deploying Your Crawl Space Humidity Monitor
Auto-Run on Boot
Once everything looks like it is working, you are almost ready to take your Pi + sensor down to your crawl space and fire it up. To make our setup a bit more robust, we need to kick off our Python script every time our Pi boots. This way our humidity monitor will restart without any intervention when we get a restored power outage.
Adding a process that runs on boot is really easy. At the Pi terminal:
If this is the first time you have run crontab, it may ask you which text editor you want to use (e.g. nano). Add the following line to the bottom of the crontab text file then save and exit:
@reboot python /home/pi/bme280/crawlspace.py &
You will need to specify the exact path of your script. In the example above, I created a directory called bme280 and put my Python script there.
Turn off your Pi and take it down to your crawl space (no monitor, keyboard, or mouse is necessary). It is wise to hang your Pi from the floor joists instead of letting it touch the ground (to avoid any water that may get on the floor). I put a nail in one of the floor joists and draped the power cord over the nail. Turn it on and make sure data starts flowing into your dashboard.
Conclusion (Analysis of My Crawl Space)
I’ve had my crawl space humidity monitor running for about four weeks at the time of writing this tutorial. I installed this monitor in mid-June, right when the humidity went way up in Tennessee. My averages so far are as follows:
Crawl space temperature/humidity average: 68.6 °F / 83.2%.
Outside temperature/humidity average: 79.0 °F / 69.1%.
My crawl space averages 10.4° cooler in temperature and 14.1% higher in humidity. I would expect my vented crawl space to average ~92% humidity based on the outside temperature/humidity (using the relative humidity conversion of +2.2% humidity for every 1 °F decrease). This means that I do not have anything happening in my crawl space that is adding humidity. However, I am still uncomfortable with humidity readings that high as mold can grow whenever humidity reaches levels greater than 70% for prolong periods of time.
My plan is to collect more humidity data over the next few months before deciding if I should convert my vented crawl space into an encapsulated or conditioned crawl space.