Posts with «wise clock 4» label

ZeeClock - nice mod running on Wise Clock 4

Here we have the first "independent" mod running on Wise Clock 4, thanks to Mr. Jon S!



Jon shared the code (download it from here) and added this description:

This is an alarm clock for my toddler who can't tell time (of course). It uses colors to tell him when he should be sleeping and when he should get up.
I didn't need to, but I wrote all the code so it's self contained including setting multiple alarms, setting the time, and turning the audio on and off.
It's not perfect (I'm an artist not a programmer so the code is a bit of a mess), but it does the job.

I think it's a great job!
Thanks again Jon.


ZeeClock - nice mod running on Wise Clock 4

Here we have the first "independent" mod running on Wise Clock 4, thanks to Mr. Jon S!



Jon shared the code (download it from here) and added this description:

This is an alarm clock for my toddler who can't tell time (of course). It uses colors to tell him when he should be sleeping and when he should get up.
I didn't need to, but I wrote all the code so it's self contained including setting multiple alarms, setting the time, and turning the audio on and off.
It's not perfect (I'm an artist not a programmer so the code is a bit of a mess), but it does the job.

I think it's a great job!
Thanks again Jon.

Wise Clock 4 - time synchronization with GPS

This is my first foray into the world of GPS, made possible by the GPS XBee kit.
With Wise Clock 4 offering support for XBee, this little GPS module from seeedstudio seemed like a nice fit. The purpose is, of course, to synchronize the clock with the accurate time received from satellites.

Note: Some time ago I tried the WWVB atomic clock radio receiver module CMMR-6. It comes with a 60mm ferrite rod, pretty inadequate for receiving the Colorado radio signal in Toronto, more than 2200km away. On top of the fact that it is finicky (never worked for me), it is also bulky (the ferrite rod) and fragile (the thin antenna wire).

First, I inserted the module into the XBee adapter from adafruit, which is connected (through the FTDI cable) to a terminal session (9600, 8, N, 1).















Messages started flowing in, right off the bat: wow!




















Next, I moved the GPS module onto the Wise Clock 4 and uploaded a sketch that uses TinyGPS library (modified by Justin).















Here is the serial monitor output.























For those who require maximum accuracy on top of the one provided by the DS3231 RTC chip itself, this GPS solution should do it.

Homework
Make the "Doomsday clock", like the one by Wyolum team shown in the video below, with Wise Clock 4 and 2 displays.


Wise Clock 4 - time synchronization with GPS

This is my first foray into the world of GPS, made possible by the GPS XBee kit.
With Wise Clock 4 offering support for XBee, this little GPS module from seeedstudio seemed like a nice fit. The purpose is, of course, to synchronize the clock with the accurate time received from satellites.

Note: Some time ago I tried the WWVB atomic clock radio receiver module CMMR-6. It comes with a 60mm ferrite rod, pretty inadequate for receiving the Colorado radio signal in Toronto, more than 2200km away. On top of the fact that it is finicky (never worked for me), it is also bulky (the ferrite rod) and fragile (the thin antenna wire).

First, I inserted the module into the XBee adapter from adafruit, which is connected (through the FTDI cable) to a terminal session (9600, 8, N, 1).















Messages started flowing in, right off the bat: wow!




















Next, I moved the GPS module onto the Wise Clock 4 and uploaded a sketch that uses TinyGPS library (modified by Justin).















Here is the serial monitor output.























For those who require maximum accuracy on top of the one provided by the DS3231 RTC chip itself, this GPS solution should do it.

Homework
Make the "Doomsday clock", like the one by Wyolum team shown in the video below, with Wise Clock 4 and 2 displays.

Wise Clock 4 - Using the RTC 1Hz "Heartbeat"

DS3231 can generate a square wave output signal through pin 3 (aptly named "SQW"). Same pin can be also activated (set low) when one of the two internal alarms is triggered (that's why this pin is also called "INT").

Wise Clock 4 has the INT/SQW pin connected to D2 through a jumper. Therefore, to be able to use this RTC signal, a jumper must connect the 2-header pins, as shown in the picture below (jumper is red, between processor and SD card socket).


















Since I don't seem to get things perfect from the first try, I forgot to add the mandatory 10k pull-up resistor (this is fixed in the next iteration of the board, shipping as of mid Dec 2011). Here is how you need to connect the pull-up resistor, as shown in the next photo. Solder one terminal of the resistor in the via (it fits the hole) and the other terminal to the 2-pin header.


















Once the hardware is ready, compile and upload this very simple sketch.

#include "WProgram.h"
#include "Wire.h"
#include "DS3231.h"


void rtc_interrupt()
{
  Serial.println(millis());
}


void setup()
{
  RTC.enableSQW();
  Serial.begin(57600);
  Serial.println("RTC square wave enabled");
  pinMode(2, INPUT);
  attachInterrupt(2, rtc_interrupt, RISING);
}


void loop()
{
}

The sketch (tested with Arduino IDE 22) enables the 1Hz square wave on the RTC and attaches an ISR ("interrupt service routine") that gets executed once every second. (You can see the output of the ISR function in the serial monitor.)

Notes:
  • The square wave is not enabled by default as DS3231 gets powered. To enable the square wave, bit 2 of the register 0x0E must be set to 0 (it is 1 by default).
  • The square wave frequency can be one of the 4 values: 1Hz, 1024Hz, 4096Hz and 9182Hz. This frequency is selected by setting 2 bits (3 and 4) in control register 0x0E (check page 13 of the datasheet).
  • The file DS3231.h (also required is DS3231.cpp) is the one included in the WiseClock3 library.

I see at least two applications where this square wave/interrupt line can be used:
  • RTC alarm waking up the clock from sleep mode;
  • chronometer.


Wise Clock 4 - Using the RTC 1Hz "Heartbeat"

DS3231 can generate a square wave output signal through pin 3 (aptly named "SQW"). Same pin can be also activated (set low) when one of the two internal alarms is triggered (that's why this pin is also called "INT").

Wise Clock 4 has the INT/SQW pin connected to D2 through a jumper. Therefore, to be able to use this RTC signal, a jumper must connect the 2-header pins, as shown in the picture below (jumper is red, between processor and SD card socket).


















Since I don't seem to get things perfect from the first try, I forgot to add the mandatory 10k pull-up resistor (this is fixed in the next iteration of the board, shipping as of mid Dec 2011). Here is how you need to connect the pull-up resistor, as shown in the next photo. Solder one terminal of the resistor in the via (it fits the hole) and the other terminal to the 2-pin header.


















Once the hardware is ready, compile and upload this very simple sketch.

#include "WProgram.h"
#include "Wire.h"
#include "DS3231.h"


void rtc_interrupt()
{
  Serial.println(millis());
}


void setup()
{
  RTC.enableSQW();
  Serial.begin(57600);
  Serial.println("RTC square wave enabled");
  pinMode(2, INPUT);
  attachInterrupt(2, rtc_interrupt, RISING);
}


void loop()
{
}

The sketch (tested with Arduino IDE 22) enables the 1Hz square wave on the RTC and attaches an ISR ("interrupt service routine") that gets executed once every second. (You can see the output of the ISR function in the serial monitor.)

Notes:
  • The square wave is not enabled by default as DS3231 gets powered. To enable the square wave, bit 2 of the register 0x0E must be set to 0 (it is 1 by default).
  • The square wave frequency can be one of the 4 values: 1Hz, 1024Hz, 4096Hz and 9182Hz. This frequency is selected by setting 2 bits (3 and 4) in control register 0x0E (check page 13 of the datasheet).
  • The file DS3231.h (also required is DS3231.cpp) is the one included in the WiseClock3 library.

I see at least two applications where this square wave/interrupt line can be used:
  • RTC alarm waking up the clock from sleep mode;
  • chronometer.

Data logging with Wise Clock 3/4

If you ever tried to compile the SD library (packaged with Arduino IDE 22 and 23) targeting the Sanguino board (which also covers Wise Clock 3 and Wise Clock 4), you got compilation errors.

For example, compiling Datalogger.pde with the Sanguino file setup detailed here, will give these kinds of errors:

Datalogger:67: error: 'class File' has no member named 'println'
Datalogger:67: error: 'dataString' was not declared in this scope

The main cause for these errors is missing files (e.g. Stream.h, WString.h). Even if you fix these compilation errors, Datalogger.pde sketch will still not work, and this is because SPI pins are incorrectly defined for Sanguino. (Note that the Datalogger sketch compiles and works fine for Arduino.)


I know that Arduino IDE 22 and 23 are no longer supported, but I bet many out there are still using them, as I do. Until I upgrade to Arduino 1.0, I think it is worth fixing the issue in these older IDEs.


So here is the quick recipe for covering the Sanguino board in Arduino 22 and 23 IDEs:

1. add the following section to Arduino-0022/hardware/arduino/boards.txt file:


##############################
sanguino.name=Sanguino
sanguino.upload.protocol=stk500
sanguino.upload.maximum_size=63488
sanguino.upload.speed=38400
sanguino.bootloader.low_fuses=0xFF
sanguino.bootloader.high_fuses=0xDC
sanguino.bootloader.extended_fuses=0xFD
sanguino.bootloader.path=atmega644p
sanguino.bootloader.file=ATmegaBOOT_644P.hex
sanguino.bootloader.unlock_bits=0x3F
sanguino.bootloader.lock_bits=0x0F
sanguino.build.mcu=atmega644p
sanguino.build.f_cpu=16000000L
sanguino.build.core=sanguino
sanguino.verbose=false

2. Download file sanguino22.zip and expand its content into the folder Arduino-0022/hardware/arduino/cores/. This will create the folder "sanguino" under "cores".

Sanguino22.zip contains the following files, copied from Arduino-0022/hardware/arduino/cores/arduino/:

















Only 2 4 of the original Arduino files have been modified specifically for Sanguino, and they are: pins_arduino.h
pins_arduino.c.
WInterrupts.c
wiring_private.h

Note (March 12/2012): I updated the zip file to include the last two files enumerated above. The original Arduino ones did not handle attachInterrupt() correctly, as the original Sanguino files (released a long time ago for version 18) did. So I just copied over the old files.

By following the 2 steps above, you should be able to compile sketches for the "Sanguino" target (selectable from the menu "Tools/Board" of the IDE). (A few extra steps are required to be able to burn the bootloader, but I will leave this out for now, for the sake of simplicity.)

Now try compiling and uploading Datalogger.pde and see the results for yourself: data is appended to the file datalog.txt on SD card.

Note: The Wise Clock 3/4 software handles reading from SD card just fine even with the old Sanguino files because the SPI pins are defined in the file mmc.cpp, which is part of the Wise Clock 3/4 library. The SD library relies on externally-defined (in file pins_arduino.h) SPI pins.

Guess why am I bringing up data logging on Wise Clock 4? :)

Data logging with Wise Clock 3/4

If you ever tried to compile the SD library (packaged with Arduino IDE 22 and 23) targeting the Sanguino board (which also covers Wise Clock 3 and Wise Clock 4), you got compilation errors.

For example, compiling Datalogger.pde with the Sanguino file setup detailed here, will give these kinds of errors:

Datalogger:67: error: 'class File' has no member named 'println'
Datalogger:67: error: 'dataString' was not declared in this scope

The main cause for these errors is missing files (e.g. Stream.h, WString.h). Even if you fix these compilation errors, Datalogger.pde sketch will still not work, and this is because SPI pins are incorrectly defined for Sanguino. (Note that the Datalogger sketch compiles and works fine for Arduino.)


I know that Arduino IDE 22 and 23 are no longer supported, but I bet many out there are still using them, as I do. Until I upgrade to Arduino 1.0, I think it is worth fixing the issue in these older IDEs.


So here is the quick recipe for covering the Sanguino board in Arduino 22 and 23 IDEs:

1. add the following section to Arduino-0022/hardware/arduino/boards.txt file:


##############################
sanguino.name=Sanguino
sanguino.upload.protocol=stk500
sanguino.upload.maximum_size=63488
sanguino.upload.speed=38400
sanguino.bootloader.low_fuses=0xFF
sanguino.bootloader.high_fuses=0xDC
sanguino.bootloader.extended_fuses=0xFD
sanguino.bootloader.path=atmega644p
sanguino.bootloader.file=ATmegaBOOT_644P.hex
sanguino.bootloader.unlock_bits=0x3F
sanguino.bootloader.lock_bits=0x0F
sanguino.build.mcu=atmega644p
sanguino.build.f_cpu=16000000L
sanguino.build.core=sanguino
sanguino.verbose=false

2. Download file sanguino22.zip and expand its content into the folder Arduino-0022/hardware/arduino/cores/. This will create the folder "sanguino" under "cores".

Sanguino22.zip contains the following files, copied from Arduino-0022/hardware/arduino/cores/arduino/:

















Only 2 4 of the original Arduino files have been modified specifically for Sanguino, and they are: pins_arduino.h
pins_arduino.c.
WInterrupts.c
wiring_private.h

Note (March 12/2012): I updated the zip file to include the last two files enumerated above. The original Arduino ones did not handle attachInterrupt() correctly, as the original Sanguino files (released a long time ago for version 18) did. So I just copied over the old files.

By following the 2 steps above, you should be able to compile sketches for the "Sanguino" target (selectable from the menu "Tools/Board" of the IDE). (A few extra steps are required to be able to burn the bootloader, but I will leave this out for now, for the sake of simplicity.)

Now try compiling and uploading Datalogger.pde and see the results for yourself: data is appended to the file datalog.txt on SD card.

Note: The Wise Clock 3/4 software handles reading from SD card just fine even with the old Sanguino files because the SPI pins are defined in the file mmc.cpp, which is part of the Wise Clock 3/4 library. The SD library relies on externally-defined (in file pins_arduino.h) SPI pins.

Guess why am I bringing up data logging on Wise Clock 4? :)


Buy Complete Wise Clock 4 kit - includes display and enclosure

When you buy the "Complete Wise Clock 4 kit", you get, on top, of the Wise Clock 4 kit, the 3216 bi-color (red/green/orange) LED display from Sure Electronics, plus the enclosure, consisting of two laser-cut plexiglass plates and the required hardware (spacers, screws etc) to assemble it.



  US$125 - free shipping to North America

The "complete kit" comes with everything you need to build a functional Wise Clock 4. You will need to add your own FAT16-formatted SD card (with the necessary files on it), the miniB USB power cable and, eventually, the XBee module (if you want Wise Clock 4 to display remote messages, sent through internet, for example).




Buy Complete Wise Clock 4 kit - includes display and enclosure

When you buy the "Complete Wise Clock 4 kit", you get, on top, of the Wise Clock 4 kit, the 3216 bi-color (red/green/orange) LED display from Sure Electronics, plus the enclosure, consisting of two laser-cut plexiglass plates and the required hardware (spacers, screws etc) to assemble it.



  US$125 - free shipping to North America

The "complete kit" comes with everything you need to build a functional Wise Clock 4. You will need to add your own FAT16-formatted SD card (with the necessary files on it), the miniB USB power cable and, eventually, the XBee module (if you want Wise Clock 4 to display remote messages, sent through internet, for example).