SCADA Group6 pp
SCADA Group6 pp
PROTOCOL BY WIFI
MEMBERS:
Trầ n Thiên Thuận
Nguyễ n Sinh Tùng
Nguyễ n Bá Tiế n
Tôn Đứ c Thành
Lê Đứ c Anh
Đoàn Duy Thắng
Table of
CONTENTS
01 02 03 04
Overview Operating Product App support
principle details
OVERVIEW
Product This system is a temperature control relay and
BLYNK_CONNECTED() is a Blynk function that gets called when the device connects successfully
to the Blynk server.
Blynk.syncVirtual(button1_vpin); synchronizes the relay control button's state from the Blynk app.
CODE EXPLANATION
4, HANDLE SIGNAL FROM BLYNK APP TO CONTROL RELAY
BLYNK_WRITE(button1_vpin) is called when the relay control button state changes in the Blynk
app.
param.asInt() gets the value from the app and stores it in relay1_state.
digitalWrite(relay1_pin, relay1_state); sets the relay state (on or off)
CODE EXPLANATION
5, SENDSENSOR() FUNCTION TO READ SENSOR DATA
AND UPDATE LCD AND BLYNK
sendSensor() reads the temperature t and humidity h from
the DHT sensor.
If the data is invalid (temperature or humidity is NaN), the
function exits without doing anything.
Blynk.virtualWrite(V0, t); and Blynk.virtualWrite(V1, h); send
the temperature and humidity data to Blynk through virtual
pins V0 and V1.
Updates the LCD display with temperature and humidity
values.
CODE EXPLANATION
6, SETUP FUNCTION IN SETUP()
Serial.begin(115200); initializes Serial to print data
to the computer screen.
pinMode(button1_pin, INPUT_PULLUP); sets the
button as INPUT_PULLUP.
pinMode(relay1_pin, OUTPUT); sets the relay as
OUTPUT.
digitalWrite(relay1_pin, HIGH); turns off the relay at
startup (output is HIGH)
Blynk.begin(auth, ssid, pass); connects to Wi-Fi and
Blynk
dht.begin(); initializes the DHT sensor
timer.setInterval(100L, sendSensor); calls
sendSensor() every 100ms to read sensor data and
update Blynk
CODE EXPLANATION
7, MAIN LOOP TO RUN BLYNK AND TIMER