"RTC lost confidence in the DateTime!" or "SSD1306 allocation failed", ask for help! #223
Unanswered
mianqi2016
asked this question in
Q&A
Replies: 2 comments
-
What device/Arduino? Do you know what pins the I2C is on your device? Do they overlap 10,11, or 12? The error system for these devices is not robust as they often just don't communicate when there is an error, so they can often just show as lost confidence or strange dates. Most of the time its either wiring is wrong or power is wrong. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Solution: https://github.com/greiman/SSD1306Ascii |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I used DS1302 with an IIC OLED, the code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// DS1302
// CONNECTIONS:
// DS1302 CLK/SCLK --> D10
// DS1302 DAT/IO --> D11
// DS1302 RST/CE --> D12
// DS1302 VCC --> 3.3v - 5v
// DS1302 GND --> GND
#include <RtcDS1302.h>
ThreeWire myWire(10,11,12); // IO, SCLK, CE
RtcDS1302 Rtc(myWire);
// SetTime on DS1307
bool parse=false;
bool config=false;
boolean flagDS1302 = false; // flag for DS1302 h/m/s showing when DHT11 read error
void setup() {
Serial.begin(115200);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
// Draw a single pixel in white
//display.drawPixel(10, 10, WHITE);
// Show the display buffer on the screen. You MUST call display() after
// drawing commands to make them visible on screen!
//display.display();
//delay(2000);
// display.display() is NOT necessary after every single drawing command,
// unless that's what you want...rather, you can batch up a bunch of
// drawing operations and then update the screen all at once by calling
// display.display(). These examples demonstrate both approaches...
// set time on DS1302
}
void loop() {
// // display time info on LCD2004A
// RtcDateTime now = Rtc.GetDateTime();
}
now, it was prompted in Arduino IDE:
RTC lost confidence in the DateTime!
and, if uncommented these lines:
// if (now < compiled)
// {
// Serial.println("RTC is older than compile time! (Updating DateTime)");
// Rtc.SetDateTime(compiled);
// }
// else if (now > compiled)
// {
// Serial.println("RTC is newer than compile time. (this is expected)");
// }
// else if (now == compiled)
// {
// Serial.println("RTC is the same as compile time! (not expected but all is fine)");
// }
it would prompted:
SSD1306 allocation failed
any suggestion?
Beta Was this translation helpful? Give feedback.
All reactions