Hello, I'm trying to make a simple program to act as a defrost controller for a dehydrator cabinet I built to remove moisture from 3d printer filament. The device consist of a peltier cooler with a fan-less heatsink for the cold side, designed to develop frost on it to remove moisture from the air the same way a freezer would, while only slightly changing the temperature inside the cabinet. Allowing the heatsink to frost up creates lower humidity inside the chamber than a traditional dehumidifier. I need to make a program that senses how long the humidistat has been sending 12 volts to the peltier and do 1 of two possible task.
Task 1: If the humidistat has been calling for drying for more than 1 hour, the arduino needs to send power to relay 1 to disconnect power to the peltier for 5 minutes to allow the heatsink to defrost, then turn off relay 1, and turn on relay 2 for 2 minutes to allow a solenoid valve to drain the drip tray.
Task 2: If 12 volts is lost from the humidistat before 1 hour is up, the arduino needs to wait 5 minutes, then turn on relay 2 for two minutes to drain the drip tray, then reset the 1 hour timer when 12 volts from the humidistat turns back on.
I'm brand new to writing code, so any help is much appreciated.
Use the millis() function to keep track of time, to time events and make decisions. Keep in mind that all variables associated with millis() and micros() should be declared unsigned long.
Examples are given in the Arduino IDE and on line. Avoid using delay().
Use "every" library, it's just millis() but code will be shorter and easier to read
The easiest way to detect if power is send to peltier is to make voltage divider, add current limit resistor and use analog pin.
Then u should print results using serial monitor and see how long/in what cycles peltier is being powered. If it's on for hour without any turning off then it should be easy. If u will come back with result i could help find a way to detect it
Don't use mechanical switches, use mosfets instead. U can buy 'High-Power Dual MOSFET Switch Module'. It's cheaper, it's way more efficient (so it stays cool), it's silent, it will last years and it can be powered directly from arduino pins.
// Mechanical switches are obselete, they are worth checking only in very high current demanding scenarios
U should use flyback diode (1N4007) on solenoid valve (and mechanical switches if u would use them instead of mosfets)
Cables that u will put into mosfet board should have 'Ferrule Terminal Cord Pin End Terminal'. Otherwise over time cable will lose connection and will produce sparks (fire hazard). U don't need special crimping tool, cheap ones are even worse then pliers
For task1 u need switch that is 'normally open'. These mosfets are normally closed (u need give them at least 3,3V to close circuit), so u need to turn them on at the start of code.
It also mean that this cabinet will not work without arduino powered on. It would be easy to back to old state tho, u would need only to plug in +12V (from peltier line) to signal IN on mosfet board.
If cabinet uses DC charger (if there is big brick between cabinet and wall socket) and then u can power arduino with it (using step down converter). If 120/230V AC goes into box don't touch it.
If project will work correctly, don't use jump wires in final project. They disconnect very easily. Make perfboard for arduino and solder cables to it or just solder cables directly to arduino pins (u don't need many cables so it shouldn't be hard for u do, but it could lead to problems if u can't move cabinet near pc to upload new code)
Sorry for my broken english, i hope i helped a little
The moisture falls into a drip tray, then drains into a tank outside the chamber with the help of a solenoid valve which I use to keep the chamber sealed when not draining.