Open daghemo opened 6 years ago
@SpellFoundry, I was getting the same error over and over, then I found the root case.
The following code can be used to reproduce the error:
#include "SleepyPi2.h"
unsigned long timeNow = 0, timeLast = 0;
char datetime[ 20 ];
void setup() {
Serial.begin( 9600 );
Serial.println( "Starting serial console..." );
SleepyPi.rtcInit( true );
}
void loop() {
DateTime now;
timeNow = millis();
now = SleepyPi.readTime();
if ( ( timeNow - timeLast ) >= 5000 ) {
sprintf( datetime, "%d/%02d/%02d %02d:%02d:%02d" , now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second() );
Serial.println( datetime );
Serial.flush();
timeLast = timeNow;
}
}
Just moving SleepyPi.readTime() within the "if" will solve the problem. That is, the SleepyPi.readTime() should not be run too often! If not, it will break both the RTC on the Raspberry Pi and even its whole I2C bus.
I think I have bricked my Sleepy Pi 2 while working on my Sketch.
The Sleepy Pi 2 was connected to my Raspberry Pi while I saw I was not able to talk to the RTC:
Then I also saw:
I was not able to upload another sketch remotely using the Software Jumper because it was not working:
After pressing the Reset button on the Sleepy Pi 2 I saw:
Then, after some time:
Again, after some other time:
That is, resetting the Sleepy Pi 2, rebooting the Raspberry Pi, removing the power from both the boards, also removing the battery from the Sleepy Pi 2 does not resolve the problem. I had to put the hardware jumper in place in order to upload a new Sketch.