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? :)

Comments

Popular posts from this blog

How to Remove �Powered by Blogger� attribution From Blogspot Blog?

Fritzing: an Electronic Design Automation software