As any fule kno, the only project documentation worth looking at is that created contemporaneously - 'after-the-fact' documentation is notoriously incomplete and inadequate. With no further ado, here's my 'after-the-fact' documentation of this project (in case it helps anyone to build their own thing)...
I wanted to inject some 'home automation' into a couple of previous projects (PV+LED-based 'Fake' Skylight and Solar-Powered Attic-to-Basement Fan, plus another, undocumented, project that moves surplus warm air from our lounge to our bedrooms). Specifically, I wanted to use temperature measurements to switch on/off the various lights and fans.
The complexities of this project include:
- Switching multiple power sources: 20W PV for daytime stuff (skylight and attic fans); 9v DC for night-time stuff (lounge-to-bedroom fans).
- Switching to different power consumers: LED-based lights (simple); fans (not simple - motors are not straight forward to switch electronically).
- Multiple temperature probes: lounge temperature; attic temperature.
- Optional extras include: XBee (or similar) switch override and/or temperature data publishing; the ability to supply an secondary LED light system via a manual/remote switch.
- Motors (fans) are not straight forward to switch electronically as they can produce electricity as they spin down after the power is cut - this can force the electronic switch (MOSFET) to stay on. In other words, you can switch the fans on electronically, but not off again. To address this, my circuit uses pairs of MOSFETs, plus a diode across each fan output that 'drains' the motor-produced current from the circuit.
- 20W of power is a lot for a circuit board to push around - I've made my traces extra-wide, but it's worth finding a 'trace width' tool on the Web to make sure your needs are fully covered.
- I used EagleCAD to translate my schematic into a PCB. The files are attached, below. I started with an Arduino Shield design available from the Arduino Foundation, but it turned out to be slightly too narrow for the Decimilia unit I was using (no idea why) - the result fits (just), but I'd recommend starting again if you want to make your own version of what I've done here.
- My PCB includes break-out pads for the temperature sensors (not least of which because they are on long wires to get the sensor to the right locations). Information about wiring a temperature sensor can be found here.
- My PCB includes a connector block for my 'optional extra' secondary light system, but this has not been implemented in the Arduino code.
- My PCB includes break-out pads for the Tx/Rx pins (for the 'optional extra' XBee), but this has not been implemented in the Arduino code.
This project has morphed quite a bit over time. The latest version:
- replaces the Arduino module with an ESP8266 module
- replaces the pair of LM335Z temperature sensors with a pair of MCP9808 i2c devices
- uses MQTT for outbound messaging (e.g. state change messages)
- uses a simple web server for inbound messaging (easier than MQTT to trigger from random clients)
- implements the 4th switch to transfer power to a set of LEDs (in the shed)
- implements OTA updates (no more climbing up to the attic to update the code)
ESP8266 code: Attic.cpp
All Arduino MOSFET Switch assets by Chris Molloy are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
¤ Copyright 1999-2024 Chris Molloy ¤ All rights reserved ¤