The ARM 7 processor in the netduino features an internal low-power oscillator and a programmable clock signal generator for its own timing needs but it is not intended to be a dedicated, battery-backed, date / time keeping system like the Maxim DS1307 real-time clock.
The DS1307 has the following features:
- Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the week, and Year with Leap-Year Compensation Valid Up to 2100
- 56-Byte, Battery-Backed, General-Purpose RAM with Unlimited Writes (very useful on a netduino to store configuration data!)
- I²C Serial Interface
- Programmable Square-Wave Output Signal
- Automatic Power-Fail Detect and Switch Circuitry
- Consumes Less than 500nA in Battery-Backup Mode with Oscillator Running.
Connecting the clock module to a netduino over I2C is trivial:
- netduino analog pin 4 -> SDA pin on the clock
- netduino analog pin 5 -> SCL pin on the clock
- netduino 5v pin -> Vcc pin on the clock
- netduino GND pin -> GND pin on the clock
A 1 or 2K pull-up resistor connected to 5v is only required when using the square-wave generation function on the clock (INT pin).
The square-wave function can generate frequencies at 1Hz, 4kHz, 8kHz and 32kHz and is useful in scenarios when a device relies on an external clock signal entirely, when a program relies on timely interrupts to do some work or to come back from a low-power sleep mode.
Here’s the oscilloscope output that I used to test the square-wave generation function:
To easily interface the DS1307 with the netduino, I wrote a C# driver which supports all of the chip’s features as I was unable to find one: most of the C# code out there appears to only support the date / time functions of the DS1307. You can find the driver and the test code here.