Start

for every value of (t=time)

get TMP, HMDT, GAS, MTN, RN

Send data to Ubidots MQTT

Change the value on/off (sensors and actuators)

Get data from MQT

case1 (YL83)

if(RN>=RN_0) then

switch CLOSE sliding window

else

switch OPEN sliding window

break;

case2 (HC-SR-505)

if MTN is present then

Send message “Motion Detected”

break;

case3 (MQ2)

if(GAS>=GAS_0) then

Send message” Gas Detected”

break;

case4 (LDR)

if(DRK>=DRKₒ) then

ON light switch

else

OFF light switch

break;

End.