Hi all
I have trouble getting my DCF77 (radio clock) module working with my Arduino Uno.
The following code works as expected and returns Bits as explained on the Website of Thijs Elenbaas (http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-signal/):
/*
* DCFSignal.ino - DCF77 debug Example
* Thijs Elenbaas, 2012
* This example code is in the public domain.
This simple example shows the raw signal coming from the DCF decoder.
Pulse-to-Pulse is approximately 1000 ms and pulse with is approx 100ms or 200ms
The axis underestimates the elapsed time slightly, because a single loop takes a bit
longer than 10ms.
*/
#define BLINKPIN 13
#define DCF77PIN 2
int prevSensorValue=0;
void setup() {
Serial.begin(9600);
pinMode(DCF77PIN, INPUT);
pinMode(13, OUTPUT);
Serial.println("0ms 100ms 200ms 300ms 400ms 500ms 600ms 700ms 800ms 900ms 1000ms 1100ms 1200ms");
}
void loop() {
int sensorValue = digitalRead(DCF77PIN);
if (sensorValue==1 && prevSensorValue==0) { Serial.println(""); }
digitalWrite(BLINKPIN, sensorValue);
Serial.print(sensorValue);
prevSensorValue = sensorValue;
delay(10);
}
however if i try to run this code, of which i expect the timestamp as a response (http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-library/):
/*
* DCFBinaryStream.ino
* example code illustrating time synced from a DCF77 receiver
* Thijs Elenbaas, 2012
* This example code is in the public domain.
This example shows the binary stream generated by the
pulse train coming from the DCF decoder and the resulting
time
In order for this example to give output from the DCF library,
make sure that logging is turned on in the DCF library. You can
do this by adding the #define VERBOSE_DEBUG 1 in Utils.cpp.
*/
#include <DCF77.h> //https://github.com/thijse/Arduino-Libraries/downloads
#include <Time.h> //http://www.arduino.cc/playground/Code/Time
#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);
Serial.println("1 - binary 1 corresponding to long pulse");
Serial.println("0 - binary 0 corresponding to short pulse");
Serial.println("BF - Buffer is full at end of time-sequence. This is good");
Serial.println("EoB - Buffer is full before at end of time-sequence");
Serial.println("EoM - Buffer is not yet full at end of time-sequence");
DCF.Start();
}
void loop() {
delay(1000);
time_t DCFtime = DCF.getTime();
if (DCFtime!=0) {
digitalClockDisplay(DCFtime);
}
}
void digitalClockDisplay(time_t _time){
tmElements_t tm;
breakTime(_time, tm);
Serial.println("");
Serial.print("Time: ");
Serial.print(tm.Hour);
Serial.print(":");
printDigits(tm.Minute);
Serial.print(":");
printDigits(tm.Second);
Serial.print(" Date: ");
Serial.print(tm.Day);
Serial.print(".");
Serial.print(tm.Month);
Serial.print(".");
Serial.println(tm.Year+1970);
}
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);
}
throws me following error :
"variable or field 'digitalClockDisplay' declared void"
and if i declare it as an "int" another error pops up, that tells me "time_t" isnt declared in that scope.
Help is apprechiated.
Thanks in advance, Fabian