So Hi. I Made A IOT based home Automation In Arduino IOT Cloud, But In My case i Need A Timer To Control My Appliances. I Have Tried Cloud Scheduler But Failed. Can Someone help me With This Please?
This Is The Code:
/*
Sketch generated by the Arduino IoT Cloud Thing "SMART WATERING SYSTEM"
https://create.arduino.cc/cloud/things/a2fb6655-6761-4d51-bbcc-c3a2712e7dec
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudSchedule motoron;
CloudSchedule terracewatering;
bool relay1;
bool relay2;
bool relay4;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
void setup() {
pinMode(D0,OUTPUT);
pinMode(D1,OUTPUT);
pinMode(D2,OUTPUT);
pinMode(D3,OUTPUT);
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
if (schedule_test.isActive()) {
light = true;
digitalWrite(D0, LOW);
if (toggle) {
counter = ++counter;
toggle = false;
}
} else {
light = false;
digitalWrite(D0, HIGH);
toggle = true;
}
if(ArduinoCloud.connected()){
time_read = ArduinoCloud.getLocalTime();
}
}
void onScheduleTestChange() {
}
}
// Your code here
/*
Since Relay1 is READ_WRITE variable, onRelay1Change() is
executed every time a new value is received from IoT Cloud.
*/
void onRelay1Change() {
if(relay1)
{
digitalWrite(D0,LOW);
}
else
{
digitalWrite(D0,HIGH);
}
// Add your code here to act upon Relay1 change
}
/*
Since Relay2 is READ_WRITE variable, onRelay2Change() is
executed every time a new value is received from IoT Cloud.
*/
void onRelay2Change()
{
if(relay2)
{
digitalWrite(D1,LOW);
}
else
{
digitalWrite(D1,HIGH);
}
// Add your code here to act upon Relay2 change
}
/*
Since Relay3 is READ_WRITE variable, onRelay3Change() is
executed every time a new value is received from IoT Cloud.
*/
/*void onRelay3Change()
{
if(relay3)
{
digitalWrite(D2,LOW);
}
else
{
digitalWrite(D2,HIGH);
}
// Add your code here to act upon Relay3 change
}
/*
Since Relay4 is READ_WRITE variable, onRelay4Change() is
executed every time a new value is received from IoT Cloud.
*/
void onRelay4Change()
{
if(relay4)
{
digitalWrite(D3,LOW);
}
else
{
digitalWrite(D3,HIGH);
}
// Add your code here to act upon Relay4 change
}
/*
Since Terracewatering is READ_WRITE variable, onTerracewateringChange() is
executed every time a new value is received from IoT Cloud.
*/
void onMotoronChange()
{
}