Modifications

Sauter à la navigation Sauter à la recherche
382 octets ajoutés ,  21 janvier 2013 à 12:09
Ligne 30 : Ligne 30 :  
== Premier test RTC ==
 
== Premier test RTC ==
   −
The first thing we'll demonstrate is a test sketch that will read the time from the RTC once a second. We'll also show what happens if you remove the battery and replace it since that causes the RTC to halt. So to start, remove the battery from the holder while the Arduino is not powered or plugged into USB. Wait 3 seconds and then replace the battery. This resets the RTC chip. Now load up the following sketch (which is also found in Examples->RTClib->ds1307) and upload it to your Arduino with the datalogger shield on!
+
La première chose que nous allons réaliser avec ce sketch de démonstration, c'est de lire l'heure depuis le module RTC une fois toutes les secondes.  
   −
  <nowiki>// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
+
Nous allons aussi voir ce qu'il arrive lorsque nous retirons et remplaçons la pile... cette opération interrompant le fonctionnement du RTC.
 +
 
 +
Donc, pour commencer, retirez la pile du son emplacement pendant qu'Arduino n'est pas alimenté (ou raccordé via USB). Attendez 3 secondes et ensuite, replacez la pile. Cela fait une remise-à-zéro (reset) du circuit RTC.
 +
 
 +
Maintenant ouvrez le sketch suivant sur votre Arduino (il est disponible dans Examples->RTClib->ds1307) et téléchargez le sur votre Arduino avec breakout DS1307 branché OU votre shield Datalogger raccordé.
 +
 
 +
  <nowiki>// fonctions Date et heure en utilisant
 +
// le RTC DS1307 RTC via bus I2C et librairie Wire
    
#include <Wire.h>
 
#include <Wire.h>
Ligne 45 : Ligne 52 :     
   if (! RTC.isrunning()) {
 
   if (! RTC.isrunning()) {
     Serial.println("RTC is NOT running!");
+
     Serial.println("RTC n est pas en cours de fonctionnement!");
     // following line sets the RTC to the date & time this sketch was compiled
+
     // La ligne suivante fixe la date et l'heure du RTC avec les date et heur de compilation du sketch
 
     //RTC.adjust(DateTime(__DATE__, __TIME__));
 
     //RTC.adjust(DateTime(__DATE__, __TIME__));
 
   }
 
   }
Ligne 74 : Ligne 81 :  
     Serial.println("d");
 
     Serial.println("d");
 
      
 
      
     // calculate a date which is 7 days and 30 seconds into the future
+
     // Calcule une date dans le future, date ayant
 +
    // 7 jours et 30 secondes de plus
 
     DateTime future (now.get() + 7 * 86400L + 30);
 
     DateTime future (now.get() + 7 * 86400L + 30);
 
      
 
      
     Serial.print(" now + 7d + 30s: ");
+
     Serial.print(" maintenant + 7d + 30s: ");
 
     Serial.print(future.year(), DEC);
 
     Serial.print(future.year(), DEC);
 
     Serial.print('/');
 
     Serial.print('/');
Ligne 96 : Ligne 104 :  
</nowiki>
 
</nowiki>
   −
Now run the Serial terminal and make sure the baud rate is set correctly at 57600
+
Démarrer le moniteur série et assurez vous qu'il soit bien configuré sur un débit de 57600 bauds.
   −
bps you should see the following:  
+
Vous devriez voir les messages suivants:  
    
[[Fichier:ADF-RTC-DS1307-USE-03.jpg]]
 
[[Fichier:ADF-RTC-DS1307-USE-03.jpg]]
   −
Whenever the RTC chip loses all power (including the backup battery) it will report the time as 0:0:0 and it won't count seconds (its stopped). Whenever you set the time, this will kickstart the clock ticking. So basically the upshot here is that you should never ever remove the battery once you've set the time. You shouldn't have to and the battery holder is very snug so unless the board is crushed, the battery wont 'fall out'
+
A chaque fois que le composant RTC perd toutes ses sources d'alimentation (incluant donc la pile de secours) l'heure retournée it will report the time as 0:0:0 and it won't count seconds (its stopped). Whenever you set the time, this will kickstart the clock ticking. So basically the upshot here is that you should never ever remove the battery once you've set the time. You shouldn't have to and the battery holder is very snug so unless the board is crushed, the battery wont 'fall out'
    
== Fixer l'heure ==
 
== Fixer l'heure ==
29 861

modifications

Menu de navigation