I’ve done a lot more work on the backyard controller design and things have firmed up.
Here’s what it looks like.
First, I don’t think the 100 watt power supply I bought is going to cut it; I have 36 watts on the ground and 40 watts on the house, and we’ve added tree accent lighting, fountain accent lighting, and I think I’m going to include some existing stair lighting on this. Oh, and some umbrella lighting. That would put me close or slightly over 100 watts, and that doesn’t leave any margin for losses in the wiring or a power supply that doesn’t quite do what I think it’s going to do.
The project is going to be split into two modules.
The first will live in the duplex outlet and will consist of the SSRs to drive the pump and the power supply and a 5V power supply for the NodeMcu. I have some nice thin 2 amp SSRs that will do nicely for those two loads and I’ve verified that they work fine on 3 volts (they worked okay on 2 volts in my tests), and my current plan is to hot glue them to the back of a split duplex outlet. One outlet will be used to plug the 12V power supply into, and the other will be back wired to connect to wiring that goes to the outlet next to the water feature. I *might* go hunting for some beefier SSRS, but the good ones are unfortunately expensive and the cheap ones have a bad reputation. So, we’ll see. The ones I have are fine for those applications but if somebody plugs something beefier things will not work well.
The 5V power supply will be just enough to run the ESP; an amp will be fine. And yes, I’m going to break code and mix high and low voltage in the same box, but I will do my best to do it sanely.
From that box I’ll run some 4-conductor cable out. It will have:
That cable will run to the second box mounted up underneath the deck. It has the following inputs:
- 12V power (from the power supply)
- 12V power (from the existing stair lights)
- +5V / GND
And the following outputs:
- 12V stair lights
- 12V bed lights
- 12V house lights
- PUMP ON
- 12V ON
Maybe I’ll add in the under-umbrella lights as a separate circuit; the extra components are cheap and it would be nice to have separate control there.
My current stair lights are controlled by a switch in the garage and a power supply there. I originally thought I’d use a 12V relay to either power them from the garage or this controller, but it’s easier to just sense the 12V in the new controller and power all of them from the new power supply.
The MOSFETS I have are IRLB8721PbF, which are reputed to be decent for logic-level switching… Let’s take a look at the data sheet:
What I’m trying to figure out is what sort of current I can expect if I drive them from the ESP8266 pins. My drain to source voltage is 12 volts, so I’m looking at the right side of the curve, and I’ll pick the 3.0 V curve to be conservative. And that shows me that I can get around 10 Amps, which would be 120 watts. With 200 watts planned, I’d only pull 100 watts or so, so it looks like I’m close but okay.
But… Take a look carefully at that graph. See where it says “Tj = 175 C”. Yeah, that’s hot, and it’s the absolute maximum temperature, which means I’d really need some heatsinking or other cooling. The whole point of a nice power MOSFET is that they have low R(DS) resistances and therefore don’t get very hot. Which is not true if you are only driving it with 3V. This is the “if you’re stupid” graph.
There’s another graph in the datasheet:
Notice this one says that it has a junction temperature of 25 degrees centigrade. Which isn’t even body temperature. But, to get that from a 3 volt drive, I can only pull 3 amps.
What that really means is that I could easily build a test circuit and have it work great with my test loads of 30 watts or so, and then install it and hook it up to a 100 watt load and it will melt. Which would be bad.
The graph gives a really simple solution; instead of driving it with 3 volts, I need to drive it with something high. Like – I don’t know – maybe the 12 volts that I already have in the circuit. The graph only goes to 10 but if it went to 12 (insert Spinal Tap reference here), we’d expect that it’s pretty much the same. And it shows that we could do upwards of 100 amps from this device in that situation.
We can’t; the maximum continuous is 62 amps, but we can easily pull the 10 amps that we need. And the datasheet also tells us that at 10V(GS), the R(DS) is 8.7 milliohms. So, at a 10 amp current, that means the voltage across the MOSFET will be 0.087 volts, and it will dissipate 0.87 watts. A bipolar transistor here would drop 0.6 volts and dissipate 6 watts, which you would definitely need a good heatsink for.
MOSFETS do see increases in R(DS) as they get warmer. I am *probably* okay, but I’ll also probably put a small heatsink on the MOSFETS anyway and do a little testing overnight to see how they are pushing that much current. Or I could do the thermal calculations to see how much junction temperature rise I can expect.
Or… I might get lazy, and run two of them in parallel. Another nice thing that you can do with MOSFETS that is problematic with bipolar transistors. Bipolars have positive thermal coefficient, so if one gets hotter it pulls more current and things rapidly go downhill. MOSFETs does the offset, so you can generally put them in parallel with no problems.
So, how do we switch it with 12V? There are numerous MOSFET gate drivers out there that are designed not only to use a higher voltage but push enough current to be able to switch quickly; MOSFETS do not technically draw current but they do have gate capacitance so you need to pull some current to get them to switch quickly. That’s really important if you are building something like a switching power supply that you are switching at a relatively high frequency, but for my application, all I need is on and off and it doesn’t have to switch particularly quickly.
So, I’m going to go old school and use a small signal bipolar transistor to switch the gate.
The schematic comes from here. It’s really simple; when the logic input is low, the transistor won’t be conducting and the pull-up resistor will pull the gate high, turning on the MOSFET. Turn the transistor on by flipping the logic input high, it pulls the gate to ground (well, to 0.6 volts, which is close enough), and the MOSFET will turn off. It does invert the signal, which is a bit inconvenient but not really problematic in this case, as the 12V is only there is the power supply is turned on.
Pretty much any NPN transistor will do; I have some metal cased 2n2222s in my box, so that’s what I will use.
The only remaining part of the hardware is the sensing circuit for the 12V coming from the current stair light power supply. That’s pretty simple; take the 12 volts in, run it through a simple voltage divider, and I’ll get 3 volts to feed to the ESP.
All this is going to get hand-wired on a breadboard; there’s no reason to do a PC board for this application. I think the connections will all be screw-terminal barrier strips as they work well with the beefy 12 gauge wire for the low voltage lights.
I’m also going to build a small remote that you can use inside so you don’t need your phone to do the switching.
The software will be based on the ESP8266WebServer class, with a simple method to query the current state and separate methods to do the switching. I’ll do turn on, turn off, and toggle methods to provide some flexibility.
I recently switched to VS Code and Platform IO; it took some futzing to get it working, but the experience is so much better than the arduino IDE, and it knows how to create an ESP project that works out of the box. I have the bare-bones http server running for this; I don’t expect the full code is more than a day’s work if that. Oh, and I’ll do a web-page interface as long as I’m doing it.
I haven’t done anything on implementing the advanced functions based on sunset times etc., though I will probably implement auto-off for both the fountain and the lights.