Close
0%
0%

Boat Ventilator Control

Controlling a fan and protecting the battery on my boat on the cheap; using an ATTiny85 and a DHT11 temperature and humidity sensor

Similar projects worth following
A Small controller based on a Digispark ATTiny controller I had on my shelf and a spare DHT11 combined temperature and humidity sensor.
The controller turns a vent fan On and Off (and several speeds in between) depending on the temperature, humidity, user input and battery voltage.
The unit goes to a very low power mode when the battery is low to prevent it from deep discharging the battery.

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. 

Hardware 

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.

Software

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.

Operation...

Read more »

Zip Archive - 2.38 MB - 07/03/2020 at 16:41

Download

gzip - 2.37 MB - 07/03/2020 at 16:41

Download

JPEG Image - 587.32 kB - 07/03/2020 at 16:41

Preview
Download

  • 1 × DigiSpark ATMega85 devboard on a USB plug. Typically a clone..
  • 1 × DHT11 Cheap-ass Temperature and Humidity sensor
  • 1 × NPN signal level Mosfet eg IRLZ14, IRL520, or similar. Big enough to switch the fan you use even when stalled or starting.
  • 2 × Diode 1N4007 reverse voltage and flyback protection
  • 4 × Resistors for the voltage detector divider, and the mosfet drive.

View all 6 components

  • Working Well

    Owen07/03/2020 at 16:46 0 comments

    I've had this in place for a week or two now, it's working well. I updated to the new (sleep mode) release yesterday and so far, so good (I have a breadboard version at home that has had a bit more testing).

    I'm publishing this now and will see how it works over the rest of the season.

    I may return to it since the PCB is not brilliantly laid out, and I'd like to reduce power even further by powering the DHT11 off of one of the ATtiny's unused digital pins.

  • PCB design updated, flyback diode!

    Owen06/22/2020 at 16:56 0 comments

    I kind of forgot a flyback diode when designing this, I did remember and the Unit I built has a 1N4007 soldered underneath across the +Ve and Fan terminals of the power connector.

    I wanted to integrate it into the design, and I needed to fix a path probelem with the KiKad libraries for the sensor and DigiSpark, so I sat down and did a minor update on the PCB design. I dont intend to make this, but it looks fine. Also.: all the resistors are now flat on the board, they interfered with the case before.

    I updated the schematic to add some notes and correct a badly labelled pin.

  • Post install refresh

    Owen06/18/2020 at 14:37 0 comments

    So, this is now installed and running in my boat

    And I have spent some time refactoring the archive, and updating the documentation/readme's 

    It's still not perfect, but should be easier to navigate and understand.

    I will come back to this later since I still want to use an interrupt/timer for the primary sleep loop. Currently I just use a delay(), in idle mode the Digispark is only drawing a couple of mA.

  • Finished

    Owen06/17/2020 at 16:52 0 comments

    I had a sudden burst of enthusiasm and finished this. I will be installing and testing this later. today The github repo needs some love etc.

  • Testing: Virtual DHT11 (emulator); perfect!

    Owen09/30/2019 at 14:36 0 comments

    From here:

    https://forum.arduino.cc/index.php?topic=248576.0

    Looks like this could solve a lot of testing headaches. If it works on my Uno.

    I might extend it so I can simply pass values via the serial interface.

  • Interrupts

    Owen09/30/2019 at 14:22 0 comments

    I had time recently to look at the Interrupt routines I want to use; got a couple of ATTiny examples working, one for timer and the other for a pin interrupt.

    I will use sleep mode for the times between readings, but one of the relatively hight power modes that leave the PWM running. I might investigate using super low power mode for battery low conditions, in these modes even the PWM is off, but if the fan is running I need to limit sleep mode to one of the mid states.

  • What Nu!!

    Owen09/18/2019 at 19:54 0 comments

    I now need to define the main control loop; and implement it.

    • One reading every 30S and then decide how to set fan.
    • Power Control
      • Vmin->11.8V : Powersave mode; no activity, wake every 30s to take and process a voltage reading. Ignore button
      • 11.8->12.6V : Low Power Mode(s); start running the fan; limit max speed. respect quiet/off overrides
      • 12.6->Vmax : Full power mode. respect quiet/off overrides
    • Fan Control
      • Need to think about this
    • User Control
      • Off/Quiet/Idle
    • Average readings; discard outliers
    • Testing will be tricky.. I'll need to 'fake it' somehow for the humidity/temp readings.
    • I'd like to use interrupts and have the controller sleep between readings/decisions.

View all 7 project logs

Enjoy this project?

Share

Discussions

Owen wrote 09/18/2019 at 19:29 point

Comfort and condensation control. This is actually an Input fan, not an extractor, though it does blow into the bilge area.

She's a 6m sailboat with a small cabin and electric motor, no gas fears with her, though 'Clancy is correct; bilge vents can be a really good idea if you have flammable fuels about, and are mandatory in lots of houseboats etc.

  Are you sure? yes | no

Dan Maloney wrote 09/18/2019 at 15:21 point

Is the fan just a comfort fan? Or is it for bilge ventilation? Just asking because I once read a Tom Clancy story where he made a point of the need for bilge ventilation before starting the engines in some boats. In which case I'd imagine a gas sensor would be a nice addition.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates