Control a High Voltage AC/DC circuit using any device in your local network.
This readme was made for my future reference. Dont expect it to be perfect.
- Pi (with wifi access)
- Relay Module
- Female-Female Wire
Relay is basically a electromagnatic switch you can turn on/off using small electrical currents from your Pi. Learn More here: https://raspberrypi-guide.github.io/electronics/control-electronics-with-a-relay
Key Takeaway:
- Refer to your Pi's GIOP digaram.
- Connect one wire of your circuit to
common
- Connect the other wire to
NO(Normally Open)
if the circuit is broken by default or NC(Normally Connceted) if complete by default. - If your circuit has ground, it will probably go at
NC(Normally Closed)
and the other wire at NO In
,GND
andVCC
connect to your Pi's pins.In
is the switch. Connect it to a GPIO. (Change thefan_pin
var insetup.py
accordingly)GND
is ground. Duh. Connect it to any ground pin.VCC
is the operating voltage. Connect to 5V or 3.3V pin depending on the Relay you bought.
-
Clone this repo in your Pi
-
Install Flask
pip install flask
- Run the Server
python server.py
- Control your switch at
localhost:6969
orip-address:6969
in any device in your local network. (Runhostname -I
in your Pi to check the ip-address)
This will enable the server to run every time the pi restarts.
- Update the
sudo nano /etc/rc.local
file
sleep 5
bash -c '/usr/bin/python /home/siren/relay-switch/setup.py > /home/siren/mylog.log 2>&1' &
- Get the below IPs and update
sudo nano /etc/dhcpcd.conf
:
pi: hostname -I
router: ip r | grep default
domain Name servers: sudo nano /etc/resolv.conf