loading

This is how I modified a standard 100 Cigar humidor to provide constant humidity and temperature via WiFi. The pi part of the project could easily be adapted for any other use that requires a temperature and humidity sensor.

Features:



• Total cost around 125$ including 55$ for the unmodified humidor. You could do this cheaper
• Web interface providing temperature and humidity reading
• RESTful API to provide readings to other systems. (Screenshot above shows my ElasticSearch Kibana data feed)
• Configurable push alerts for temperature / humidity limits with both "warning" and "alert" levels.
• Push alert on open / closed lid (Know if someone is pilfering your cigars!)
• Buzzer on humidity or temperature outside of alert limits / clear buzzing with button.

Step 1: Parts List

  1. Humidor - We're going to be cutting into it with a Dremel tool, so not a family heirloom. I got this BALLY II GLASS TOP HUMIDOR specifically for this project because it was cheap,I had no idea if I would destroy it by cutting into it with a dremel, and because I live right near Famous Smoke Shop, so I could pick it up the same day.
  2. Humidifier - You'd need this for any humidor, and the ones that come with them are nearly always awful. I use this one attached with the magnets that came with it to the glass top, but didn't figure it in to the total price since you can do way cheaper than this.

  3. Raspberry Pi - I had an older Raspberry Pi B+ laying around, which was more than enough for our purposes, but any Pi with the B series pin out should do. As usual the Pi will require a power supply, Micro SD card, and, if you're not using a Pi 3 and want wireless connectivity, a USB WiFi adapter.
  4. ABS Plastic Case For Raspberry Pi 2 - This particular case has a separate side panel blank that we can cut our openings for the sensor pinout and LED into.

  5. DHT22 Digital Temperature and Humidity Sensor - I got this one from Amazon. You could also use a DHT11 but you would need to modify the node in the Node-RED setup.

  6. Common Cathode RGB LED - This will require a current limiting resistor depending on the LED

  7. Resistors - You'll need a 10k pull up for the DHT sensor, and a current limiting resistor for the LED. I use a 220 ohm resistor for the ones that I linked to.

  8. Foil Tape- This is just foil tape that you would find in the HVAC section of the Home Depot. It's conductive so it's perfect to make the contact sensor for the lid. I had it on hand from another project.

  9. Stackable pin headers - I had these on hand

  10. PCB Mount Momentary Push button - Something like this

  11. 5x7 Double Side Prototype board - This is what I had on hand, but had to cut it to fit it into the case. If you can find smaller, probably 5x5 or 5x4cm would be right.

  12. Buzzer - These are 5v continuous beep (Add voltage, get tone. You don't need to do the work of generating a stream of ones and 0s to make it beep) buzzers that I had on hand. I hooked it straight to a GPIO (3.3v), but since they're 5 volt buzzers they're not that loud at 3.3v. If I had it to do again I'd have put them on the 5v rail with a transistor in between.

Step 2: Setup Raspbian

I started with a clean NOOBS Raspbian install. In retrospect, having lost 2GB from an 8GB SD card by using NOOBS, a fresh Raspbian flash would have been better. If you're using a bigger card and/ or a newer pi this doesn't matter as much. Once you have your Pi up and running with fresh Raspbian you will need to follow these steps:

  1. (Optional) Get rid of X Windows (Saves about 2GB of disk space, and you don't need it unless you plan on hooking up a screen and running a browser in kiosk mode to always display the readings). I followed the best answer in this stackexchange, which boils down to 'sudo apt-get remove --auto-remove --purge 'libx11-.*' then 'sudo apt-get autoremove --purge' a bunch of times until it stops finding orphan packages to purge.
  2. Install Node.js 'sudo apt-get install node'
  3. Install Nginx - 'sudo apt-get install nginx'
  4. Install Git - 'sudo apt-get install git'
  5. Install Node-RED - 'sudo npm install -g nodered'
  6. (Optional) Install Webmin - Instructions Here - This is optional, but I highly recommend for pretty much any headless server.

Notes: I had some trouble installing node-red globally and wound up creating a /web directory then installing node-red there (npm install node-red, without the -g option to install globally) so you may see references to /web in my screenshots where it wouldn't appear in your configuration.

Step 3: Set Up Node-RED

  1. Set Node-RED to start on boot (Instructions here). Because you're using the GPIOs the Node-RED service will need to be run as root for it to work properly. I used the webmin interface under Bootup and Shutdown -> Create a new systemd service.
  2. Install Node-RED DHT Node - 'cd /root/node_modules/node-red' then 'sudo npm install node-red-contrib-dht-sensor'
  3. Install Node-RED Pushover Node - 'cd /root/node_modules/node-red' then 'npm install node-red-node-pushover'
  4. Download or clone my GitHub repository into a temporary directory on the Pi: https://github.com/mindtesterdev/HumidorPi.git
  5. Copy nodes/flows_humidor.json from your temp directory to /root/.node-red
  6. Update the the node red configuration at /root/.node-red/settings.js:
    1. Uncomment the uiHost line to keep Node-Red from listening on anything but localhost. (We're going to use nginx to reverse proxy the admin interface on 80 or 443): uiHost: "127.0.0.1",
    2. Uncomment the flowFile setting and point it to the cloned directory /nodes/flows_humidor.json
    3. Uncomment the httpAdminRoot setting and set it to /admin: httpAdminRoot: '/admin'
    4. Optionally you could password protect the admin interface here using these instructions.

Step 4: Setup NginX

  1. Open /etc/nginx/sites-enabled/default with your favorite text editor
  2. Point the "root" setting to the 'web-interface' directory of your cloned temp directory.
  3. Add the following lines after the first location / {} stanza to set up the Node-RED through the reverse proxy:

    location /api {
    proxy_pass http://localhost:1880;
    }

    location /admin {
    proxy_pass http://localhost:1880;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }

  4. Enable nginx to start on boot by running: 'systemctl enable nginx' on the command line

Notes: I wound up putting my static website folder under /web as well.

Step 5: Configure Node-RED Nodes

Once everything is up and working on the Pi, You'll need to adjust some of the settings in the nodes themselves.

  1. In the "Humidor" tab find the "Pushover" node and double click it to edit.

  2. Update the User key and API token to use one from your Pushover account (https://pushover.net)

  3. In the "Settings" tab find the "settings.json" node and double click it to edit.
  4. Update the file name to point to [your cloned folder path]/web-interface/settings.json. This file specifies the alert/and warning levels which are used to both set set the gauge color on the web interface, and determine when pushover alerts are sent.

Step 6: Test Our Work So Far...

If you've set up node-red as an upstart or systemd service using the instructions to start on boot and run as root, and you've installed and enabled nginx to start at boot and configured everything properly, you should be able to reboot, and access everything via the web interfaces. With no sensors connected you'll get readings of all zeros, but everything should work at this point. You should verify the following:

  1. Going to http://[your-raspi-ip] should show you the guages
  2. Going to http://[your-raspi-ip]/api/reading should show you the raw JSON output of the readings
  3. Going to http://[your-raspi-ip]/admin should show you the Node-RED admin interface
  4. You should get a pushover message (or several) upon restarting the pi.

Step 7: Make a Backup

Shutdown the pi using 'sudo shutdown now' from an ssh connection. A good way to tell if it's shutdown with no monitor is if the green disk activity light is not flashing and has not flashed in over a minute. You can then pull the power from the pi, and make a backup of the sd card to an image file using something like Win32 Disk Imager. Trust me when I say you don't want to have to re-do all this work just because the power went out and your SD card was fragged.

Step 8: Build the Daughter Board

I created this board mainly for convenience, and there's nothing really complicated happening here. Due to size requirements we're only using pins on the 3.3v side of the Raspberry Pi pinout. That's just 2x8pin headers(that were supposed to be stackable, but don't fit next to eachother, so we have to skip a pin) and you can see that I cut the board short at the row for the letter T to fit it horizontally in the case. On the other side, the electrical tape is covering another pin header that I chopped down in height so that it rests on the HDMI port on the Pi. Without this, the board just floats free, and sometimes bends down and makes contact with points on the Pi, which, as you may have guessed, is very bad for the Pi. I mounted a 6 pin header for the DHT sensor, and the Open/Closed sensor with the pins bent 90 degrees to face what becomes the front of our setup (towards the blank side, not the USB ports), and the momentary pushbutton on the top side of the board, and an RGB LED for output, also facing front next to the pin header, and the buzzer on the bottom side of the board. You'll have to play with placement of the buzzer as you probably don't want it resting on the chip. As I mentioned earlier, using only this side of the pinout, you don't have a 5v line, but you may want to find a way to hook into it, and put a transistor between it and the GPIO for the buzzer, as that buzzer is a 5v buzzer and at 3.3 volts it's not loud at all.


IO PINOUT (Super helpful Raspberry Pi pinout website):

  • DHT: Actual Pin 7 - GPIO 7 - BCM 4
  • LID Sensor: Actual Pin 11 - GPIO 0 - BCM 17
  • Button: Actual Pin 11 - GPIO 22 - BCM 6
  • Buzzer: Actual Pin 29 - GPIO 21 - BCM 5
  • RGB LED:
    • Red: Actual Pin 33 - GPIO 23 - BCM 13
    • Green: Actual Pin 15 - GPIO 3 - BCM 22
    • Blue: Actual Pin 13 - GPIO 2 - BCM 27

Step 9: Modify the Raspberry Pi Case

Basically, we're just using a Dremmel tool to modify the case to accomodate the button on top, and the LED and Pin header on the front plate. Measure twice cut once...

Step 10: Modify the Humidor

There may be a way to do this with super thin ribbon cable if you can find the proper connectors so you don't have to cut into an intact humidor, but this way works well too if you can keep it sealed. If you can't you can always go up to the next bigger humidifier. For instance, this humidor is a 100 count, but I have a 250 count humidifier in it, because it's cheap and the seal around the glass leaks even after it's been sealed with tape, and I'm able to keep a pretty steady 70% relative humidity even though I know the humidor isn't fully sealed.

  1. I took 3 pin headers that I had cut down to 4 pins each and stacked them on top of eachother. (Picture shows 6 pins wide, but same setup)
  2. After finding the spot in my humidor where the sensor would go, I pencil traced the pin header on the back of the humidor.
  3. I then cut through as closely to my pencil markings using the carving tool on the Dremel, all the way through to the inside of the humidor so that I would be able to stick the pin header through and have the holes on the inside of the humidor and 4 pins sticking out of the back.
  4. Finally, I covered the holes on the pin headers with electrical tape and filled the gap as much as possible with silicone adhesive to re-seal the humidor with the pinout through it. You may want to use 2 part epoxy first, then silicon, as I've had to re-silicon multiple times due to this setup coming out when adjusting the sensor.
  5. Wait for the adhesive to dry completely.
  6. I bent the pins on the DHT back 90 degrees to make the sensor sit flush with the back of the humidor.
  7. I cut 2 L shapes out of the foil tape and arranged them so that they stuck to the top and bottom lid and the bottoms of the Ls made contact when the lid was closed. I then used another layer of foil tape to tape down the exposed ends of some Dupont cables (Female -> male with the male side cut off and stripped to expose stranded wire inside). It occurred to me after the fact, that you could use 3 straight strips of foil tape, 2 on the body of the humidor, and one on the lid as a bridge between the two and that would make the wiring a bit cleaner.
  8. I then connected the female side of the dupont cable to a 2x pin header and taped it down to the back to make a quick disconnect. As you can see, I wasn't considering that I would attach the pi to the back of the humidor so the disconnect faces the wrong way.
  9. Connect everything to the pin header on the Pi. I just used Dupont cables that I had laying around. Later, I made that 4x wide hookup for the DHT connection using a dupont cable and a 4x pin header, and some electrical tape. Be careful not to reverse the DHT sensor's polarity as these sensors burn out easily when connected the wrong way.
  10. Sometime much later, I attached the finished pi to the back of the humidor with some Command strips.

Step 11: Power Up and Test

With everything connected and in the humidor, do a final test and make sure you're getting good readings from the DHT sensor to the web interface. If everything is working, you're done. You should now season the humidor as normal (Remove all the connections, and the DHT sensor before doing a wipe down of the interior).

Step 12: Optional Stuff

Here are a couple of things that I've done with this setup that you can do if you've got the spare hardware. Admittedly, my network more advanced than most, but maybe not most makers...

  • If you've got a DNS server on your network, you could make your life easier by setting a static IP on the pi and pointing an A record at it. You'll notice in my screenshots mine is set up this way, and my humidor is accessible as https://humidor.sensor on my network.
  • If you're really serious about monitoring your cigars, you can use Elasticsearch and Kibana or something similar to capture readings periodically and graph them over time. This should be done from a seperate server as you probably won't have enough power on the pi to run an elasticsearch server.

  • If you're thinking of exposing the humidor's web interface to the internet, configure NginX to serve the page with SSL. I used an internal certificate from the CA on my router, but you could also use letsencrypt to get a free ssl certificate.

Step 13: A Word About Security

First and foremost, as with any other IoT solution you should very carefully consider security before exposing any interface to the internet. A Raspberry pi is a full computer and can wreak havoc on your network if compromised. Considering that we are running Node-RED as the root account, someone who breaks in to the admin interface to Node-RED has full access to the pi, and all the access it has to your internal network to scan and try to break into other machines. My advice to anyone who doesn't have a very high level understanding of network security is simply to not expose the pi to the internet at all, and simply enjoy it inside your own network. For my personal setup, the humidor is not exposed to the internet, and I get remote access via a VPN connection. If you need the data outside of your network, the better option is to have the pi reach out and post it on an interval to another service, such as the IFTTT maker channel.

If you do decide to expose this to the internet:

  • Make sure you have configured node-red to require a strong password to perform administration functions.
  • Make sure you have NginX configured to serve the web interface via https, and are only exposing the https port to the internet.
  • Make sure sure you are not using the default password for the pi account on the raspberry pi, and that it has a strong password.
  • Keep the software on the pi up to date and fully patched at all times.
<p>where do we get a current plan for the daughter board?</p>
<p>Since there's really nothing to it, I didn't think it necessary to provide a diagram. In step 8 there is a labeled hi-res image of both sides of the board.</p>
<p>Very, very nice. I want to do this now for my own stogies. Thank you</p>
Thanks!
<p>How do you do the humidor.sensor part? </p><blockquote>&quot;If you've got a DNS server on your network, you could make your life easier by setting a static IP on the pi and pointing an A record at it. You'll notice in my screenshots mine is set up this way, and my humidor is accessible as <a href="https://humidor.sensor/" rel="nofollow">https://humidor.sensor </a>on my network.&quot;</blockquote><p>again, how do you do the humidor.sensor part? how do i make that setup on my network?</p><p>nothing specific about the sensor or anything, just assuming i have my own server on the raspberry pi (or any other machine on the network). i can access that server from that machine via <a href="http://localhost/" rel="nofollow"> http://localhost/ </a>, or from any other device on the same network using the IP address of the device on the network.</p><p>what if i want to access the device using a name (like raspberrypi.local or humidor.sensor), not an IP? how to do this? how is this thing done on a local network?</p>
<p>You'd need a computer running a DNS server running on your network. Some higher end routers will do it, or you could build your own router with something like pfsense. I demote my desktops in order, so 3 computers ago is now my router, and 2 computers ago is my main server that runs NAS, DNS, some internal websites like the ElasticSearch/Kibana service that gathers and displays the history of my humidor's readings. Basically, any linux box running Bind can be the internal DNS server for your network, so instead of using your ISP's DNS server from all your local computers, you make your DNS server the server under the DNS settings in your router and on each of your local computers not getting DHCP configurations, then have that query your ISP or whatever your preferred DNS provider is. Once you've got that set up you can add custom zones. For instance, I have a .sensor zone that has the humidor.sensor entry you see in my screenshots. </p>
<p>Ok assume that i have a USB Wi-Fi module on my raspberry pi that i'll be using as a hotspot. so in that case, no internet, no ISP, no ISP DNS.</p><blockquote>Basically, any linux box running Bind can be the internal DNS server for your network<br></blockquote><p>so, i guess that means i'll have to see how to configure Bind on the PI?</p>
<p>So, if you're creating a standalone network that will have no connection to the internet, and using the pi as the router / hotspot for that network, the easiest way to configure everything would be through <a href="http://www.webmin.com/">webmin</a>. If you install webmin on your pi and access the pi's IP address via 10000 you should be able to figure out how to add DNS, DHCP, Firewall, Routing, and most other network services to it relatively easily. If you go into &quot;unused modules&quot; and find Bind DNS Server, and click the link it will tell you bind is not installed, and you can click to install it, then you get a really nice interface to manage your local DNS zones. </p>
<p>Ok, then i'll install the webmin and see how it goes. Thanks a lot for your quick response.</p>

About This Instructable

6,508views

93favorites

License:

Bio: I'm a software developer and DBA by trade, just digging into electronics for the first time. I'm also a private pilot and skill ... More »
More by mindtesterdev:HumidorPi: A Smart Humidor On The Cheap with Raspberry Pi and Node-RED Built-in Hackduino (Arduino) Ultrasonic Parking Guide 
Add instructable to: