Smart Switch using ESP12F Module for 2 Relay control + Motion deetection using PIR sensor. Motion deetection is selectable. if its enabled then Relay 2 will operate based on PIR sensor. PIR sensor enable is possible using MQTT message.
System Overview :-
Raspberry PI act as MQTT broker & it connects with Local wireless network using Router.
ESP running with MQTT PUBSUB library and connect with same locak wire less network and subscribed to three topics
for Relay 01
for Relay 02
for enable or disable motion sensor functionaliity.
in any hard wired switching ESP will publish stats of relay on respective topic.
TWO Hard wired switch connected with ESP input. ESP monitor state of each DI and switch relay accordingly.
Motion sensor(PIR) connected with one DI of esp. if motion sensor function is enabled(From MQTT message) then Relay02 will work as per motion sensor.
if motion deetected Relay 02 will turned on.
if motion deetection input is low and Relay02 is On then after 60 seconds Relay will trrned off automatically.
MQTT DASH app installed on mobile and mobile is connected with same wifi network on which mqtt broker(PI) is connected.
From mobile we send 0 or 100 value on same topic on which ESP is subscribed.
whenever mobile published value, accoding that value esp turn on or off relay.
Design Consept :- PCB made to install in OLD switch board without changeing any hardware like Switches or wiring scheame so it is easy to install this in any swithc board.
Design Basic:-This switch can operte Two relay. operation can be pissible by two method, 1st is by hard wired. 2nd method is using MQTT DASH android app.. Relay 02 can operte using PIR motion sensor.
ESP12F wiring:- ESP12F module is 3.3V operated & i used 5VDC for field wiring, so to protect ESP i have used PC817 Opto coupler which convert 5VDC to 3.3VDC visa-versa.
ESP12F To relay board wiring :- Relay board is 5 VDC operated so i have modified its circuit. i remove LED of each relay and sorted its two pin. after that each relay works fine with 3.3VDC. Relay coil is 5VDC rated & for that one pin header privided.
Supplies:
1:- 230V to 5 VDC SMPS
2:- 5VDC to 3.3 VDC voltage regulator
3:- ESP12F
4:-Opto couplers PC817
5:- Passiv componants :-Resistors,Capacitors
6:- Male & Female Pin headers & screw terminal
7:- Push Buttons
8:- 2 Chanel Relay board (5VDC operated)
9:- Raspberry PI3B+
10:- 16 GB Class 10 SDcard
11:- HDMI to VGA converter
12:- 5VDC 2.5 Amp. power supply for Raspberry PI
13:- PIR sensor”

Link

Related Content