Bonjour,
J'ai acheté un kit de démarrage afin de m'initier à l’Arduino avant de me lancer dans un projet plus complexe. Je suis entrain d'essayer d'utiliser un module RTC DS3231 afin d'obtenir l'heure, la date, ... en temps réel. Cependant j'ai de nombreux messages d'erreur qui s'affichent lors de la compilation.
Je vous joint le code utilisé ainsi que les erreurs obtenues. C'est un exemple fourni par le revendeur "Elegoo", ceux-ci sont censé fonctionner, en réalité de nombreux exemples fonctionnent mais celui-ci non.. La librairie DS3231 est bien installée, et j'utilise Arduino 1.8.4.
//www.elegoo.com
//2016.12.9
#include <DS3231.h>
DS3231 clock;
RTCDateTime dt;
void setup()
{
Serial.begin(9600);
// Initialize DS3231
Serial.println("Initialize DS3231");;
clock.begin();
// Set sketch compiling time
clock.setDateTime(__DATE__, __TIME__);
// Set from UNIX timestamp
// clock.setDateTime(1397408400);
// Manual (YYYY, MM, DD, HH, II, SS
// clock.setDateTime(2016, 12, 9, 11, 46, 00);
}
void loop()
{
dt = clock.getDateTime();
Serial.print("Long number format: ");
Serial.println(clock.dateFormat("d-m-Y H:i:s", dt));
Serial.print("Long format with month name: ");
Serial.println(clock.dateFormat("d F Y H:i:s", dt));
Serial.print("Short format witch 12h mode: ");
Serial.println(clock.dateFormat("jS M y, h:ia", dt));
Serial.print("Today is: ");
Serial.print(clock.dateFormat("l, z", dt));
Serial.println(" days of the year.");
Serial.print("Actual month has: ");
Serial.print(clock.dateFormat("t", dt));
Serial.println(" days.");
Serial.print("Unixtime: ");
Serial.println(clock.dateFormat("U", dt));
Serial.println();
delay(1000);
}
Message d'erreur :
Arduino : 1.8.4 (Windows 7), Carte : "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
ATTENTION : La catégorie 'Real-time clock' dans la bibliothèque DS3231 n'est pas valide. Définition sur : 'Uncategorized'
DS3231_dateformat:6: error: 'RTCDateTime' does not name a type
RTCDateTime dt;
^
C:\Users\Florian\Desktop\Arduino\code\Lesson 19 Real Time Clock Module\DS3231_dateformat\DS3231_dateformat.ino: In function 'void setup()':
DS3231_dateformat:14: error: 'class DS3231' has no member named 'begin'
clock.begin();
^
DS3231_dateformat:17: error: 'class DS3231' has no member named 'setDateTime'
clock.setDateTime(__DATE__, __TIME__);
^
C:\Users\Florian\Desktop\Arduino\code\Lesson 19 Real Time Clock Module\DS3231_dateformat\DS3231_dateformat.ino: In function 'void loop()':
DS3231_dateformat:28: error: 'dt' was not declared in this scope
dt = clock.getDateTime();
^
DS3231_dateformat:28: error: 'class DS3231' has no member named 'getDateTime'
dt = clock.getDateTime();
^
DS3231_dateformat:31: error: 'class DS3231' has no member named 'dateFormat'
Serial.println(clock.dateFormat("d-m-Y H:i:s", dt));
^
DS3231_dateformat:34: error: 'class DS3231' has no member named 'dateFormat'
Serial.println(clock.dateFormat("d F Y H:i:s", dt));
^
DS3231_dateformat:37: error: 'class DS3231' has no member named 'dateFormat'
Serial.println(clock.dateFormat("jS M y, h:ia", dt));
^
DS3231_dateformat:40: error: 'class DS3231' has no member named 'dateFormat'
Serial.print(clock.dateFormat("l, z", dt));
^
DS3231_dateformat:44: error: 'class DS3231' has no member named 'dateFormat'
Serial.print(clock.dateFormat("t", dt));
^
DS3231_dateformat:48: error: 'class DS3231' has no member named 'dateFormat'
Serial.println(clock.dateFormat("U", dt));
^
exit status 1
'RTCDateTime' does not name a type
Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.
D'avance merci pour votre aide !