The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Full-featured driver / test code for the Maxim DS1307 real-time clock
Being unable to find a C# driver implementing the complete DS1307 spec, I wrote one and figured I'd share it with the community http://fabienroyer.w...eal-time-clock/
Fabien,
I have downloaded the zip file (and some of your other zip files), both winrar, 7h and the builtin in win 7 says that the files are damaged (downloaded both with IE8 and Chrome) .
Can you please check your website.
/Jan Olof
Hi Fabien
Did you test the DS1307 code with the netduino plus ? Unfortunately, my device is not able to communicate with the DS1307. I'm sure, the issue is not the code, because I can't see any activity on the 4+5 pin of the netduino-plus with a logic analyzer. So I'm not sure, the I2C works with the netduino-plus well.
I'm using the folloing firmeware:
HalSystemInfo.halVersion: 4.1.2821.0
HalSystemInfo.halVendorInfo: Netduino Plus (v4.1.1.0 a6) by Secret Labs LLC
Regards
Joschua
Hi Joschua,
I have never tested the code on a N+.
I'm wondering: can you share a link to the datasheet of the DS1307 clock module you're using?
You may need pull-up resistors if the module doesn't have any on board.
Cheers,
-Fabien.
Hi, I’m new here. I’m having a hard time trying to display time and date on a LCD.
I have wired up a Netduino, DS1307 RTC module and a 20x4 HD44780-controlled LCD on a breadboard. I can get “Hello World” to appear on the LCD, but not time and date.
Any help is welcome. Thanks in advance.
Hi, I’m new here. I’m having a hard time trying to display time and date on a LCD.
I have wired up a Netduino, DS1307 RTC module and a 20x4 HD44780-controlled LCD on a breadboard. I can get “Hello World” to appear on the LCD, but not time and date.
Any help is welcome. Thanks in advance.
Hi,
Could you describe the problems you are having? I.E. does it just display garbage, Not at all etc...
Hi Stuart,
Here is the unfinished Program.cs code. The LCD screen is blank.
Error messages:
The name ‘_ds1307’ does not exist in the current context.
The type or namespace name ‘DS1307’ could not be found.
Since my RTC module is a Sparkfun unit, I placed two 1.5K resistors between SDA/5V and SCL/5V. Thanks for any suggestion.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using MicroLiquidCrystal;
using Devices;
namespace NetduinoClock
{
public class Program
{
public static void Main()
{
var lcdProvider = new GpioLcdTransferProvider(
Pins.GPIO_PIN_D12, // RS
Pins.GPIO_NONE, // RW
Pins.GPIO_PIN_D11, // enable
Pins.GPIO_PIN_D9, // d0
Pins.GPIO_PIN_D8, // d1
Pins.GPIO_PIN_D7, // d2
Pins.GPIO_PIN_D6, // d3
Pins.GPIO_PIN_D5, // d4
Pins.GPIO_PIN_D4, // d5
Pins.GPIO_PIN_D3, // d6
Pins.GPIO_PIN_D2); // d7
var lcd = new Lcd(lcdProvider);
lcd.Begin(20, 4);
_ds1307 = new DS1307();
_ds1307.Halt(false);
Debug.Print("Clock: " + _ds1307.Get().ToString("HH:mm dd/MM/yyyy"));
Utility.SetLocalTime(_ds1307.Get());
Debug.Print("Dev: " + DateTime.Now.ToString("HH:mm dd/MM/yyyy"));
}
}
}
The Explorer (right side) window contains these files:
DS1307.cs
GpioLcdTransferProvider.cs
ILcdTransferProvider.cs
Lcd.cs
Program.cs
http://10rem.net/blo...th-the-netduino
I see nowhere in the code where the LCD screen is actually being written to. Debug.Print() only writes to the Output window of the Netduino. You need to use a call to lcd.Write() instead with the properly formatted date string.
Hi Fabien,
Thanks for your advice. I can get the date and time to appear on the LCD screen, but the time does not update itself.
LCD Output:
07/20/2011 22:10:00
How do you make the time output increment?
Is it possible to display the month in char (eg Jul) and the day (eg Friday)?
Here’s the updated Program.cs code.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using MicroLiquidCrystal;
using netduino.helpers.Hardware;
namespace NetduinoClock
{
public class Program
{
public static void Main()
{
var lcdProvider = new GpioLcdTransferProvider(
Pins.GPIO_PIN_D12, // RS
Pins.GPIO_NONE, // RW
Pins.GPIO_PIN_D11, // enable
Pins.GPIO_PIN_D9, // d0
Pins.GPIO_PIN_D8, // d1
Pins.GPIO_PIN_D7, // d2
Pins.GPIO_PIN_D6, // d3
Pins.GPIO_PIN_D5, // d4
Pins.GPIO_PIN_D4, // d5
Pins.GPIO_PIN_D3, // d6
Pins.GPIO_PIN_D2); // d7
var lcd = new Lcd(lcdProvider);
lcd.Begin(20, 4);
var clock = new DS1307();
// Set the clock to some arbitrary date / time
clock.Set(new DateTime(2011, 7, 20, 22, 10, 00));
// Make sure the clock is running
clock.Halt(false);
// Test reading RTC clock registers
lcd.Write(clock.Get().ToString());
}
}
}
Hi Fabien,
Thanks for the info. The clock is now counting.
Is it possible to display the time in 12-hour format showing AM/PM?
Here’s the updated Program.cs code.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using MicroLiquidCrystal;
using netduino.helpers.Hardware;
namespace NetduinoClock
{
public class Program
{
public static void Main()
{
var lcdProvider = new GpioLcdTransferProvider(
Pins.GPIO_PIN_D12, // RS
Pins.GPIO_NONE, // RW
Pins.GPIO_PIN_D11, // enable
Pins.GPIO_PIN_D9, // d0
Pins.GPIO_PIN_D8, // d1
Pins.GPIO_PIN_D7, // d2
Pins.GPIO_PIN_D6, // d3
Pins.GPIO_PIN_D5, // d4
Pins.GPIO_PIN_D4, // d5
Pins.GPIO_PIN_D3, // d6
Pins.GPIO_PIN_D2); // d7
var lcd = new Lcd(lcdProvider);
lcd.Begin(20, 4);
var clock = new DS1307();
// Set the clock to some arbitrary date / time (do once)
clock.Set(new DateTime(2011, 7, 22, 00, 00, 00));
clock.Halt(false);
while (true)
{
lcd.SetCursorPosition(0, 0);
lcd.Write(clock.Get().ToString());
Thread.Sleep(1000);
}
}
}
}
To anyone who wants to build this project:
You have to download the code twice for the clock to work properly.
First time: download the above code as shown with today's date and your local time
Second time: turn the clock.Set( ) line into a comment and download
DS1307 Datasheet: http://www.maxim-ic....dex.mvp/id/2688
I've been able to run this demo on a NetduinoPlus. Changed 'using ...Netduino' to 'using...NetduinoPlus'. Used 1k pullup resistors to 3.3v for the I2C lines, 5v power for the DS1307. Put an led (internal resistor) to 3.3v on the sq wave output to watch it pulse. DS1307 came from Spark Fun. Thanks for the code.