Humidity and Temperature sensing fan controller for a small boat, with battery protector.
My boat can get quite hot, suffers from condensation, and a permanent fan kept on flattening the battery.
I have built a small controller based on a Digispark ATTiny85 development board I have lying around and a spare DHT11 combined temperature and humidity sensor. It turns the ventilator fan on and off (and several speeds in between) depending on the temperature, humidity, user input and battery state (voltage).
- DigiSpark Based
- ATtiny85, plenty powerful enough for this application, and with a robust toolchain. It has 6 IO pins & very little extra cruft
- Has a onboard 5v regulator, I can supply it with the battery voltage, and then power the DHT11 from the 5v line
- Somewhat tricky to flash/develop for, Lack of a uart is a total pain during debug since BitBang serial emulators eat half the memory+
- DHT11 Temperature and Humidity sensor
- Not the best sensor, something more accurate would be prefered, but this is what I have
- A DHT22 would be an easy (plug and go) upgrade
- PWM fan control via a high-current logic-level NPN mosfet
- I have a quiet but powerful (Noctuna) 12V PC case fan to run from this
- Battery voltage sensing for powersave and shutdown. My boat has a good battery and solar charging system, but the battery can still get low during use and late season.
- A button.. to allow on/off/quiet overrides, my bunk is 50cm from the fan and a quiet mode seems like a really good idea.
KiKad project files, Gerber files and the Case design files are all in this repository.
The circuit is very simple, there is a logic-level mosfet to drive the fan. I used a IRLZ14 for this but almost any logic-level mosfet will do, just make sure it can handle the startup current of your fan.
If your fan is powerful you may need to add a heatsink to the mosfet and make sure heat from it does not affect the sensor.
The Digispark incorporates a 5V voltage regulator (LM7805), which only powers the ATTiny and the DHT11 sensor, the absolute maximum voltage this can handle is 35V, Digistump themselves recommend a maximum of 16V for the module. Please be careful when disconnecting batteries on boats with solar/fixed charging systems, you may be able to spike the supply voltage enough to damage the controller.
However; it is reasonably robust and may even work for a 24v systems, but no promises, and you will need to change the thresholds in the code ;-)
Here are some picture of my buildup; at this stage I had, ahem, forgotten to put a flyback diode in parallel to the fan. This could be a very bad idea if a high wind decides to spin the fan very fast. It is not visible in my pictures but I added a 1N4007 diode to the underside between the pins of the connector. The revised PCB now has this flyback diode onboard.
See the `BoatFanControl.ino` sketch in the `Software` folder. There are a number of other sketches in there that I used during development, you may find the `*Calibrate` scripts useful to verify your sensors and voltage divider.
The DigiStump boards definitions are installed by adding `http://digistump.com/package_digistump_index.json` to the Boards URL list in the preferences dialog of the IDE. In the IDE.
Select `boards -> Digistump AVR boards -> Digispark (16MHz, no USB)` for programming. The 'No USB' refers to clock speed alignment and is advised to keep the clock stable when not plugged into a USB port.
Please read the notes at the top of the main sketch, by default the Digispark runs the fan at 500Hz, this is possibly audible and might affect fan lifespan (the jury is out, I've seen people arguing both sides quite convincingly). In any case I decided to pump the fan PWM frequency up as high as possible. But this requires modifying a file in the Digispark boards folder, proper details and URL's for reference are in the sketch header.