Hookup all the components according to the circuit diagram shown above.
In the above wiring diagram, The pins VCC, GND and IN on the Relay module may vary depending on your Relay module. So, Refer to the data-sheet of your Relay.
For, connecting the AC bulb to the relay properly:
Connect live wire from AC wall outlet to Common port on relay and one terminal of AC bulb to Normally open terminal of Relay.
Then, Connect the other terminal of AC bulb to GND on the AC wall outlet.
Take proper precautions and care while connecting any wire to mains.
Step 3: Arduino Sketch
from flask import Flask, request, render_template
app = Flask(__name__)
result = b'null'
@app.route("/rcv", methods = ['GET','POST'])
def rcv():
result = "1"
return result
@app.route("/rcv2", methods = ['GET','POST'])
def rcv2():
result = "0"
return result
@app.route("/rcv3", methods = ['GET','POST'])
def rcv3():
return result
@app.route("/")
def index():
global result
return render_template("index.html", data = result.decode("utf-8"))
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
Once you have hooked up everything properly upload the Relay.ino sketch to your arduino.
Unlike LEDs, Relays closes the circuit whenever the signal or input pin is connected to GND. (This may vary for other custom made relay modules.)
So, "digitalWrite(13, LOW);" turns on the bulb. While, "digitalWrite(13, HIGH);" turns off the bulb.
Comments
Post a Comment