Introduction: HVAC for Root Cellar
- This is a device to monitor temperature and humidity in a two room cold cellar. It also controls two fans in each room which circulate air from outside into each room, and communicates with a smart switch in each room connected to an ultrasonic mister. The aim is to control the temperature and humidity in the room, ideally to maintain the temperature below 5C and humidity about 90%.
The device uses an ESP8266 microcontroller to read the temperature and humidity sensors, to drive the fans, and to present the information over the local network in a web page.
This instructable will not get into exact detail because:
- I forgot to take pictures as I built it, and it is installed at the client's house now!
- Your situation will be different. This is meant as a reference design, not to be exactly duplicated.
The parts I used are:
- NodeMCU 1.0 ESP8266 microcontroller. Any ESP8266 will work, as long as it has enough free digital input and output pins for your design. It is not trivial to figure out how many pins ARE free, some are exposed, but used during booting or serial transmission.
- prototyping board
- wires, connectors
- female header socket to hold ESP8266 and make sensor connectors
- DHT22 temperature and humidity sensors
- DS18B20 temperature sensor for outside use
- deconstructed CAT5 cabling for sensor wiring
- 690 ohm resistors to limit FET gate current
- 10K resistors to pullup DHT22 data line
- 2.2K resistor to pull up DS18B20 data line
- IRLU024NPBF HEXFET power drivers
- San Ace 80 48VDC fans
- MeanWell 48VDC 75 watt power supply to power fans
- cannibalized 5v phone charger to power ESP8266 and sensors
- miscellaneous diodes across fan to prevent back EMF (maybe P6KE6 TVS?)
If you would like additional links to any of these, comment and I will add them.
Step 1: Construction - Microcontroller and Sensor Wiring
The circuit is constructed on prototyping board, following techniques similar to these.
- Layout the components on the prototyping board to allow easy wiring in the next step. I did not leave enough space around the MOSFET drivers, and the wiring got a bit tight.
- Solder the female headers into place, by plugging them onto the NodeMCU as a jig to get a few pins tacked down. Then remove the NodeMCU and finish all pins. I only used sockets on the pins which are used for power and input/output. This helped ensure the device was plugged in with the right orientation each time.
- Solder a male connector to the 5VDC power supply.
- Solder a matching female connector to the board near the ESP8266 Vin and ground pins, and then solder thin hookup wire between connector 5VDC and ground to the matching socket pins. Consider placing this connector so that it is in the way of the USB port of the NodeMCU. You do NOT want to power the NodeMCU from this power supply and USB at the same time. If you put the connector in an inconvenient location, it will be harder for you to accidentally do this.
- Solder 3 pin male headers near the ESP8266 D1, D2 and D3 pins. Leave plenty of room for the pullup resistors and all hookup wire.
- Construct matching connectors from female headers for the sensor hookups. I used 4 pin lengths, with one pin removed to make the sensors keyed so they could be connected incorrectly. I put the 3.3V supply and ground on pin 1 and 4 of each connector, and data on pin 2. It would be better to put 3.3V and ground beside each other and data on pin 4, so if a sensor was connected backwards, no damage would be done.
- Solder the pullup resistors between 3.3V and data lines for each sensor. The DHT22 uses a 10K pullup, and the DS18B20 (at 3.3V) likes a 2.2K pullup.
- Solder hookup wire between the ground pins of each connector and to a ground pin of the NodeMCU socket.
- Solder hookup wire between the 3.3V pins of each connector and 3.3 pin of the NodeMCU.
- Solder hookup wire from the data pin of one DHT22 connector to pin D1 of the NodeMCU socket
- Solder hookup wire from the data pin of the other DHT22 connector to pin D2 of the socket
- Solder hookup wire from the data pin of the DS18B20 connector to pin D3.
- Measure from the planned sensor installation locations to where the device will be.
- Construct wiring harnesses of suitable length. I do this by taking apart a length of CAT 5 ethernet cable, the putting 3 of the wires in the chuck of a drill and twisting them together. This gives the new sensor cable some mechanical strength against getting kinked and a wire breaking.
- Solder the sensor on one end of the wire, and a female header on the other. Be careful with the pin assignment. Also put some strain relief on each end, for example silicon caulking, epoxy or hot glue. Silicon caulking is probably best - hot glue can actually soak up humidity, and epoxy might get into the connector.
Step 2: Construction - Fan Drivers
This design uses 48 volt fans for two reasons:
- they were available, and seemed to be higher quality / more efficient than the more usual 12V fans in our junk pile
- they use less current than lower voltage fans, so wires can be skinnier
Lower voltage fans may be a better choice in your design.
This section goes into quite a bit of detail on constructing the driving circuit using a 3 volt digital output from the NodeMCU to power a 48 volt fan. Other than the software, this section is the most unique part of the device. You might benefit from building the circuit on a breadboard at first.
- Moving over to the other side of the NodeMCU socket, determine a location for the incoming 48V power connector. It should be adjacent to where the power supply will be mounted and a ground rail on the prototyping board. Don't solder into place yet.
- Examine the schematic above to understand how you will be connecting all these components.
- Place the four 690 ohm resistors close to pins D5, D6, D7 and D8. Don't solder them down yet.
- Place the four transistors into the prototyping board.
- Place the four clamping diodes into the prototyping board. For each diode align the anode with the drain of the transistor, and the cathode so a wire from it will have a clear path to the 48V power rail.
- Four connectors for the fans, the positive (+) connector to the 48V rail and the negative (-) to the source of the FET and the diode anode
- Now adjust all those locations until everything is well placed and there is room to run all hookup wires.
- Solder the first of four driver circuits into place. It's OK if the others fall out as you flip the board around. The next steps are focused on one of the driving circuits. Once it is functional, you can move onto the others.
- Using hookup wire or the leads of the components, solder one fan driver circuit:
- one end of the gate current limiting resistor to pins D5 of the Node MCU
- the other end of the resistor to the gate of the FET
- the drain of the FET to ground
- the source of the FET to the anode of the diode and the negative of the fan connector
- NOT zero resistance between the 3 pins of the FET
- NOT zero resistance across the fan connector from negative to positive, and zero resistance from positive to negative showing the diode is working.
- Open circuit from each FET pin to 48V
Step 3: Program NodeMCU and Initial Configuration
- Download the attached Sketch files into a new Arduino project, compile and load into the NodeMCU.
- Do NOT power the NodeMCU from the board. Disconnect the 5V supply from the prototyping board.
- Disconnect 48V from the main board.
- Plug the NodeMCU into the socket, connect your USB cable, and flash the NodeMCU
- Open the Arduino serial monitor at 115200 baud.
- Using a smart phone, laptop or tablet, connect to the RootCellarMon network which should appear as the NodeMCU acts as a wi-fi access point. Password is "opensesame". I'm using the nifty IOTWebConf library to allow configuration of your network's SSID and password.
- Then using a web browser on your device, navigate to http:192.168.4.1. You should see a page as shown above but with errors from the sensors. Click on the Configuration link at the bottom.
- Work through the configuration screen to set your network parameters SSID and password, then click APPLY. Reconnect to your normal wi-fi network. You should see something like this on the Arduino serial monitor:
Password was not set in configuration State changing from: 0 to 1 Setting up AP: RootCellarMon With default password: <hidden> AP IP address: 192.168.4.1 State changed from: 0 to 1 Connection to AP. Disconnected from AP. Request for <your browser identification> redirected to 192.168.4.1 Requested non-existing page '/favicon.ico' arguments(GET):0 Configuration page requested. Rendering 'iwcThingName' with value: RootCellarMon Rendering 'iwcApPassword' with value: <hidden> Rendering 'iwcWifiSsid' with value: your SSID Rendering 'iwcWifiPassword' with value: <hidden> Rendering 'iwcApTimeout' with value: 30 Rendering 'tasmota1' with value: Rendering 'tasmota2' with value: Rendering separator Rendering separator Validating form. Updating configuration Value of arg 'iwcThingName' is:RootCellarMon iwcThingName='RootCellarMon' Value of arg 'iwcApPassword' is:opensesame iwcApPassword was set Value of arg 'iwcWifiSsid' is:your SSID iwcWifiSsid='nizkiyRoad' Value of arg 'iwcWifiPassword' is:your wi-fi password iwcWifiPassword was set Value of arg 'iwcApTimeout' is:30 iwcApTimeout='30' Value of arg 'tasmota1' is: tasmota1='' Value of arg 'tasmota2' is: tasmota2='' Saving config 'iwcThingName'= 'RootCellarMon' Saving config 'iwcApPassword'= <hidden> Saving config 'iwcWifiSsid'= 'your SSID' Saving config 'iwcWifiPassword'= <hidden> Saving config 'iwcApTimeout'= '30' Saving config 'tasmota1'= '' Saving config 'tasmota2'= '' Configuration was updated. State changing from: 1 to 3 Connecting to [your SSID] (password is hidden) State changed from: 1 to 3 WiFi connected IP address: 192.168.0.155 State changing from: 3 to 4 Accepting connection State changed from: 3 to 4
- Make note of the IP address assigned to your device. Above, it is 192.168.0.155.
- Reconnect your laptop/tablet/phone to your normal network if it hasn't already.
- Browse to the new address of the device, 192.168.1.155 in my case. You should see the main page again.
Step 4: Connecting It All Together
- Disconnect the USB cable.
- Connect 5 volt power. And refresh the web page. You should see the heartbeat incrementing regularly.
- The LED on the ESP8266 should flash every 5 seconds as it reads the sensors.
- Connect the sensors, and you should start getting readings. Originally I had a DHT22 outside, but found it unreliable, so switched to the simpler and better protected DS18B20.
- If you have issues with readings, you can disconnect 5V power, power the NodeMCU with USB, and load example sketches for each sensor to troubleshoot the issue. It's almost always a bad wire.
- Connect 48V power and the fans. Click on the fan control buttons.
- Build two Tasmota-based smart switches. I used Sonoff Basic switches. There are tutorials on how to flash them with Tasmota elsewhere, including arendst's own page.
- Consult your router's client list, and identify the IP addresses assigned to each smart switch. Set these addresses as reserved, so that the switches always get the same address.
- Try controlling the smart switches directly, for example
Step 5: Installation
I mounted the parts of the device on a small piece of plywood, with the lid of a plastic food container in between the plywood and the lid. This arrangement was screwed to the wall of the root cellar. Because the lid is off the wall a bit, the body of the food container can easily be snapped on to provide a protective case. All the cabling is routed through the fixed lid to the circuit board.
The sensors and fan wiring were fastened to the walls loosely, as future work is planned in the root cellar - possibly plastered walls and additional shelving.
Step 6: Summary
This is an experiment, so we don't know which parts of the system will prove out in the end.
Some first notes on how to make success easier:
- The fans maybe unnecessary. Natural convection may be sufficient. The intake and exhaust vents are placed near the floor and ceiling respectively, so that hot air is exhausted and cold air brought in.
- Make sure wi-fi is OK in the root cellar before starting the project. In our case, we needed to install a wifi extender in the room above the root cellar.
- If wi-fi is not good, a wired or different radio frequency design might be required.
- Paint the board the components are mounted on, or use plastic or something less affected by humidity.
- Four fans running consume about 60 watts, the power supply is likely 80% efficient at least. So heating inside the case is at most 20% * 60 or 12 watts. Overheating shouldn't be a problem, especially in a cold root cellar. If your case is more airtight, you might want to drill some ventilation holes.
- There are projects which add environmental sensors to Tasmota-based smart plugs. One of those might be a good alternative for this application.