Pages: [1]   Go Down
Author Topic: how to wake up arduino by rtc DS1307  (Read 2850 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
this is my first topic.
I bought this sd-rtc shield:
http://snootlab.com/shields-snootlab/86-memoire-fr.html
The Wire.h and SD.h libraries work good but I can't find how to stop and wake up the arduino board: can you help me?
Thank you in advance.
  
« Last Edit: December 12, 2012, 09:58:01 am by supermax » Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The RTC on this board (DS1307) does not have an alarm function so all you could do is configure it's square wave output to 1Hz and sleep the arduino for a second at a time.
If you had something like the DS3231 RTC that has alarms then you could connect it's INT/SQR output pin to an interrupt pin on the Arduino, configure and set an RTC alarm to wake up and put the arduino to sleep until this alarm time.
Logged

Handle every stressful situation like a dog. If you can't eat it or hump it. Piss on it and walk away.

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a shield with an rtc like ds3231?
 
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a shield with an rtc like ds3231?
I don't know if there is a shield but you can get this device http://www.phenoptix.com/products/adafruit-chronodot-ultra-precise-real-time-clock-v2-1?utm_source=google-product-search
Logged

Handle every stressful situation like a dog. If you can't eat it or hump it. Piss on it and walk away.

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much Riva!

http://docs.macetech.com/doku.php/chronodot
This link says:"The SQW pin can be configured to output a square wave signal at 1.000 Hz, 1024 Hz, 4096 Hz, or 8192 Hz"
Do you know how to program the wave to last a day or fraction?

here is a clone with the ds3231 included
http://pcb.daince.net/doku.php?id=ad_ul_data_logger
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A possible quick and easy answer to your original question that I found while researching my reply is to download the narcoleptic library from here http://code.google.com/p/narcoleptic/ and just sleep the arduino for x amount of time. The more complex answer if the sleep time needs to be accurate is to use the SQW output from your DS1307 to wake the arduino every second (or less) and you count the number of wakeup's and do something as required (eg every minute (60 wakeup's) read the temperature)

The principle is the same for both the shield you bough and the Chronodot, the difference is in the RTC chip being used. The DS1307 has a SQW output pin that is configurable for 1Hz, 4kHz, 8kHz or 32kHz output. The DS3221 SQW pin is configurable for either 1Hz or ALARM output. I would start with the shield you have and sleep the arduino for 1 second at a time, waking it with the SQW interrupt set to 1Hz. Once you get this working okay then substituting the DS3221 should only entail minimal hardware changes and a bit more programming to set alarm times and configure the SQW pin as an alarm interrupt instead of square wave output.
I cannot find a DS3221 library that has the alarm setting commands you would require but maybe someone else knows of one.
I would use this library https://github.com/davidhbrown/RealTimeClockDS1307 for the DS1307. I have used it myself and it works really well and also has the SQW configuration commands you will need.
I cannot find a schematic of the shield you have and cannot determine if/where the SQW pin is broken out on the shield pins. You will need to read up on causing the arduino to sleep and wakeup using an interrupt. I recall Nick Gammon doing an article on power saving using processor sleep, he and others can maybe give you more info on this.
*I'm quite new to arduino though not micro controllers (PIC) and have not ventured to wake on interrupts yet.
Logged

Handle every stressful situation like a dog. If you can't eat it or hump it. Piss on it and walk away.

Pages: [1]   Go Up
Jump to: