“Is that just a webcam pointed at an LCD display?” Well yes, it is. But we’re getting ahead of ourselves.
Note that all of this is taking place in an unfinished shed – so the numbers you see will not be typical of fruiting chambers.
So we’d all like to be able to check on our mushrooms as often as we’d like. I was insulating the shed in preparation for growing mushrooms and was getting sick of having to walk out there in the rain to see how the heat retention was doing. I already had an Arduino-based temperature and humidity display rigged up from a couple years ago, so I just got a Raspberry Pi 2, shoved a USB wifi adapter in it, and hooked up the camera. Pretty low-tech and arguably the worst possible way to do it.
The temperature controller hadn’t arrived yet, so it was all pretty approximate anyways, but it was nice to be able to check on it. I was powering the Arudino board (a Mega2560) from the Pi’s USB ports, since it was convenient, but of course, these boards also do serial communication over USB, which is what we’ll end up doing.
The problem we run into is that a decent number of temperature and humidity sensors either use their own protocols with extremely weird timing, or are analog. An Arduino is a lot better at dealing with this than a Pi is. Even with the lowest possible level hardware access, a Pi will fail to read a DHT22 about 25% of the time.
So the basic concept is that the Arduino board reads sensor data, discards invalid data, cleans it up a bit, then feeds it to the Pi over the USB serial connection. From there, well, I can log it, put it up on a web server, pretty much whatever, really.
We’ll get to the code at the end, but so far in this project I’ve used:
- an Arduino Mega2560 board (an Uno would work fine)
- a DHT22 temperature/humidity sensor
- a Raspberry Pi 2 with a wifi adapter (a Pi 3 would work, and has onboard wifi)
- an analog flame sensor for the Arduino (I’m running a heater unattended, I’m paranoid)
And also of course various wires and USB power adapters and such (AmazonBasics 12W adapter for the Pi.) Al
You could also use an Arduino-style board with onboard wifi (Photon Redboard, various ESP8266-based boards, etc.) I did it this way because the wifi signal in the shed is questionable at best and I didn’t want to rely on a low power solution.
The Arduino board is powered via USB from the Raspberry Pi, and basically its job is to make the sensor readings make enough sense to be useful. We’ll get into the software in the next post, but the hardware is basically set up as follows.
The DHT22 sensor (also known as an AM2302, same thing) is connected to a GPIO pin for power (it’s very low power), and a digital input. Adafruit’s DHT22 library is being used to read data from it. The flame sensor is being powered from the 3.3 volt rail and outputs into analog input 0.
You may notice it’s not controlling anything. This is on purpose. I don’t trust DIY stuff to not burn the place down if I let it control a heater or something. You can totally add it, but that’s between you and your insurance provider. If you do have it control something, don’t forget to make it fail SAFE. This means that if it has an error or loses power, the heater turns OFF, as opposed to getting stuck in the on position. Controlling 110V appliances with logic-level signals is a bit beyond the scope of this post, though.
Once this is done, you should be able to check on your mushrooms from anywhere you have an internet connection. In the next post, we’ll take a look at the software!