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 Connected)and the other wire at NO In,GNDandVCCconnect to your Pi's pins.Inis the switch. Connect it to a GPIO. (Change thefan_pinvar insetup.pyaccordingly)GNDis ground. Duh. Connect it to any ground pin.VCCis 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:6969orip-address:6969in any device in your local network. (Runhostname -Iin 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.localfile
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(it is originally a cli based on Dynamic Host Configuration Protocol inRFC 2131. It configures the network interface of the machine on which it is running). Use the right settings for your type of network connection:
pi ip: hostname -I # so you know your subnet
router ip: ip r | grep default # default gateway (your router IP)
domain Name servers: sudo nano /etc/resolv.conf # current DNS servers

