I have a NodeMCU board. Blink sketch and a ton of example sketches work fine.
With nothing connected, as soon as I include DS1307RTC.h on top the board start to crash and reboot immediately at startup. I have also tried un-edited DS1307RTC and RTC examples and the result is the exact same.
When I do connect the actual board, with the i2c scanner sketch, the board is detected and the results are still the exact same.
I2C device found at address 0x50 !
I2C device found at address 0x68 !
When the board resets at startup, I see the following in console in a loop.
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v60000318
~ld
Any ideas?
No code
No wiring details
No point in discussing it.
Sorry, I didn't feel like it was needed since I don't have anything custom.
Here is the out-of-the-box example sketch and there is nothing connected to the board so I am unsure what wiring I would provide.
/*
* TimeRTCSet.pde
* example code illustrating Time library with Real Time Clock.
*
* RTC clock is set in response to serial port time message
* A Processing example sketch to set the time is included in the download
* On Linux, you can use "date +T%s > /dev/ttyACM0" (UTC time zone)
*/
#include <TimeLib.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup() {
Serial.begin(9600);
while (!Serial) ; // Needed for Leonardo only
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
}
void loop()
{
if (Serial.available()) {
time_t t = processSyncMessage();
if (t != 0) {
RTC.set(t); // set the RTC and the system time to the received value
setTime(t);
}
}
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
/* code to process time sync messages from the serial port */
#define TIME_HEADER "T" // Header tag for serial time sync message
unsigned long processSyncMessage() {
unsigned long pctime = 0L;
const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
if(Serial.find(TIME_HEADER)) {
pctime = Serial.parseInt();
return pctime;
if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013)
pctime = 0L; // return 0 to indicate that the time is not valid
}
}
return pctime;
}
I think I have figured it out (or found a hack).
In the stock example sketch in post #2, if I comment out include <Wire.h>, the crash goes away. Weird.. so I ported this back to my original code.
This crashes...
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WEMOS_Motor.h> //motor shield
#include <Adafruit_MCP23017.h> //port extender
#include <U8g2lib.h> //display shield
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t; causes issues and crash if this is the last one
void setup {
}
void loop {
}
But if I comment out WEMOS_Motor.h and Adafruit_MCP23017.h, it works. Only common thing is that they all include Wire.h somewhere in there.
Also, if I move DS1307RTC.h to top, it starts to work. So, this works...
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t; causes issues and crash if this is the last one
#include <WEMOS_Motor.h> //motor shield
#include <Adafruit_MCP23017.h> //port extender
#include <U8g2lib.h> //display shield
void setup {
}
void loop {
}
So, although, it does work now, if DS1307RTC.h is after other includes (WEMOS_Motor.h or Adafruit_MCP23017.h) that have Wire.h something weird is going on to crash the board.
Hopefully this helps someone in future.
1 Like