PCF8523 I2c ne bouge pas

Bonjour je voudrais intégrer mon RTC pcf 8523 sur une arduino nano au design maison

le Microcontroleur et une NINA-B306-00B, le même qui anime la Arduino 33 BLE.
Sur ce Microcontrôleur nous avons deux I2C séparé SDA/SCL d'un coté et SDA1/SCL1 de l'autre coter utilisé pour tout les capteurs embarqué sur la carte.

De base l'IMU 9axes et ses librairies son configurer pour être utilisé sur SDA1/SCL1 ce type de Micro ne peux pas faire marché deux I2C en même temps, du coup au lieu de passer d'un i2c à l'autre j'ai choisie dans le disign hardware de mettre le RTC PCF 8523 sur l'i2c(sda1/scl1) alors que sa librairie le cherche dans SDA/SCL. l'adresse du RTC est 0x68.

je suis alimenté sur batterie ou USB mais ca change rien j'utilise un régulateur step up step down pour maintenir la tension à 3.3v en permanence et ca peu importe le niveau de la batterie qui va de 5.5v à 1.8v

Le PCF8523 est certes moins précis il perd 80s tout les 35jours m sa précision surtout pour une activité de quelque heures maximum 48h n'est pas un problème

Le PCF 8523 et alimenté a travers un régulateur a découpage step up step down pas de problème d'alimentation quelque soit le niveau de la batterie sa marche ou pas car on a 3.3v en sortie ou rien.

Cordialement JMi

Bonsoir,
Je ne connais pas très bien votre module RTC. Je sais seulement qu'il n'est pas précis. Préférez un module DS3231.
Votre module a t'il été mis à l'heure ?
Utilisez vous la bonne librairie ?
Est-il bien connecté sur A4 A5 ?
Votre microcontrôleur est il bien un arduino nano classique (Atmega328) ?

Bonne soirée.

hello
peut etre une piste ICI, (à lire en entier)

edit:
dans ton code as tu ces lignes?

if (! rtc.initialized() || rtc.lostPower()) {
    Serial.println("RTC is NOT initialized, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
    //
    // Note: allow 2 seconds after inserting battery or applying external power
    // without battery before calling adjust(). This gives the PCF8523's
    // crystal oscillator time to stabilize. If you call adjust() very quickly
    // after the RTC is powered, lostPower() may still return true.
  }

Bonsoir

en complément :

-comment est alimenté le PCF8523 ? (Vss ? Vbat ?)

coucou philipe Non le PCF8523 est parfait pour une utilisation de 24/48h sa consommation en mode veille est de quelque nano ampère et sa derive est de 80s sur 40j ca va ... pour une utilisation de 7h a 48h max en continue.

Il est Impossible de mettre le module a l'heure l"i2c ne peut pas se connecter car la librairie que j'utilise cherche l'i2c sur sda/scl. Et Là tu touche au bute "la bonne librairie" ou alors modifier la librairie pour qu'il mette le RTC sur sda1/scl1 au lieu de sda /scl.

Non je n'utilise pas un atmega 328 mais ceci.

compatible arduino

bonsoir al1fch le pcf et le Nina son alimenté par usb qui passe par un chargeur de batterie Littium et en parallèle attaque un régulateur step up step down dont le but et de donner 3.3v d'alimentions pour toute l'électronique du nina du pcf et des autres capteurs ca quelque que soit le niveau de la batterie de 5.5v a 1.8v donc ca marche sur usb (5v) et batterie lithium de 4.2 à 2.7v pour 1A en sortie.
si il ne peu pas fournir il se coupe.

Non, le PCF8523 ne dérive pas.
Le PCF8523 n'est constitué que de compteurs.

Ce qui dérive, c'est le quartz. Un quartz dérive en fonction de la température.
Des quartz, on en trouve à tous les prix et moins ils sont chers, plus ils dérivent.
Quand on achète un module, surtout à 1 ou 2 €, il est impossible de connaître la provenance du quartz.
Il est impossible d'annoncer une dérive sans mesures de qualification en température.
La dérive dépendra de la saison : elle sera plus faible au printemps/automne qu'en hiver/été.

Le gros avantage du DS3231 qui a été proposé est qu'il n'y a pas de quartz mais des MEMS.

Les MEMS dérivent aussi, mais comme ils sont "construit" sur la même puce de silicium que les compteurs le fabricant MAXIM a ajouté une sonde de température, toujours sur le silicium, et effectue une correction en fonction de la température.
MAXIM est le maître total du produit DS3231, il peut garantir une dérive.

En 2022, on ne se pose pas de question, on prend un DS3231.

Extrait de la documentation MAXIM
quartz_ds3231

Bonjour @jmingargiola,

Je ne suis pas assez compétent pour vous répondre car Je ne connais pas du tout votre matériel et surtout votre montage.

Cependant J'ai trouvé deux modules RTC différents chez Adafruit :

Dans le deuxième lien, on vous oriente vers une bibliothèque arduino mais je pense que vous êtes déjà passé par là !
@al1fch et @68tjs sont bien plus compétents que moi, ils sauront mieux vous renseigner.

Bonne journée.

Tu omets de préciser laquelle, malgré la question posée :

La librairie AdaFruit ?
Dans ce cas la méthode begin() propose un paramètre :

  bool begin(TwoWire *wireInstance = &Wire);

programme test PCF8523


// Date and time functions using a PCF8523 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_PCF8523 rtc;

ca marche pas car je pense qu'il travail sur sda/scl et moi j'ai tout connecter sur sda1/scl1

par contre un autre i2c scl1/sda1 marche avec ce programme pour l'imu

/*
  Arduino LSM9DS1 - Simple Accelerometer

  This example reads the acceleration values from the LSM9DS1
  sensor and continuously prints them to the Serial Monitor
  or Serial Plotter.

  The circuit:
  - Arduino Nano 33 BLE Sense

  created 10 Jul 2019
  by Riccardo Rizzo

  This example code is in the public domain.
*/

#include <Arduino_LSM9DS1.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Started");

je ne fais pas de code ou très peu moi je ne fait que dur hardware donc j'ai un peu besoin d'aide pour router des périphérique sur l'autre i2c

La librairie AdaFruit ?
Dans ce cas la méthode begin() propose un paramètre :

bool begin(TwoWire *wireInstance = &Wire);

il me semble que c'est ca mais il font quoi ici ?

J'ai l'impression que tu n'as pas compris ma réponse.
La méthode begin() accepte un argument te permettant de changer d'I2C.
Un objet Wire1 existe apparemment.

non ca c'est sur j'ai pas compris tu peux m'expliqué :smiley:
je sais pas par ou commencer déjà ....

par exemple dans ce code il n'utilise pas wire...


 :slight_smile: 
/ Date and time functions using a PCF8523 RTC connected via I2C and Wire lib
#include "RTClib.h"


RTC_PCF8523 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  Serial.begin(57600);

#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    while (1) delay(10);
  }

  if (! rtc.initialized() || rtc.lostPower()) {
    Serial.println("RTC is NOT initialized, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
    //
    // Note: allow 2 seconds after inserting battery or applying external power
    // without battery before calling adjust(). This gives the PCF8523's
    // crystal oscillator time to stabilize. If you call adjust() very quickly
    // after the RTC is powered, lostPower() may still return true.
  }

  // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

  // When the RTC was stopped and stays connected to the battery, it has
  // to be restarted by clearing the STOP bit. Let's do this to ensure
  // the RTC is running.
  rtc.start();

   // The PCF8523 can be calibrated for:
  //        - Aging adjustment
  //        - Temperature compensation
  //        - Accuracy tuning
  // The offset mode to use, once every two hours or once every minute.
  // The offset Offset value from -64 to +63. See the Application Note for calculation of offset values.
  // https://www.nxp.com/docs/en/application-note/AN11247.pdf
  // The deviation in parts per million can be calculated over a period of observation. Both the drift (which can be negative)
  // and the observation period must be in seconds. For accuracy the variation should be observed over about 1 week.
  // Note: any previous calibration should cancelled prior to any new observation period.
  // Example - RTC gaining 43 seconds in 1 week
  float drift = 43; // seconds plus or minus over oservation period - set to 0 to cancel previous calibration.
  float period_sec = (7 * 86400);  // total obsevation period in seconds (86400 = seconds in 1 day:  7 days = (7 * 86400) seconds )
  float deviation_ppm = (drift / period_sec * 1000000); //  deviation in parts per million (μs)
  float drift_unit = 4.34; // use with offset mode PCF8523_TwoHours
  // float drift_unit = 4.069; //For corrections every min the drift_unit is 4.069 ppm (use with offset mode PCF8523_OneMinute)
  int offset = round(deviation_ppm / drift_unit);
  // rtc.calibrate(PCF8523_TwoHours, offset); // Un-comment to perform calibration once drift (seconds) and observation period (seconds) are correct
  // rtc.calibrate(PCF8523_TwoHours, 0); // Un-comment to cancel previous calibration

  Serial.print("Offset is "); Serial.println(offset); // Print to control offset

}

void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");

    // calculate a date which is 7 days, 12 hours and 30 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));

    Serial.print(" now + 7d + 12h + 30m + 6s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();

    Serial.println();
    delay(3000);
}

Bonjour

par exemple dans ce code il n'utilise pas wire...

 :slight_smile: 
/ Date and time functions using a PCF8523 RTC connected via I2C and Wire lib
On peut lire "**connected via Wire lib**"

pas fous  chez Adafruit, ile ne vont pas s'embêter à réinventer ce qui existe  déjà  !

bon si je comprend ce que tu me dit pour que ca marche je dois remplacé ts les wire dans wire.h par wire1 ?

En supposant que Wire1 corresponde à SDA1 SCL1.

#include <Wire.h>
extern TwoWire Wire1;

void setup()
{
Wire1.begin();

Serial.begin(9600);
while (!Serial);
Serial.println("\nI2C Scanner");
}

void loop()
{
byte error, address;
int nDevices;

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire1.beginTransmission(address);
error = Wire1.endTransmission();

if (error == 0)
{
  Serial.print("I2C device found at address 0x");
  if (address<16)
    Serial.print("0");
  Serial.print(address,HEX);
  Serial.println("  !");

  nDevices++;
}
else if (error==4)
{
  Serial.print("Unknown error at address 0x");
  if (address<16)
    Serial.print("0");
  Serial.println(address,HEX);
}    

}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");

delay(2000); // wait 5 seconds for next scan
}




resusltat ::


Scanning...
I2C device found at address 0x1E !
I2C device found at address 0x68 !
I2C device found at address 0x6B !
done


du coup j'ai bien mon imu et mon RTC sur le bus :D je commence a kiffé La vie

Bon ca marche pas j'ai peut être fait les chose comme une brutasse ???

// Date and time functions using a PCF8523 RTC connected via I2C and Wire lib
#include "RTClib.h"
#include <Wire.h>
extern TwoWire Wire1;

RTC_PCF8523 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  Serial.begin(57600);

#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin(&Wire1)) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    while (1) delay(10);
  }

  if (! rtc.initialized(&Wire1) || rtc.lostPower(&Wire1)) {
    Serial.println("RTC is NOT initialized, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
    //
    // Note: allow 2 seconds after inserting battery or applying external power
    // without battery before calling adjust(). This gives the PCF8523's
    // crystal oscillator time to stabilize. If you call adjust() very quickly
    // after the RTC is powered, lostPower() may still return true.
  }

  // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

  // When the RTC was stopped and stays connected to the battery, it has
  // to be restarted by clearing the STOP bit. Let's do this to ensure
  // the RTC is running.
  rtc.start();

   // The PCF8523 can be calibrated for:
  //        - Aging adjustment
  //        - Temperature compensation
  //        - Accuracy tuning
  // The offset mode to use, once every two hours or once every minute.
  // The offset Offset value from -64 to +63. See the Application Note for calculation of offset values.
  // https://www.nxp.com/docs/en/application-note/AN11247.pdf
  // The deviation in parts per million can be calculated over a period of observation. Both the drift (which can be negative)
  // and the observation period must be in seconds. For accuracy the variation should be observed over about 1 week.
  // Note: any previous calibration should cancelled prior to any new observation period.
  // Example - RTC gaining 43 seconds in 1 week
  float drift = 43; // seconds plus or minus over oservation period - set to 0 to cancel previous calibration.
  float period_sec = (7 * 86400);  // total obsevation period in seconds (86400 = seconds in 1 day:  7 days = (7 * 86400) seconds )
  float deviation_ppm = (drift / period_sec * 1000000); //  deviation in parts per million (μs)
  float drift_unit = 4.34; // use with offset mode PCF8523_TwoHours
  // float drift_unit = 4.069; //For corrections every min the drift_unit is 4.069 ppm (use with offset mode PCF8523_OneMinute)
  int offset = round(deviation_ppm / drift_unit);
  // rtc.calibrate(PCF8523_TwoHours, offset); // Un-comment to perform calibration once drift (seconds) and observation period (seconds) are correct
  // rtc.calibrate(PCF8523_TwoHours, 0); // Un-comment to cancel previous calibration

  Serial.print("Offset is "); Serial.println(offset); // Print to control offset

}

void loop () {
    DateTime now = rtc.now(&Wire1);

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");

    // calculate a date which is 7 days, 12 hours and 30 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));

    Serial.print(" now + 7d + 12h + 30m + 6s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();

    Serial.println();
    delay(3000);
}

Le message "Couldn't find RTC" est affiché ?

o matching function for call to 'RTC_PCF8523::initialized(TwoWire*)'