How to Build a Crawl Space Humidity Monitor with a Raspberry Pi

Jamie Bailey
Initial State
Published in
10 min readJul 13, 2020


Raspberry Pi Crawl Space Humidity Monitor


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.


Vented crawl space with vapor barrier
Vented crawl space with vapor barrier

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.

Relative Humidity

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

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.


Raspberry Pi Zero wiring for a BME280 temperature and humidity sensor
Raspberry Pi wiring for a BME280 temperature and humidity sensor

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).

Software Setup

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

sudo raspi-config
sudo raspi-config

Select 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:

BME280 detected on a Pi at address 0x76
BME280 detected on a Pi at address 0x76

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:
hostname -I

This will return the IP address of your Pi. At your laptop terminal, type:

ssh pi@<insert Pi ip address>

For example:

SSH into your Pi from your laptop
SSH into your Pi from your laptop

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-> <ok>-> exit.

Python Setup

  • 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

Initial State

Python Script

  • 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

Crawl space humidity monitor dashboard
Crawl space humidity monitor dashboard — live version at

Go to your Initial State account (, 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_weather_desc, curr_temp, and curr_humidity. Too many unncessary data streams make it hard to create an effective dashboard.

Dashboard Templates

Crawl space humidity mobile dashboard
Crawl space humidity mobile dashboard — live version at

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 ( for the desktop version and 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

Deployed crawl space humidity monitor
Deployed 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:

crontab -e

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/ &

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.

Hardware Deployment

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.



Jamie Bailey
Initial State

EVP Strategy, Alto | ex-CEO Initial State | SaaS | startup guy | nerd