Help creating library from existing code for WWVB

Thanks to previous contributors in the archived "Arduino and atomic clock (WWVB) receiver". For others interested in WWVB there is good information and code at Popular Sci's website. I came across wwvb while working on an automated gardening system and found other time solutions unreliable. I'm now trying to use wwvb in addition to an ds3234 rtc to control some relay's from temp/humidity sensor and some logic. I have some programming experience mostly with JAVA and would like to use existing code to create a library so then I can just import libraries for the various ICs and sensors into my code to make it cleaner and help the community by creating a new library. Attached to this post is the cpp and h files along with a text file of the current errors I get when importing/using the library in the IDE.

A little background on the code: I basically took the code from the Popular Sci's article but stripped out all the lcd, rtc, and led light used in that project so I was left with just the code for the wwvb receiver. I hooked up the wwvb to an arduino uno r3 and was getting a signal so I took that sketchbook code and tried to work it into a cpp and h file but I originally wanted to have a few functions that returned a string of the time but after getting compile errors about the strings I learned that it's probably not going to be possible to have functions that return strings so I commented those functions out but now I'm getting all these other crazy errors and so I thought I would see if some c++ gurus in the group can help.

WWVB.cpp (14.2 KB)

WWVB.h (843 Bytes)

compileError.txt (10.3 KB)

Include an #include <Arduino.h> to your WWVB.h file (uint8_t errors).

You can attach an interrupt only to a static class function, not a regular member function,
so you will have to find a different way to do what you want.

So cool Varela! I've made several devices by scavenging cheap "atomic" clocks for their antenna/receiver device This usually involves cutting four wires and some glue. Here is my latest one - it runs three clocks:

Thank you Whandall - I included the Arduino.h and I will have to do some research on static vs regular functions in c++.

Chris your clock looks clean - I was just going to try to bust open a $20 walmart "atomic clock" but the online IC was only $24. I'm thinking of buying an extra one because these seem like pretty useful add-on's for the arduino and pi's.

Thanks. Where, if you don't mind my asking, did you find the IC online. Everywhere I looked did not have them in stock. And what do you use for an antenna? I'm intrigued by the watch sized, Cmax variable frequency antenna.

Chris - I found them at tinkersphere

I don't know that I have a current use for the small antenna but it looks very cool. I was thinking of going the other way

I have two of those same WWVB boards and ferrite rod antennas, (but not from tinkersphere) and I was only ever able to get a board to sync to WWVB once. Then I moved the board or the antenna and neither of them has ever worked since.
Is there any magic incantation needed?

Pete

el_supremo:
Is there any magic incantation needed?

We have several clocks that synchronize to WWVB. Some thoughts on synchronizing...

• They only synchronize after dark. They have never been able to synchronize while the sun shines.

• Metal (car, filing cabinet) interferes.

• Concrete (slab floor) interferes.

• Elevation helps (the clocks on the second floor are a tiny bit more reliable).

• Assuming your IP address indicates your rough geography, I am much closer to Colorado than you. I suspect that matters.

• Antenna orientation can be very significant: http://tf.nist.gov/general/pdf/2422.pdf ... "Most RCC antennas are directional and achieve maximum gain when they are positioned broadside to the transmit antenna in Fort Collins, Colorado."

Finally, Udo Klein has done amazing work with DCF77 (the German equivalent)...
https://www.google.com/search?q=udo+klein+DCF77
https://www.google.com/search?q=udo+klein+DCF77+site:forum.arduino.cc

el_supremo:
I have two of those same WWVB boards and ferrite rod antennas, (but not from tinkersphere) and I was only ever able to get a board to sync to WWVB once. Then I moved the board or the antenna and neither of them has ever worked since.
Is there any magic incantation needed?

Pete

Various noise source can kill the signal. Things around the 1Khz range are particulary bad like LCDs, or matrix LEDs.
So if your antenna is close to one of those or in some cases a computer, it may not work.
Also, some power supplies like cheap AC plugin USB supplies are very noisy and will insert so much noise that no signal can be reliably sensed.

In terms of signal,
for best results the ferrite rod needs to be perpendicular to the signal wave front.
i.e. if you drew a line between you and colorado springs, the best reception will be when the rod is perpendicular to that line.
If you place the rod parallel to that line, you will likely never sync.

I found that reception at dusk and dawn was often not good enough to sync.
In my area there were also certain hours where local radio stations cranked up power that create interference.

But since it should be treated as a background sync to correct a free running clock, a single sync per day is typically good enough to keep accurate time and get daylight time change information.

If you have enough status information (like LEDs) it can be pretty obvious if the problem is noise or lack of signal.
I use an RGB led and use various colors to indicate status of bits, markers, frames and errors.
1 bit per second makes it easy to see the status on a bit by bit basis.

--- bill

bperrybap:
Various noise source can kill the signal. Things around the 1Khz range are particulary bad like LCDs, or matrix LEDs.
So if your antenna is close to one of those or in some cases a computer, it may not work.
Also, some power supplies like cheap AC plugin USB supplies are very noisy and will insert so much noise that no signal can be reliably sensed.

In terms of signal,
for best results the ferrite rod needs to be perpendicular to the signal wave front.
i.e. if you drew a line between you and colorado springs, the best reception will be when the rod is perpendicular to that line.
If you place the rod parallel to that line, you will likely never sync.

I found that reception at dusk and dawn was often not good enough to sync.
In my area there were also certain hours where local radio stations cranked up power that create interference.

But since it should be treated as a background sync to correct a free running clock, a single sync per day is typically good enough to keep accurate time and get daylight time change information.

If you have enough status information (like LEDs) it can be pretty obvious if the problem is noise or lack of signal.
I use an RGB led and use various colors to indicate status of bits, markers, frames and errors.
1 bit per second makes it easy to see the status on a bit by bit basis.

--- bill

I usually have a pretty easy time syncing anytime between dusk and mid-morning.

An earlier iteration of the clock above used a quad 7-segment display. The clock would not sync at all with the display running. Then I switched it with an OLED, and the problem went away, mostly. I put ferrite tori on the I2C wires to the display, and it seems to help.

A row of 5 LEDs gives me status on syncing (error, frame, mark, logic 1, and logic 0, each powered through a 1960s style metal can transistor) so I can tell when it's having a hard time. Like if there is a storm anywhere between here and Colorado (when it becomes a lightening detector.)