Arduino Nano Power outage notifier project

HI all!.

I'm working in a project where an Arduino Nano can notify me via a GPRS800L module when there is a power outage at home. Also, the whole system should be powered with a Lipo battery in order to stay alive when the line power (from the 5v charger) is gone. Then when the power is back the Arduino "knows" and send me anoher message telling me that the power outage is gone. The code is ready and does all of this things. No problem with that.

The problem is that I cannot have the right voltage value and make a good decision so i can't send the message when the power outage occurs. I've been in a mental loop trying to figure it out to take SOME value that could be TRUE, FALSE, ON, OFF, 1 or 0, whatever that tells me that the power outage occurs or not.

So, i own these modules that maybe helps me with this project:

  • TP4560 (with protection) battery charger
  • Arduino Nano
  • OLED screen
  • Lipo 3,7v 3500 Mha battery
  • 5v mobile charger for using with the Arduino Nano
  • I also have a USB module that is used inside the battery banks. I disassemble it and used in this project with no luck.

As said, the main goal is to tell Arduino when there is a power outage and i don't mind how is done, it can be with a simple way. I know that the project is not too hard.

I have the code if someone want it.

Thanks a lot that anyone that can help me with this.

Regards!

You may want to start by giving this a read.

Using the above link as a starter I would replace the button with a simple opto-coupler design. You can detect mains power with an AC opto or just look at your DC out of your battery charger / maintainer. This is a simple true or false (1 or 0) affair for detecting.

Ron

You may also want to give some thought to what to consider a power outage. Is it 1 AC cycle? Is it a switching transient of less than a cycle? Is it something that you can time with an Arduino?
If you decide a power outage is a good part of a second, then you do not want to depend on an unloaded DC wall wart type supply as it will stay up for too long of a time.

Another consideration is multiple short term outages. Do you want to be notified immediately for each one or do want to wait until power has resumed for some time period?

2 Likes

How can that fail?
Posing schematics could help us.

Like this:

Maybe. I'll try to look it up when back home at the Pc. Often pen and paper does the job.

1 Like

If you have a relay powered off the mains and monitor the contacts with your Arduino , that would do the job .
Be careful with the Lipo - chargers are not usually designed to charge a lipo and supply a load at the same time .
Google “pass through charger “

You could use a small lead acid battery to power the Arduino , you can use a float voltage charger to run that . ( you can get 8v lead acid for example )

There are many options - you can do things with dual supplies at different voltages and diode OR gates in the supply and also monitor one of them to look for mains failure .

Assuming TP4560 is really TP4056, you have two pins that are open collector (6 & 7) on that chip that indicate whether charging is ongoing or has completed. If there is 5V input power to the TP4056, one of those will be low. If they are tri-state when power is off, then they could be connected to GPIO ports configured in input_pullup mode.

But I don't understand your setup. You have a battery, a power bank and a USB module of some kind. It's not clear to me what all that is about. A schematic would help a lot.

Frist off, thanks a lot who answer the post. I really appreciate the help. I will ask individually my doubts.

Great approach. Do you have an schematic of this?. I think i can use an opto relay so i can detect the AC main right?.

I don't understand quite well what you mean with 1 AC cycle but i can tell you that the goal is to get notified immediately when the outage occurs and when the outage is done.

Did you want to monitor AC mains or your DC? There rewally isn't much to it. Also you want to look at duration as mentioned. Just as an example power fails, do we want a pause before you go to battery power or instantly. Where I am lately we have power "burps" lately where power drops out for less than one second. Noticable with LED lighting but not with incandescent.

You can also just run off a battery having a battery maintainer to keep your battery up and charged.

Ron

Then you need to REALLY define what you mean by a "power outage"!

Is when the main power cuts. No energy from the service.

What people are getting at and see my last prior post is a single cycle of US or North American mains is 16.66 mSec (1/60 = .16.66 mSec and a single cycle of European mains in 20 mSec (1/50 Hz = 20 mSec. Those are the frequencies for 50 Hz and 60 Hz mains power and 50 Hz is 20 mSec and 60 Hz is 16.66 mSec.

So it's about the duration of power outage before a notification is sent. This is what I was getting at in my prior post. When do you want notifications? A simple "burp" of a single cycle or after 1 second, 5 Seconds what?

Ron

I used this method of AC mains detection recently using a zero crossing detector, made from a dual led optocoupler and 2 x 100k (5W) resistors.

The concept of detecting the outage with interrupts/timers is explained very well in the link.

I upload the hand made schematics, sorry but i couldn't do it with software because i cannot found all the arduino modules. I hope it is understandable, i will explain it below.

These are the basics:

  • I connect an OLED screen to show the actual voltage. The screen is connected directly to the arduino nano. Could be used or not, is optional.
  • The SIM800L is connected with GND and VCC directly to the Lipo cell because these modules are energy sensible, this way works better. Also, is connected to the Arduino nano with pins RX and TX for transmission and send the SMS messages.
  • The USB module i use is from a battery charger i had (exactly this). This module charges the Lipo battery and also feeds the arduino nano simultaneously. i don't know if it is a good option. Maybe i can replace it with something else.
  • I use a Lipo battery 3,7 v 3000 Mha to feed the arduino nano when the power is gone.

Again, thanks to everyone helping this project.

That is a fine block diagram, not a schematic. But we all are still waiting for you to tell us what you consider a power outage to be and exactly how often you want to be notified when there are multiple outages.

1 Like

The USB module in your link is a power bank, not just a charger. So it includes a charger and a boost converter that produces the 5V output. I assume the large USB port is the output port, and the small USB port (microUSB) is for input. But can you do both at the same time? Can you even fit both connectors at the same time? If so, do you still get 5V output when the battery is charging? And do you still get 5V output when the battery has fully charged but the wall power is still connected?

One characteristic of most power banks is that they shut down automatically when load current drops below a certain point. If your circuit does not draw enough power, that could be a problem. Something like a J5019 module would do the charging and boost conversion, but would not have that shutdown feature.

ok, i will respond in parts.

  • The USB module has a micro and a large USB as you've been noticed. I can connect both at the same time. What i have connecting both is something like a UPS allowing me that when the main power coming from the charger is out the module enables the Lipo cell.
    Both connectors fit well or at least i can connect them at the same time :roll_eyes:

  • The USB module has a LED. When the battery is fully charged the led lights blue, if not is red.

Again, maybe using the USB module is not the best decision and i should replace it with something else. Ideas are welcome.