Arduino with RTC module turning off after unplugging


Very recently I started my journey with Arduino - I am a total beginner.

I've built a clock with LCD display and everything works as it should, except when I unplug my project, it completely turns off. When I plug it again, it keeps measuring time as it should.
I also tried other codes (for LED display only with RTC wired to 5v etc) with same results. I was hoping that the battery from RTC will provide the power, but something is flawed.

Components used:
Arduino UNO board
LED display with i2c
RTC DS1302 with lithium battery 3V

Scheme I followed:


include "virtuabotixRTC.h"//Library used
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
virtuabotixRTC myRTC(2, 3, 4); //The order here is DAT,CLK,RST. You can change this depending on the wiring
char timeChar [8]; //number of digits for the format
void setup() {
// Set the current date, and time in the following format:
// seconds, minutes, hours, day of the week, day of the month, month, year
myRTC.setDS1302Time(40, 47, 19, 7, 6, 12, 2021); //Here you write your actual time/date as shown above
//but remember to "comment/remove" this function once you're done
//The setup is done only one time and the module will continue counting it automatically
void loop() {
// Start printing elements as individuals
lcd.print("Date: ");
lcd.print(myRTC.dayofmonth); //You can switch between day and month if you're using American system
sprintf(timeChar, "TIME:%02d:%02d:%02d",myRTC.hours, myRTC.minutes, myRTC.seconds);

Best regards,

this line defines the start of your watch's time control.

After setting the correct time, you need to comment it out (using //)
and reload your code again, otherwise every time you reset or load your code it will load this line and the date you set as start.

Read the comments below the line.

RV mineirin

Yes, thank you, I figured this one out already, I just copied the code from IDE. My problem is that my project doesn't work when unplugged, although it has a proper battery.

Best regards

Check the module's battery condition.
RV mineirin

Thanks for the quick response, unfortunately I changed the battery and it still turns off when unplugged.

Am I being thick? The battery on the RTC board is just to keep the RTC chip alive when the power is off. It won't run the Arduino and display. Or have I misunderstood?

1 Like

I might misunderstood something, but the VCC of RTC board is connected to 5V of arduino and VCC of LED display (grounds also). Please correct me if I'm wrong, but I assumed from the tutorials that another battery shouldn't be necessary as the one on RTC is supposed to power all of the components.


So, you got it wrong. The RTC battery is a 3V coin cell. It´s not able to provide voltage and/or current enough to power your Arduino. This battery task is just to keep your RTC on time when the module has no power.

1 Like

Oh ho, the module battery just keeps the module running, keeping the clock and the module "in time".

RV mineirin

1 Like

@lenapepl, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

P.S. this is one project where I use a supercap… 1F / 5V instead of the coin cell to keep the RTC alive, but yes,. you need to provide enough power for the processor and LCD separately. (Power = Volts X Amps)

Thank you very much for all the responses.
Oh no, so that’s the beginner struggle.
Do you have any recommendations which battery would be the best to power Arduino uno and LCD? And where should I add it in my project?

Best regards,

Since it´s a clock, supposed to work for a long time with no battery changes, I would try to use a wall adapter (like the ones for charging cell phones). If it´s more than 5V, connect it to the barrel jacket.

If you still want to use batteries, I prefer not guessing the best option. Let someone with more electronics knowledge to suggest.

Thank you,
Unfortunately I need my clock independent from any plugs etc. so I'm going to opt for the batteries.
I was wondering if a power bank would be a proper solution.

As I said, I´m not an electronics expert. I think it should be interesting to see how the power bank behaves. Take a look in this topic for some expected trouble --> Powering Arduino from a power bank

1 Like

Perhaps one lesson from this is that using an Arduino to tell the time is a bad choice of technology. A lot of effort goes into making the chips inside quartz clocks and watches consume as little power as possible. Indeed, they aren't general purpose microcontrollers at all - they use custom silicon designed to do one specific job, well, at the lowest possible power.

Obviously you can use an Arduino in the way you envisage, but it clearly isn't the best choice.

So consider this a win; you now know that the first question to ask, after you've identified what you want your widget to do, is "What is the most appropriate technology?". The answer will only be "Arduino" some of the time. Many other options are available - we even get people asking for help with their software when the whole thing could be done with a couple of transistors - no microcontroller required.

I get the message, but Arduino is simple to use and there is a lot of resources that provide necessary knowledge - it just seems approachable for an electronic newbie. The clock itself works properly and the results are satisfying enough for a simple project. I just need to learn more about outsourcing power and this is the advice I’m looking for :slight_smile:
Thanks, I appreciate the response
Best regards

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.