Your Pages‎ > ‎Users Pages‎ > ‎Robin‎ > ‎shelved‎ > ‎

Project - Smart Switch

NOTE:  Unfinished, still in progress

(a small sample selection of different switches, plus 2 different type beam-break detectors, and 2 different type radar sensors)

This Smart Switch script provides for an input to trigger a local relay and/or send instructions to control remote nodes if wished.
The input trigger can be bi-state (ie: toggle) or momentary (ie: push-button), allowing use of almost any types of switches and sensors.
The hardware can be any Annex-WiFi Basic device that suits your needs, from a battery-powered ESP-01 to a MAINS relay module.
Two different scripts are offered:
1.  Local - for stand-alone operation
2.  EasyNet - send or receive trigger alerts with other nodes to create an interactive smart system.

The project details are based on the low-cost Sonoff Mains Relay Module, but the principles are easily adapted to your own preferred hardware.

Sonoff devices usually come with the flashing holes vacant, so you'll need to solder in some pins for connecting a UART to reflash the device.

Waste not want not - after re-flashing, the TX (gpio01) and/or RX (gpio03) can be used as input or output, some Sonoffs also have gpio14 available.

Depending on the make and model of your device, use a gpio that is next to the 0v pin to make it convenient for a 2-pin header plug to be used.
(can be be made from some stripboard if needed)
















Wires might be added in parallel across the onboard gpio00 button.

Whatever your choice, it would be advisable to route the wires out the bottom of these pictures to keep them as far from the thick upper MAINS pcb tracks as possible. Cut a slot in the top plastic cover to fit over the wires without pressing on them, then hot glue them to the base or pcb.

The longer the wires, the more they may be affected by transients - twisted pairs may help to cancel out noise, otherwise try shielded cable.
If the weak Esp pullup is being swamped, add a hardware pullup resistor - if 10K isn't strong enough, try 5K, or even 1K.
Also the hardware interrupt debounce times can be increased to lessen spurious triggering and improve stability.



Note to self:  need to complete EasyNet handshaking