Arduino-controlled home network closet temperature logging and exhaust fan.
About a week ago I lost internet. For some people, this is a daily occurrence. For me, not so much. I went to try the usual unplug-everything-and-plug-it-back-in procedure, and found two things:1. My router was stuck in bootloader mode for no apparent reason, and2. My closet I keep my server, modem, router, and other network gear in was warm. Really, really warm.After leaving the door open and router unplugged for a little while, it started functioning again. This weird bootloader issue has happened once before, but I never realized it might be the heat causing it. With concerns for my router's longevity and my electricity bill having a very hot closet adjacent to several air-conditioned rooms and transferring what I assumed was more than a tiny amount of heat through the (uninsulated) walls, I embarked on this project.I had three objectives: to ventilate the hot air out, to not exhaust more air than necessary (since some of the supply air would be coming from my A/C, which isn't cheap,) and to be able to see and log the temperature as well, so that I could make sure that my equipment would no longer get too hot, and keep track of how fast the room heated up/cooled down.I had some TMP36's lying around from a previous project, they're great little versatile analog temperature monitors. A bit of example code later, and I verified that my sensor worked and that this would work great for what I needed. I also found out that if I tied the 3.3v coming out of the arduino to AREF and then told the arduino to use this for an external reference, it could help make the temperature sensor more accurate and (I think) less prone to noise. This was a good thing, as we'll see later.I used some CAT6 I had lying around to give the TMP36 some mobility, and drilled a hole in the ceiling of my closet to check what temperatures looked like over the course of a few days. If you want to see all the gory details, you can check it out here. The serial data was captured with RealTerm, which is a very capable serial terminal. I knew it was hot, but after figuring out just how hot, I wasn't comfortable leaving it as it was any longer and left the door open to keep things cool until I finished the project.One hole saw and some duct-tape later (there was a poorly-done patch in the ceiling that came apart when I was drilling) I had myself a ventilation hole. Here's a shot of the TMP sensor, and fan (as well as the USB cable from the arduino in the attic that is reporting temps back to my server.) (It's in a closet. It doesn't have to be pretty, it just has to work.)Testing it all out went well, so after using some gap-filling liquid nails to both glue the fan in place as well as make sure it was sealed, I checked my code and looked at the serial data coming in:94.5694.5694.5694.5694.5695.14fan_turned_on93.4093.4093.4093.4092.8292.8292.2491.6691.6691.6691.0890.5090.5090.5089.92fan_turned_off91.6691.6691.6691.6691.6691.6692.2492.8292.8292.8292.8292.8293.4093.4093.4093.4093.9893.4093.4093.9893.9893.9893.9893.9893.9893.9893.9893.9893.9893.9893.9894.5693.9894.5694.5693.9894.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5694.5695.14fan_turned_on93.4093.4092.8293.4092.8292.8292.8292.2491.0891.0890.5089.92fan_turned_off91.0890.5091.0891.0891.0891.6692.2492.2492.2492.8292.8292.8293.4093.4093.40It is so awesome to see the results of your work there in black and white. It works great, and keeps things exactly between 90f and 95f now. I threw a reducer duct with a large dryer vent attached in the attic: This will hopefully allow for a bit of a chimney effect to keep hot attic air from moving back into the house through the closet, as well as to get what might be hotter air (at night or in winter) away from places that it might recycle into the room. I sealed that off with liquid nails again, and everything seems to be working.Last shot of the arduino in the attic that drives it all: Final notes:The fan is driven with a solid-state relay.The extensions from the arduino are all repurposed CAT6 and powered off a USB port.I may in the future try to add a flap to the end of the duct to make it so air can only flow one way, but I don't think it's necessary.I have my code turn the fan on at 95 and off at 90 because otherwise the fan is constantly on/off/on/off. It's not loud, but it may be mildly noticeable during a movie or something like that. I can also PWM it if I don't want it full speed.I read the TMP36 1,000 times in my code and average it. Why? Because it still only take 1/2 second and it makes the values read in rock solid.Uncommented arduino code here.The ATMEGA328 is spec'd to be able to go up to 185f max, so it shouldn't have a problem in my attic. I'm powering it off USB so it doesn't have to use the 5v regulator which would get hot and might have issues.My router is now happy.Here's the temperature log over three days before. Note how it gets a little hotter during the days. The large dip at the beginning is when I had the door open. The small dip at the end is opening it briefly.Here it is now over about half an hour. Note that it's perfectly held in the range I want: