Decided to put some landscape lighting up at my new home and figured I might as well make it home automation friendly. That means I want to control it from a browser or by Alexa or Google commands.
It’s actually not very complicated, as far as home automation goes. The whole project is centered around a Sonoff 4 Channel Relay. The device I linked is actually a newer model than the one I have. I have the Sonoff 4 Channel Relay R2 Pro.
Figured I may as well use it.
It can control 4 different lighting circuits however I’ll probably only install 2 or 3 circuits, and this of course will give me room to grow.
These things come ready to roll but the device and smart app are Chinese and I don’t dig that at all.
So I flash mine with Open Source firmware called Tasmota. At least I know my information isn’t being sent to some server in China.
NOTE: These devices are rated to 10 amps only. If you use them on an AC home circuit breaker it is likely a 15 or 20 amp circuit. Translation: The Sonoff will fail catastrophically before a circuit breaker trips if something goes wrong. We are powering this device with DC power and using low voltage DC landscaping lights that are 12 volt. This will be safe.
So basically what we need to pull this off is:
- Sonoff 4 channel relay
- 12v power supply (I use a 360 watt)
- Low Voltage Landscape Lights (from anywhere, Lowes, HomeDepot, Amazon, etc.)
- Low voltage wiring. 2 conductor usually 14 or 16 gauge.
To flash the Sonoff to Tasmota you need:
- FTDI Controller – you can actually get one on eBay for a couple bucks. Doesn’t have to be this one.
- Laptop with USB
- Flashing software like Tasmotizer or ESP-Flasher
Hook up your FTDI to your board like this:
FTDI Connections (click to enlarge pic)
To get the device in boot loader mode you may need to short GPIO0 to Ground manually. Connect your FTDI as per the pic above and before you plug in the USB put a jumper from from Ground to the test point circled below.
Shorting Manually GPIO0 to GND (click pic to enlarge)
Now you can use Tasmotizer or another program to flash Tasmota. I used ESP-Flasher. You just select the serial port which is usually autodetected and the Tasmota.bin (or Tasmota-lite.bin) depending on your flash memory size.
Once flashed Tasmota will make a WiFI hotspot which you need to connect to, then navigate to 192.168.4.1 in a browser. It will ask you to insert your home wifi credentials then it will connect to your network.
Once it boots you need to configure the module to number 23 which is Sonoff 4ch PRO.
Then it reboots and you’ll see 4 buttons to control each channel of the relay:
At this point you can connect lights and control them via this web page. But we want to voice command it via Home Assistant. You need to set up an MQTT broker (if you are using Home Assistant) and then configure the switches. The switch commands will depend on what you set the MQTT topic to, and POWER1, POWER2, POWER3 and POWER4……..yep, you guessed it, one for each switch.
- platform: mqtt name: "Landscape Lights" state_topic: "stat/sonoff4ch/POWER1" command_topic: "cmnd/sonoff4ch/POWER1" qos: 0 payload_on: "ON" payload_off: "OFF" payload_available: "Online" payload_not_available: "Offline"
Be sure to make 4 entries and change Power1 to Power2, and so on.
Then you can put the switches on your dashboard.
It should be noted that for initial configuration I named them all “Landscape Lights”. This will probably change and could become “Fence lights”, “Path Lights”, etc. You can name them whatever you want in the code. Once you decide on names you can tell Alexa to “Discover Devices” and she’ll pull them into her Alexa Skill (bitch got skills) and you can tell her “Alexa, turn on Path Lights”. Even better you can set an automation for the lights to come on at sunset or something like that. You could set up motion detectors or door switches which will turn the lights on when the door is opened, or whatever. The sky is the limit.
Now on to the physical installation:
The relays will be wired as “Normally Open”. R1 or Relay 1 is wired as follows:
- Normally Open Terminal – goes to light bulb negative wire
- COM (Common Terminal) – goes to negative 12v on power supply
- A Red wire goes from 12v Positive on power supply to lamp positive wire
The relay acts like a switch that breaks the return connection on the negative side of the circuit. As soon as you hit the switch the common and normally open side of the relay touch and complete the circuit.
Sonoff Wiring (click to enlarge pic)
Not depicted is how to wire the power to the Sonoff. You can use a brick to power it via the DC connection (anything between 5 and 24volts), or you can also tap into the AC side of the power supply hooking it up like below:
- Black wire to L (Line)
- White wire to N (Neutral)
Either DC or AC hookup works. AC hookup saves you one outlet space, and DC hookup generally might be safer because the Sonoff device is only rated for 10 Amps. The brick I use only pumps 1 or 2 amps on the output side.
In the interest of keeping it all neat and clean I 3D printed a mounting bracket system for the power supply that I found here.
3D Printed Bracket For Power Supply (click pic to enlarge)
Here it is in action! I have more lighting to do around the yard but it just involves adding additional runs.
That’s a wrap! Like Debbie Boone sang……You Light Up My Life!