-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug when use with RTClib of adafruit #6
Comments
I don't know how but I made it work, I don't know what caused it, but it worked correctly again after disconnecting and reconnecting the rtc module, maybe the module was blocked. |
Hello
I allready have this pb with DS3231 RTC clock. Sometimes it freezes and
as it have a battery, chip can stays in this state when we do a power
off followed by a power on.
I find a bypass method on the web, bellow i2cRecovery function (source :
https://forum.arduino.cc/t/ds3231-and-i2c-problem/576700/5 ):
void i2c_recovery(){
Serial.println("Starting I2C bus recovery");
delay(2000);
pinMode(SDA, OUTPUT); // Make SDA (data) and SCL (clock) pins Inputs
with pullup.
pinMode(SCL, OUTPUT);
digitalWrite( SDA, LOW );
digitalWrite( SCL, LOW );
pinMode(SDA, INPUT_PULLUP); // Make SDA (data) and SCL (clock) pins
Inputs with pullup.
pinMode(SCL, INPUT_PULLUP);
delay(2500); // Wait 2.5 secs. This is strictly only necessary on the
first power
// up of the DS3231 module to allow it to initialize properly,
// but is also assists in reliable programming of FioV3 boards as it
gives the
// IDE a chance to start uploaded the program
// before existing sketch confuses the IDE by sending Serial data.
boolean SCL_LOW = (digitalRead(SCL) == LOW); // Check is SCL is Low.
if (SCL_LOW) { //If it is held low Arduno cannot become the I2C
master.
INTERFACE.println("I2C bus error SCL is low ! Error 1");
// return 1; //I2C bus error. Could not clear SCL clock line held
low
return ;
}
boolean SDA_LOW = (digitalRead(SDA) == LOW); // vi. Check SDA input.
int clockCount = 20; // > 2x9 clock
while (SDA_LOW && (clockCount > 0)) { // vii. If SDA is Low,
clockCount--;
// Note: I2C bus is open collector so do NOT drive SCL or SDA high.
pinMode(SCL, INPUT); // release SCL pullup so that when made output
it will be LOW
pinMode(SCL, OUTPUT); // then clock SCL Low
delayMicroseconds(10); // for >5uS
pinMode(SCL, INPUT); // release SCL LOW
pinMode(SCL, INPUT_PULLUP); // turn on pullup resistors again
// do not force high as slave may be holding it low for clock
stretching.
delayMicroseconds(10); // for >5uS
// The >5uS is so that even the slowest I2C devices are handled.
SCL_LOW = (digitalRead(SCL) == LOW); // Check if SCL is Low.
int counter = 20;
while (SCL_LOW && (counter > 0)) { // loop waiting for SCL to
become High only wait 2sec.
counter--;
delay(100);
SCL_LOW = (digitalRead(SCL) == LOW);
}
if (SCL_LOW) { // still low after 2 sec error
INTERFACE.println("I2C still low after 2 sec error ! Error 2");
// return 2; // I2C bus error. Could not clear. SCL clock line
held low by slave clock stretch for >2sec
return;
}
SDA_LOW = (digitalRead(SDA) == LOW); // and check SDA input again
and loop
}
if (SDA_LOW) { // still low
INTERFACE.println("I2C SDA still low ! Error 3");
// return 3; // I2C bus error. Could not clear. SDA data line held
low
return;
}
INTERFACE.println("Recovery ends with no known error");
// else pull SDA line low for Start or Repeated Start
pinMode(SDA, INPUT); // remove pullup.
pinMode(SDA, OUTPUT); // and then make it LOW i.e. send an I2C Start
or Repeated start control.
// When there is only one I2C master a Start or Repeat Start has the
same function as a Stop and clears the bus.
/// A Repeat Start is a Start occurring after a Start with no
intervening Stop.
delayMicroseconds(10); // wait >5uS
pinMode(SDA, INPUT); // remove output low
pinMode(SDA, INPUT_PULLUP); // and make SDA high i.e. send I2C STOP
control.
delayMicroseconds(10); // x. wait >5uS
pinMode(SDA, INPUT); // and reset pins as tri-state inputs which is
the default state on reset
pinMode(SCL, INPUT);
Wire.begin();
// return 0; // all ok
return;
}
---
Cordialement.
Joel Soranzo Président de l'association VoRoBoTics
Fabmanager du VoLab à Vauréal
Premier fablab du Val d'Oise
Formateur informatique, robotique et impression 3D indépendant.
site internet http://www.vorobotics.com
[3]mail : ***@***.*** tel 06.23.41.24.22
Le 2022-05-20 06:00, David Nuñez a écrit :
I don't know how but I made it work, I don't know what caused it, but
it worked correctly again after disconnecting and reconnecting the rtc
module, maybe the module was blocked.
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you are subscribed to this
thread.Message ID:
***@***.***>
|
Hello dear, `if(!rtc.begin()){ // Init rtc module
}` |
Hello
I'm very happy to know that works for you.
I thing it is a buggy hardware too. I 'm electronic engeneer and despite
my many searches, I could not find the cause of this problem !
Good luck for the rest of your project ;-)
---
Cordialement.
Joel Soranzo Président de l'association VoRoBoTics
Fabmanager du VoLab à Vauréal
Premier fablab du Val d'Oise
Formateur informatique, robotique et impression 3D indépendant.
site internet http://www.vorobotics.com
[3]mail : ***@***.*** tel 06.23.41.24.22
Le 2022-05-21 20:06, David Nuñez a écrit :
> Hello I allready have this pb with DS3231 RTC clock. Sometimes it
> freezes and as it have a battery, chip can stays in this state when we
> do a power off followed by a power on. I find a bypass method on the
> web, bellow i2cRecovery function (source :
> https://forum.arduino.cc/t/ds3231-and-i2c-problem/576700/5 ):
Hello dear,
The solution he proposed was successful, after placing said function
when losing communication with the rtc when starting, it runs and
allows the program to work without problems, the strange thing is that
the error is intermittent, during some reboots it works without
blocking and in some others it does require the use of i2c_recovery();,
but here the important thing is that now it always works on every start
with that function,
Thank you very much, I'm still curious about what really generates this
lock, maybe something at the hw level?
if(!rtc.begin()){ // Init rtc module Serial.println("Error Couldn't
find RTC Module"); i2c_recovery(); // This maybe solved the bug of RTC
Hold Cold }
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you commented.Message ID:
***@***.***>
|
Hello, I am trying to use this library in conjunction with the RTClib library, both use i2c, I have both devices connected in SDA and SCL, if I use them in the code separately there is no problem, but if I insert them in the code together Both libs and I try to use them have an error, the device address of this lib is 0x58 and of the rtc is 0x68, so I do not see an address conflict, could you support me, maybe I missed something.
` ioexp.begin();
Serial.println( "IO Expander: " + String(CNanoI2CIOExpander::initOk?"Ready":"Error") );
for(i = 0; i <= 10; i++){
ioexp.pinMode(i, OUTPUT);
}
The text was updated successfully, but these errors were encountered: