Bonjour,
Je souhaite pouvoir mettre à l'heure l'horloge interne de l' ARDUINO, avec un petit module DCF77 qui fournit la trame du signal radio (série d'impulsions).
Configuration:
MAC OSX (10.11.6)
Carte ARDUINO UNO (1.8.4)
Platine câblée de réception DCF + antenne,
sortie transistor collecteur ouvert, (donc + Résistance pullup 10K).
Je vois très bien le signal en sortie du module avec un oscilloscope.
Sortie du module DCF sur Pin 2 Arduino (interruption 0).
Je détecte également le signal sur l'Arduino avec le petit programme "DCF signal" des exemples fournis avec les librairies DCF77 que j'ai téléchargées.(Thys Elenbaas 2012).
"InternalClockSync" doit permettre la mise à l'heure de l'horloge interne de l'Arduino.
/*
- InternalClockSync.pde
- example code illustrating time synced from a DCF77 receiver
- Thijs Elenbaas, 2012
- This example code is in the public domain.
This example shows how to fetch a DCF77 time and synchronize
the internal clock. In order for this example to give clear output,
make sure that you disable logging from the DCF library. You can
do this by commenting out #define VERBOSE_DEBUG 1 in Utils.cpp.
NOTE: If you used a package manager to download the DCF77 library,
make sure have also fetched these libraries:
- Time
A package that includes all referenced libraries can be found at:
https://github.com/thijse/Zipballs/blob/master/DCF77/DCF77.zip?raw=true
*/
#include "DCF77.h"
#include "Time.h"
#define DCF_PIN 2 // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0 // Interrupt number associated with pin
time_t time;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);
void setup() {
Serial.begin(9600);
DCF.Start();
Serial.println("Waiting for DCF77 time ... ");
Serial.println("It will take at least 2 minutes until a first update can be processed.");
}
void loop() {
delay(1000);
time_t DCFtime = DCF.getTime(); // Check if new DCF77 time is available
if (DCFtime!=0)
{
Serial.println("Time is updated");
setTime(DCFtime);
}
digitalClockDisplay();
}
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);
}
Pour éviter une erreur de compilation j'ai remplacé #include<Time.h> par #include<TimeLib.h>.
A l'exécution du programme l'heure n'est jamais mise à jour; la date reste fixée au 1 janvier 1970 !
Je ne trouve pas de solution, les conseils seront les bienvenus.
Merci d'avance.
Rodolphe.