Crawl Space Ventilation

2 November 2017

Using Node Red to control crawl space ventilation

On the full, desktop version of Raspian available for the Raspberry Pi, there is a link for a pre-installed version of Node Red. Node Red was created by IBM to more easily facilitate IOT, "The Internet of Things". I decided to incorporate Node Red into my environment to help tie together my sensors and provide some nice gauges and graphs to see trends and results. Node Red provides a graphical way to link logical blocks together in a "flow". 

Through research I learned that one way to control humidity in a crawl space is to monitor temperature and humidity inside and outside the crawl space. These readings are used to calculate dew point. When the dew point is higher inside the crawl space than outside, you can bring in air from the outside to displace the higher humidity inside. I have Node Red running on two Raspberry Pi machines. One Pi is connected to a BME280 temperature, pressure and humidity sensor. This sensor will gather information inside my crawl space. Instead of using another sensor to measure conditions outside the crawl space, I use a Weather Underground node to fetch current conditions for my location from Weather Underground.

Each block in the image below is a "node". Nodes are available from the "palette" on the left side of the screen. Most of the various node types are installed by default and others, like the BME280 node, have to be installed. Each node receives and/or sends messages in various formats. If you need a function not provided by a standard node, you can use a "function" node and write some Java Script to do what you need. For example, the "Dew Point" nodes use temperature and humidity readings to calculate dew point.

Note: I was having problems with the BME280 Node so I replaced it with a Python script that fetches temperature and humidity data every 2 seconds from the BME280 and publishes the data to the on-board broker.

Here is a screen capture of my first flow that gathers sensor information every 2 seconds, calculates dew points, sets a Raspberry Pi GPIO pin to control a ventilation fan, and stuff all the information into an on-board MQTT broker. The MQTT data is "bridged" (think mirrored) to a second Raspberry Pi that gathers this info and populates a MySQL database and generates web pages for graphical display of all the information.

This is the flow on the crawl space ventilation control Pi:


If you would like to create an identical flow in your Raspberry Pi, contact me and I'll send you the text file. Just select all the text and copy it to the clipboard, then in Node Red, select "import" then "Clipboard" and import into your flow. The Weather Underground node requires an API key which you will need to get from Weather Underground. The API key is free and you can make 500 API calls per day before they cut you off.  I'll be happy to provide the Python script to you also. If you want to use another type sensor such as a DHT22, just write your own script.

18 May 2018
Note: I just learned that Weather Underground no longer issues free API keys. There is however another service called OpenWeatherMap that provides free keys and there is a node called node-red-node-openweathermap that will do the same thing as Weather Underground. See https://openweathermap.org/api

This dashboard is running on the second Raspberry Pi. The red circle (actually a gauge configured as "donut") indicates that the ventilation fan is engaged. The icon turns black when the fan is off. 

https://sites.google.com/a/wt4y.com/radio/node-red/DinPi.jpg
Here is the initial installation in the crawl space. At the moment, two sensors reside inside, but I will be using only one. The next step will be to mount the sensor in a proper enclosure. All the components are mounted on a standard DIN rail. From left to right the components are:
  • Perf board with the interface to the sensors, power supply and solid state relay
  • the Raspberry Pi with a 50mm fan to keep it cool
  • 5 volt power supply (from Amazon)
  • solid state relay (from Amazon)
  • DIN terminal blocks (from Amazon)
  • 3d printed mount for the PVC conduit (Carlon 3/4 inch conduit available at Home Depot or Lowes)
The fan on the Pi is rated for 12 volts, but I'm using 5 volts for power. This provides more than enough air flow to cool the Pi and it's completely silent.

I 3d printed the parts to mount the perf board, Raspberry Pi, power supply and conduit. 

For primary power, I wired up two switches. One switch controls input power to the 5 volt power supply. The other switch acts as a safety switch for the ventilation fan (not yet mounted). The duplex outlet is there because you can never have too many outlets.