Power Outage Logger Hardware Design

I am a newbie and don't want to fry my first board. I live where the power goes on and off many times and day and often for the entire day. I am making a logger so every time the power goes off or back on it writes to a google spreadsheet where I can easily make some reports.

The attached picture shows my proposed hardware design. Can someone confirm this will work. The plug on the right is attached to an inverter and large bank of batteries and the power always stays on. The plug on the left is attached to an old iphone USB adapter and straight to the power utility which goes off and on regularly. The USB to TTL Serial Cable has the following wires: red: +5V, black: GND, white: RXD and green: TXD. I attached the red cable to digital pin 2 and black to ground. I am still working on the code but my plan is when red 5 volt goes off I will write to google spreadsheet and then when it goes back on it will write again.

Thank you!

When you lose power are you guaranteed to have internet?
You can also save to SPIFFS or an SD card

Hi Dave, yes I will have power for the internet. My house batteries with inverter last more than 48 hours and the maximum the power is off is usually less than 10 hours.

Hi,
Yes that looks the simplest, if the input plugpack is on a mains only outlet.
OPs pic.

Tom.. :slight_smile:

bigred17:
Hi Dave, yes I will have power for the internet. My house batteries with inverter last more than 48 hours and the maximum the power is off is usually less than 10 hours.

But, will your ISP also have no power?

Paul

if the power plug outputs all the time, then great. I have had some that shut off when the load is not high enough.
for testing, I would put a 1k resistor and an LED to ground
then connect after the resistor to send to the input pin.

I assume you are relying on Google sheets for timekeeping ?

Thank you for everyone's help. I got everything working using my original layout. I tried with a resistor and LED but as part of the debugging I removed them and never put them back.

Yes, I am using google for timekeeping.

Here is a picture of the final version.