OK, so I had a code that was working properly at a testing time @usb and @wifi (see below). As you can see, I want to send a PowerStrip on/off codes at certain part of the day.
Code:
#include <OpenGarden.h>
#include <Wire.h>
//Power strip codes. Please insert here your own codes generated with
//RF_Receive_remoteControl_codes
unsigned long on1 = 1622153562;
unsigned long off1 = 1605376348;
unsigned long on2 = 1605376364;
unsigned long off2 = 1605376366;
unsigned long on3 = 1605376256;
unsigned long off3 = 1605376258;
unsigned long on4 = 1605376094;
unsigned long off4 = 1605376096;
unsigned long on5 = 1605375608;
unsigned long off5 = 1605375610;
int on_hr = 7;
int on_min = 0;
int off_hr = 22;
int off_min = 36;
void setup() {
Serial.begin(9600);
OpenGarden.initRTC();
//OpenGarden.setTime(); //write time to the RTC chip
OpenGarden.sendPowerStrip(on1); //Turn ON plug 1
OpenGarden.sendPowerStrip(on2); //Turn ON plug 2
OpenGarden.sendPowerStrip(on3); //Turn ON plug 3
OpenGarden.sendPowerStrip(on4); //Turn ON plug 4
OpenGarden.sendPowerStrip(on5); //Turn ON plug 5
}
DateTime now;
void loop() {
now = OpenGarden.getTime(); //Get date and time
if ( now.hour() == on_hr && now.minute() == on_min && now.second() == 0 ) {
OpenGarden.sendPowerStrip(on1); //Turn ON plug 1
Serial.println("Plug 1: ON");
Serial.print("godzina na ON: ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(),DEC);
Serial.println(" ");
Serial.print("lajt ON, czekam...");
Serial.println(" ");
Serial.println(" ");
delay(1000);
}
if ( now.hour() == off_hr && now.minute() == off_min && now.second() == 0 ) {
OpenGarden.sendPowerStrip(off1); //Turn ON plug 1
Serial.println("Plug 1: OFF");
Serial.print("godzina na OFF: ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(),DEC);
Serial.println(" ");
delay(1000);
}
}
As the code didn't send an off signal at the proper hour, I've tried to reset the RTC (again, via wifi, and via usb).
Code:
#include <OpenGarden.h>
#include <Wire.h>
DateTime now;
void setup() {
Serial.begin(9600);
OpenGarden.initRTC(); //Initialize RTC
OpenGarden.setTime(); //write time to the RTC chip
}
void loop() {
Serial.print(now.day(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.year(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(),DEC);
Serial.println(" ");
delay(1000);
}
the above code gives me some insane date, like 6/2/2106 and time not being correct.
my board is Arduino Uno WiFi (
http://www.arduino.org/learning/getting ... o-uno-wifi).
WTF am I doing wrong?