Hi, Im using a nano to control x4 PC fans to turn on if between 26-28 degreesC. The temp sensor is a DS18B20. All works perfectly and has been for some time. However, I do get a lot of condensation on the fans when they're not on.
So, the way this works is...
Aquarium heater turns on at 25C and auto turns off at 25.7C. If the temp reaches 26C, the nano maps between 26 and 28C respectively. So during the winter months the fans never turn on creating condensation. Im worried they will get damaged as they're not cheep.
Ive put a code in setup so I can hit the reset button on the nano manually to spin the fans dry.
I have a DS1307. My thought is to have a time set each day for the fans to purge for 10 seconds. Ive googled how to use the date/time and its very overwhelming.
My question is, as the temp sensor has a delay, how would I write in the code if time is in a 2 or maybe 3 second window? I hope Ive made sense. please excuse my ignorance. Im generally new to coding. I will post the code below along with the circuit diagram.
Would a humidity sensor work to indicate when to turn the fans on?
Take a look at my "pet feeder" simulation. It starts by setting two "feed" times, then waits for the feed time, then moves a servo. Very similar to your project. Most of it is comments and printing to the LCD. Very little is time keeping.
Cheat: Turn the fans on for a short time after you turn the heaters off and again when you turn them on. There are a lot of examples of RTC (Real Time Clock) programs posted that you could use parts of.
No. That wouldn't work because the humidity would be quite high. It would constantly purge until there is no humidity in the tank. Could take an hr to do that. I just need the fans to spin for 10secs every 24hrs to remove the water from possibly getting inside the fans and causing electrical corrosion.
nice touch.
I knew the setup part was on the ugly side
Thanks for fixing that.
The only thing that might frustrate me is that if I have a power out millis() will reset to when the nano turns back on. So it may digitalwrite HIGH all hrs of the night. Which isnt really a bad thing. I was just hoping for some time consistancy.
I def give this a crack tho. Legend!!!!!
It's calculating 24 hours in milliseconds. That's a big number, too large for an int to hold on many common types of Arduino. On most types of arduino, int can only hold numbers in the range -32,000 to +32,000 approximately. So here we must use an unsigned long type, which can hold much larger numbers. The "UL" forces the value to be an unsigned long, otherwise it will be calculated as an int and would overflow.