#192 Wakey, wakey! Let the DS3231 RTC wake up your Arduino - easy!

preview_player
Показать описание
Use a cheap RTC to wake up your Arduino from Deep Sleep

More information (including all links, sketches & PDFs in my GitHub):

### INFORMATION

The DS2131 library I'm using in this demo (I do wish each developer used a unique name!)

Alternative DS3231 library by Northern Widget, has some nice features

DS3231 Datasheet. Essential reading if you are using native I2C calls (ie no library)

AT24C32 EEPROM on that module - this could be VERY useful for data-logging. 1 million writes!

A library to exploit that AT24C32 EEPROM

Battery Life Calculator

Best 18650 battery of 2019

Si4599 Datasheet

Want to know about I2C?

### PRODUCTS

DS3132 module (with EEPROM) 3 pieces for less than $5

Si4599 N and P Channel 40V (D -S) MOSFET Expansion Board Module (each)

### List of all my videos
(Special thanks to Michael Kurt Vogel for compiling this)

If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite journey

My channel, GitHub and blog are here:
------------------------------------------------------------------
------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Thanks for the interesting video Ralph, I actually use these RTCs with all my IoT sensors around my house but it did take some time to get a fully working & stable device for my needs, i.e.extremely low power use.

Without posting my schematics the basics of my system are as follows:

Sensors are powered via 2 x 18650 cells in parallel for capacity not voltage which go to a ultra low Microchip 3.3v LDO

The output of the LDO is connected to a P- Channel MOSFET & the gate of the MOSFET is connected to the INT/SQW pin of the RTC (DS3231)

(all this time, my ESP8266 & even the RTC itself has no power, the RTC purely running on CR2032 backup)

When an alarm is activated, the gate of the MOSFET is pulled low which then sends the regulated 3.3v around the circuit.

ESP8266 is powered on, takes a reading and sends this reading to the main unit located elsewhere via ESPNow, ( the main unit is connected to a permanent supply & connects to the internet to upload the reading), sets a new alarm for the RTC and then shuts down to wait for the next wake up call. The MOSFET gate is then sent high once again & all powere is removed from the circuit.

RTC is now running on battery backup again.


There are a number of caveats though that mean some modifying of the DS3231.

The 472 resistor pack located above SDA & SCL pins on the RTC have to be removed & make sure that there are SDA & SCL pullup resistors on the board being used, good thread here:

For super low power removal of the LED on the DS3231 is also a great idea.

Plus a necessity for anyone who uses these RTCs is to remove/disable the inbuilt charging circuit.

These RTCs come ready to accept an LIR2032 rechargeable battery, most people find these inadequate and fit a regular CR2032 non-rechargeable battery in the holder. The problem is that there is a charging circuit on the unit, not a good mix with a non-rechargeable battery installed.
For simplicity I just removed the 200ohm resistor on my RTC, some people removed the whole circuit though.

More details here:

Cheers..,

CM
Автор

There is one interesting thing about these DS3231 modules. They are trying to charge the CR2032 battery! I can't remember where I found the schematics of this module and noticed this couple of years ago, so I can't give a link. But you need to remove one 200 ohm resistor right next to the SCL pin on the 4 pin connector side. It is between the MELF diode and the SCL pin. Both the diode and the resistor are in on this very wrong charging circuit, so you can remove either or both. This may also be the reason of higher than expected current draw.

borayurt
Автор

Very clear and informative as always! Thanks Ralph.

stevehallam
Автор

Bugger, I just bought a handful of 1307s! Need to get my hands on some 3231's now (not that I need them, but I love this function)!

bigpickles
Автор

Excellent video! I did a breadboard/bare bones project like this, and ran into the RTC eating too much current during sleep. My solution was to power the DS3231 from a pin on the microcontroller. Before going into deep sleep, I set the pin low, then set it as an input without pull-up. I think I got to around 40 microamps. The DS will still trigger the low alarm signal, so having the Int pin with internal pull-up is necessary. Runs for around 16 months on 3 AAA batteries I think.

andrewtait
Автор

Excellent addition to the previous videos. Thank you.

simonbancroft
Автор

I live in rural Michigan. I wish I could find any electronics locally. Everything I get comes from Aliexpress. :P

Thanks for the awesome tutorials. I've learned so much since I found your channel recently. Thanks Ralph!!!

miahsbrokengarage
Автор

Thanks A TON! I ran across your video whilst searching for anwers on why my interrupt wouldn't work. I was forgetting to clean the flag bits

felixgedratdinklage
Автор

Another good video thanks,
the ds3231 module along with a EEPROM has a diode and resistor from 5v to the battery adding a sleep drain along with the I2C resistors. Working days and weeks ahead is a pain unless have UNIX time a count of seconds and decode void to convert back to time format ts. The time library does this ? Graham

grahamwise
Автор

Thanks for all the videos Ralph ... I have learned a ton from you .
Very much appreciated ... :)

karens-jclark
Автор

I used a similar idea to save power when using a venerable PIC 16F84A to make something similar to the "who got in first" device used on quiz shows. The B port would be set up to trigger an interrupt on a button press, then the Sleep instruction executed to put the processor into a low-power state. An interrupt would wake up the processor and the interrupt routine would simply return, allowing the rest of the program to continue (check for which button triggered the interrupt, light up a LED to show which button was pressed and make a sound by bit-bashing a port, then go back to sleep until a reset is received).

melkiorwiseman
Автор

And you can power the DS from an Arduino pin and switch it off before sleeping. Interrupt still drops on alarm!

mahudson
Автор

Good stuff here! Given that you mention that I2C is only good for distances of ~1 meter or so, what would you use to go further? I saw mention in one comment about "stuff all around the house", what would you use for something like that?

Roy_Tellason
Автор

Great video as always. Have you calculated how much power it would take to just use the watchdog timer, wake up every 8 seconds, increment a counter, check for 10, 800, and go back to sleep. If you did not need "real" time, it might take less power then running the I2C lines.

MrEdwardhartmann
Автор

Great video! Thank you for the detailed explanation and for pointing to the right library

Taran
Автор

I was waiting for today's video, an even without watching, i know it will be something usefull..

oleeide
Автор

Grand video. A couple of thoughts to save current. As the DS3231 has a backup battery would powering the DS3231 from an arduino pin then allow you to cut the supply in the go to sleep sequence [I dont know if that affects the alarm out pin]. Second idea, would wire.end() de-energise the I2C just ahead of sleep, then wire.begin() on wake up?

saturdayscience
Автор

Thanks for these well presented and clear videos. I'm teaching myself simple electronics and find certain Arduino projects really helpful. I plan to use this RTC video on one of my tasks, but only need a "wake up" at the same time each day. In this case do I still need to "set next alarm" each time the sleep pin goes low.

bojangles
Автор

Been looking at making a birthday clock using a DS1307, promini and 16x2 lcd and came across your video as I was looking for more info on the use of structs.
In some ways seems simple enough but it can get rather deep rather quickly and hence loss of understanding.
So a list of names and the day and month of the birthday and then display something like "happy birthday johnny" ...other times just display the time etc. I guess or "no birthdays today".
I'll keep at Jeff

jeffbluejets
Автор

Observation: the pull-up resistors are not only applied to I2C's SCL and SDA, but to SQW. The DS3231 chip supplies SQW on an open drain, but the board with its pull-up resistors connects SQW to the board's Vcc, and Vcc is connected (amongst other things) via the LED to ground. That means that when the RTC is running on its button battery (no power on I2C), volts (from an external source) applied to SQW are attempting to power the LED and other bits of the board, and current is draining from the external source even while the alarm has not yet fired. Which rots my socks.

maisons