Home Automation – Domoticz and Sonoff Mini

Since my earlier articles on establishing my home automation system (starting here), I have been looking for a retrofit solution to automate to my outside porch light. This light is turned on at dusk and off late in the evening to illuminate what would otherwise be a very dark front door.

Recently, using a Sonoff Mini, I was finally able to put this light on an automated timer managed by my Domoticz system.

Sonoff Mini

The Sonoff Mini is a very small form wifi switch built around the same core as the larger Sonoff switches discussed in the earlier articles.

Called mini for a reason!

The unit has screw terminals for the AC power connection and short aerial wire sticking out the small plastic box. The AC powers the unit and is also switched with a relay to power a device on the output terminals. An external switch can be connected to the crew terminals to operate the relay through the firmware.

The Mini also exposes the appropriate 4 terminals (GND, 3.3V, Tx, Rx) that allow it to be reflashed, although these are PCB test pads rather that the through holes found in the larger devices (shown below).

The process for reflashing the ESP8285 with ESPEasy is the same as described in the earlier posts (read it here), it is just more painful to solder the wires to the small test pads than it was to use the PCB through holes. A few solutions have been developed to make this easier, using 3D printed jigs (see here and here), but as I don’t have a 3D printer, I made do with solder.

Configuring ESPEasy is also very similar to the larger Sonoff units. For the record, the hardware I/O pin connections are listed below.

Wifi LED:        GPIO13 (D5)
PCB Tact Switch: GPIO0  (D3)
External Switch: GPIO4  (D2)
Relay:           GPIO10 (D12)

Solving my Problem

The external porch light is essentially a cylinder about 75mm diameter, attached to the wall. The upper half is the light bulb and the lower is mostly empty space in a stainless steel ‘can’.

The wall switch is just inside the front door and the electrical wiring between the switch and the light is contained within the wall cavity. The wires emerge from the brick wall through a snug hole behind the shallow metal support plate.

As with most similar installations the wall switch is wired to switch the AC active lead, so there is no convenient neutral wire that allow the Sonoff to be installed just behind the switch (circuit shown below).

The obvious alternative location for the wifi switch is just behind the light fitting. However, the tight hole in the brick wall made this unfeasible.

The relatively narrow diameter of the light fitting also did not allow the larger Sonoff Basic to be placed inside the fitting. However, the Mini was small enough to fit inside the lower portion, after some creative metalworking, wired as shown below. Total installation time was about 30 minutes, which included dismantling and partially rewiring the light fitting.

With this arrangement, the wall switch is used to energise power to the Mini, which then enables Domoticz to control the light. However, this arrangement initially meant that we could not operate the light in ‘manual’ mode (ie, actually switched on and off from the wall plate).

After some thought I realised that a change to the default ESPEasy configuration could allow this manual mode. By setting the ‘boot up’ state for the relay output to ‘energised’ (or ‘on’), the light immediately turns on when manually switched and then off when the power is removed.

The tradeoff for this pseudo-manual mode is that if automatic operation is required the light must be switched off from automation interface, or it will stay on until the first timed ‘off’ command. As it stands, we just leave it on the whole time and it runs on the timer.

All in all, the Mini allowed a minimally impacting retrofit solution that enabled automatic and manual control with a minimum of fuss.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s