Notifications
Clear all

Mains Power monitor and alert

11 Posts
2 Users
0 Likes
220 Views
 Matt
(@matts)
Member
Joined: 3 years ago
Posts: 4
Topic starter  

I am looking for help in designing a power monitoring unit.

We all rely on electric power of one type or another.  

Especially in winter, but in windy conditions power failures are common.

It would be nice to be alerted about the power outage and its eventual return.

 

I believe the ESP32 is capable of this

 

unit live on USB power but has a battery backup

When main (USB) power has failed (voltage essentially 0) 

- mark the time

- increment the event counter by 1

- mark power state failed

- issue an email alert hoping the house ups is still running supporting the wifi and internet)

When the power has returned

- mark the time

-issue and email power has been restore

- reset power state to good

 

repeat forever ..

 

 

This topic was modified 3 months ago by Matt

M


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts The following is a little confusing

unit live on USB power but has a battery backup

When main (USB) power has failed (voltage essentially 0) 

Is your wall wart (live) plugged into a UPS (battery backup)?

If the esp32 has no power how can it detect a failure.

I THINK what you mean is that your MCU (esp32 or??) is running on a UPS HAT. 

I happen to have one using a PICO on my desk at the moment.

All the functionality you mention is what most UPS's do.

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 Matt
(@matts)
Member
Joined: 3 years ago
Posts: 4
Topic starter  

The usb power wall wart would Not be on a UPS power supply, as that power value is what is to be measured to determine a power failure.

Can the ESP32 or Arduino measure power should have been my 1st question 

If so, it should be testing a different source than what powers it (ie battery or ups system)

 

M


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts Any MCU or MPU can do what you want, however the following is impossible

The usb power wall wart would Not be on a UPS power supply, as that power value is what is to be measured to determine a power failure.

If the device to determine the power failure is not operating due to a power failure then you can't get there form here.

You need a UPS HAT powered MCU (Arduino) or MPU (Raspberry Pi) with an AC power sensor. Then it is just a handful of lines of code.

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts I just did a google, and here is the first hit

https://www.instructables.com/Build-a-Simple-Power-Outage-Monitor/

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts From google, here is a reddit discusion https://www.reddit.com/r/smarthome/comments/xs97b3/any_ideas_for_a_diy_power_outage_alarm/

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 Matt
(@matts)
Member
Joined: 3 years ago
Posts: 4
Topic starter  

Thank you, you have given me a few elements to research 

I was not aware of the Pico Pi, or the reddit item

It seems my initial description was flawed, but I sense you understand what I am after.

 

M


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts I do, I was having a bit of fun with you. It's actually a fairly trivial project. Do you want this as a learning project, or just to accomplish the task. The reason I ask is there are solutions you can buy and they are cheap, THIS device for instance costs less than $100 CDN.

If you are wanting to DIY for the learning experience, then an esp8266, esp32, most arduinos, the RaspberryPi PICO(W) and many others will all work.

Based on your requirements, a sensor on the mains is the golden solution, but a simple UPS HAT as I mentioned will tell you that at least one leg of your power is out but not the whole house.

I have UPS HATS (boards that fasten to the MCU/MPU) for PICO, Pi 4B, Pi Zero, and maybe some others so I know they are available and I can tell you the implementation varies quite a bit, some are a couple minutes, some I have yet to figure out.

If you are a qualified programmer, with a few libraries and a handful of code you can roll your own.

Good luck.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 Matt
(@matts)
Member
Joined: 3 years ago
Posts: 4
Topic starter  

@zander 

formely a programer, from the 70s with Systemhouse, in cobol, then in the 80s compiled dbase like languages then egressed to building managing and diagnosing networks as arcnet faded into token ring and ethernet or hybrid ethernet as I like to call it 🙂  I have not programed since maybe the the early 90s, and have been retired for the past 8 years, so I'm trying to keep the rust out ..

Since retirement, I have played with ardiono making a few useful things like remote temerature sensing and plant watering with moisture sensors, but still very much a neofyte of these microporocessors and training them.

Lol, my sensors detected your humour, always enjoyed.

I have seen exactly what I want on Amazaon,(Risinglink power failure alarm) but I have a few arduino and an esp32 from disassembled projects, and miscellaneous parts, so my purpose is both to construct a practical device, as well as continue my education etc.  So if I do need parts, I'm hoping it will be less than a meal at Tims, and priceless in the knowledge dept.

 

to further define:

house environment:  APC UPS supporting internet and local network & telemetry.

 

Gizmo to construct:  

desired specs - has clock / calendar that can be set - I see the PICO has this

able to find libraries to enable sending email (this will also get me the approximate time stamps needed) - most have this

powered by USB (via house UPS* or even a battery ) - they all seem to have this

* - the existing infastructrue needs to be in place for message reporting

sensor to detect power or voltage - I think it would be fine to use another USB power souce to keep this all with low voltage, and find a method to detect if there is power eg 5 volts and when there is not.

 

As you mention, the programming does seem to be fairly straighforward , to detect and alert on an outgage, and again when it is restored, sending then appropriate message.  Logging is done via the emails and not needed to be retained on the gizmo.

 

You have given me another term to hunt down - UPS HATS

 

Much deeper reason for this device:

Everyone is impacted by power outgages some just flickers, other days in length.

Some of us want to know when and how long, plus relfect over time how often do they happen and how incovient are they.

In short, the quality of power is very important in this current era.

During my working career of managing networks there was often a battle between equiment vendors, power utility and electricians when there was a problem that "it must be the power"

Electricians would bring in a boxy device 100 times the size of my blackberry, (circ 2010) to monitor the power and later say nope not the power or it doesn't detect outages shorter than 5 minutes (why did I call them, right?)

I currently have time to dwell on this issue.  Also, one of your recent notes indicated that you too have suffered a few power outages .. Inquiring minds need answers 🙂

In summary, I am sure that there are many who could use this type of gizmo to point to the gremlins affecting their lives

 

Kind regards,

Matt

 

 

 
 

 

M


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts I know Systemhouse, I either did some consulting or something. Hmm, COBOL, not too relevant.

Ok, some Arduino and projects that use sensors and MCU's so you are 'qualified'.

There are two major approaches.

1. Use a power sensor. For mains that involves a device that wraps around the main power cables in your main electrical panel.

2. Decide on a UPS HAT. A HAT is just an auxiliary board that attaches to a Pi or Arduino, it will have a small battery, charger circuit, supporting circuitry and software. The arduino or Pi will be powered by this UPS that is also plugged into the wall to keep the battery charged. When the power drops to the UPS, it will very likely have an API or some interface to tell the main processor like PICO, Pi, Arduino that it is now running on battery. Yes email is just a library, RTC may be available, but your router can supply the time via NTP, again libraries are available.

Some other things to investigate are MQTT and IFTTT in addition to email. Maybe even SMS but not sure if that can be done without cell service.

I favour option 2 because it is more fun, and a teeny bit safer.

Questions?

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6972
 

@matts Here are two PICO UPS boards. I have both, they are similar. I have not had the time to figure out how to use them but it shouldn't be too hard, and the folks at Waveshare will answer queries. Look at each closely to best determine what you need. The one with the 18650 battery will take you to the dark side of fake 18650 cells. A great idea, but very hard to get legitimate cells. You will also need to spend a few bucks on a proper charger. I have 3 in total, 2 may be enough, one for RC batteries and one for everything else. The everything else is a Skycharger MC3000, I HIGHLY recommend it for all rechargeables except the big RC LIPO packs. Fire bags and fireproof surface preferably outdoors for these somewhat dangerous batteries. A good charger is cheap insurance.

Here are the links https://bityl.co/Nqyw and https://bityl.co/NqzE

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote