Go Down

Topic: DS3231 RTC on VBAT always (Read 395 times) previous topic - next topic

fadih1

Dec 07, 2019, 06:08 pm Last Edit: Dec 08, 2019, 10:31 am by fadih1
Hello guys,i am working on a battery operated project using the DS3231 RTC, PIR sensor and a breadboard arduino. I only need the RTC to wake up a breadboard arduino every 24 hours for a period during which a PIR sensor becomes active in order to start detecting motion. After that period has elapsed, the arduino goes to sleep and wakes up after 24 hours where the PIR sensor is active again. Of course timing or elapsed periods will be computed using the RTC.

Having said that, i am looking to minimize the power as much as possible and while experimenting with the clock i noticed that i can accomplish my goal without having to wire the VCC pin.
So in summary, i don't need to keep time for more that 24 hours and send an interrupt every 24 hours.

What i need clarification on is what is the purpose of the VCC pin if i can read from the clock and send an alarm using Vbat only.
Is it designed for emergencies only, where Vcc is off so timekeeping isn't interrupted?
If so, why does Vcc consume so much more current? (By that i mean this additional current draw on Vcc is useless since the same functions can be used on Vbat)

Hope you guys could help me understand this better.
Thank you.

groundFungus

Does that DS3231 module charge the battery from Vcc?

fadih1

I am sorry, i forgot to add that i removed the resistor for the charging circuit, the resistor pack connected to SDA,SCL,SQW and 32kHz and the LED. The interrupt is working perfectly because of these modifications.

groundFungus

Quote
removed the resistor for the charging circuit, the resistor pack connected to SDA,SCL
Are there pullups on SCL and SDA elsewhere?

What powers the relay coil?  Is it a bare relay or a relay module?

Schematic please.

fadih1

#4
Dec 07, 2019, 06:56 pm Last Edit: Dec 07, 2019, 07:01 pm by fadih1
I am using a transistor to connect Vin to GND of the PIR sensor. On the board there isn't but i think the ATMEGA328P has internal pull ups on SCL and SDA.
However, if i understand you correctly, the transistor will be triggered from the ATMEGA328P not the clock

groundFungus

The internal pullups are very weak (30K to 50K).  4.7K is the recommended value.




fadih1

But these pull-ups were causing the alarms to behave randomly and without them everything is working. I wasn't planning on adding direct pull_ups.

groundFungus

#7
Dec 07, 2019, 09:31 pm Last Edit: Dec 07, 2019, 09:32 pm by groundFungus
If it works (and I don't know why it would without pullups) then run with it that way.  Do you have any pullup on the INT/SQW pin?  It, too, is an open collector output so needs a pullup.

As far as I can see Vcc is needed for the pullups on the board (SDA, SCL. INT/SQW, 32Hz) which you removed.  Also the current to run the RTC is supplied by Vcc, extending the battery life.

lastchancename

In my DS3231 circuits, I simply use a 1uF 5V supercap on vBat, charged through a diode from Vcc.  That chip sleeps when Vcc is removed.

The I2C pull-ups are required if you want the comms to be clean and reliable in all situations.

Don't overthink it.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

fadih1

#9
Dec 07, 2019, 11:58 pm Last Edit: Dec 08, 2019, 12:02 am by fadih1
Here is the thing guys, i have been struggling to get the interrupt to work while on Vbat and after reading so many threads the solution was to remove these resistors and the EEPROM because according to what i read they kept pulling down the SQW/INT.
Personally, the alarm was working fine on Vcc with the 32khz and SQW disabled however when running on Vbat the SQW is re-initialzed to a 1Hz square wave. Without changing the code and after removing these parts everything worked both on Vcc and Vbat.
This is why i am confused and asking what's the use of the Vcc.
Before removing the parts, i tried to manually set the control registers to disable the battery backed SQW register but the outcome was the same.
By removing these parts i can keep reading from the RTC at all times and this will help me decide wether to turn off SCL/SDA to save power or not(if the communication between the two becomes unsynchronized because of that and the additional current is acceptable then i will keep them on).
I am sorry if i wasn't able to deliver this message clearly before.
I know this may be a tough question but hope i could understand this clock more and maybe help others in the future

jremington

#10
Dec 08, 2019, 12:03 am Last Edit: Dec 08, 2019, 12:08 am by jremington
You have been asked to post a schematic of your current setup, which will include comments on what parts have been removed from the module and what pullup resistors you are using to the Arduino Vcc.  It is impossible to fully answer your question without seeing that schematic.

Quote
This is why i am confused and asking what's the use of the Vcc.
Vcc normally powers the chip. The poor circuit design with which you are currently struggling assumes that you want to power the chip with Vcc most of the time, and require the module pullups to Vcc.

That design will not work if you intend the chip to run solely from the battery.

aiannar974

I have used this with success. 

https://youtu.be/oh-q_IA0xFI

Flow the schematic in the comments on the google drive.

It worked great for several times on simple projects.

The only power consumption is by the rtc and a short time for the Arduino during its loop.  I got 43000 cycles out of it running an led for 10 seconds on 3 aaa batteries.

fadih1

#12
Dec 08, 2019, 10:30 am Last Edit: Dec 08, 2019, 10:33 am by fadih1
Hello guys, i did post the schematic of what's left from the board in the original post. Also i ulpoaded a picture showing what was removed.
I want to clarify that i want to operate at the lowest power consumption that i can achieve while being able to control the functions that i need being, the interrupt and the time.
The only pull-up being used is on the arduino's side for the SQW pin.
Those pull-ups were causing the clock's SQW to behave as a square wave instead of an interrupt on Vbat, by removing them the SQW pin worked as intended and many people have documented that these resistors were causing  troubles when trying to wake the arduino on Vbat.
So by removing these i am now able to control the clock from Vbat and at 100uA.
Is what i did a bad practice? This is why i asked the questions before to help me understand what really is the purpose of the Vcc if i can operate in Vbat

Go Up