Hey, I'm trying to make my board go to sleep for 10 milliseconds and checks if there's something on the serial or a half hour passed.
if there's something on the serial1(UART) to excute a function, if half hour passed to send data to the cloud.
but so far it's not working .
void loop() {
if (Serial1.available() > 0)
{
isBusy=true;
HandleGatewayMsg(); //read msgs and send msgs accordingly!
}
if(acksent) //acksent make sure there's data waiting to be sent
{
if (millis() - start_time > timeout) //timeout = 30 mins
{
isBusy=true;
SendMsgToCloud();
start_time = millis();
}
}
delay(1000); //transsimission time takes only 50ms, this is just insurance..
isBusy = false;
if(!isBusy)
{
LowPower.idle(10);
isBusy = true;
}
}