# Need help for a super simple Cheapest USB POWER OUTAGE ALARM sketch

#### dankori

Joined Jul 1, 2022
9
Hello. Im new to electronics..
I want suggestions + schematics for a chipest simplest project:
USB power outage alarm that is triggered 10 seconds after the USB power went down.. also the alarm should make enough noise to hear from other room and should last for 10 seconds.

The basic bom:
buzzer is sfm-27
9V backup battery to drive the buzzer
usb cable
bc547 / 2n2222 transistor
capacitor
diode
resistor

optional components:
c005 timer modules

Eventually I will send it to PCBway for my first pcb manufacturing ever.
D

#### dankori

Joined Jul 1, 2022
9
//cheapest :\

#### Papabravo

Joined Feb 24, 2006
18,806
The cheapest would not be something that requires a sketch. Maybe a 555 and a comparator.

#### crutschow

Joined Mar 14, 2008
30,116
Below is an LTspice simulation is my take on a simple circuit that does what you want:
I used a CMOS inverter buffer to drive the buzzer, since it has a fairly predictable trigger point to minimize variation in the delay time, and draws only a minute leakage current for power.
Each output can sink about 8mA worst-case, so four in parallel should be more than enough to power the buzzer.

The 1 megaohm resistor will be drawing current from the 9V battery when the 5V USB voltage is applied, but that is only about 0.08 Ah/year so the battery will still last its normal shelf life.

Of course you need a switch to turn off the 9V when the device is not connected to the USB port.

#### Papabravo

Joined Feb 24, 2006
18,806
Below is an LTspice simulation is my take on a simple circuit that does what you want:
I used a CMOS inverter buffer to drive the buzzer, since it has a fairly predictable trigger point to minimize variation in the delay time, and draws only a minute leakage current for power.
Each output can sink about 8mA worst-case, so four in parallel should be more than enough to power the buzzer.

The 1 megaohm resistor will be drawing current from the 9V battery when the 5V USB voltage is applied, but that is only about 0.08 Ah/year so the battery will still last its normal shelf life.

Of course you need a switch to turn off the 9V when the device is not connected to the USB port.

View attachment 270522
I'm pretty sure this circuit does not require a "sketch" for reliable operation.

#### dankori

Joined Jul 1, 2022
9
Below is an LTspice simulation is my take on a simple circuit that does what you want:
I used a CMOS inverter buffer to drive the buzzer, since it has a fairly predictable trigger point to minimize variation in the delay time, and draws only a minute leakage current for power.
Each output can sink about 8mA worst-case, so four in parallel should be more than enough to power the buzzer.

The 1 megaohm resistor will be drawing current from the 9V battery when the 5V USB voltage is applied, but that is only about 0.08 Ah/year so the battery will still last its normal shelf life.

Of course you need a switch to turn off the 9V when the device is not connected to the USB port.

View attachment 270522
Thank you for this.
Most of this sketch is simple enoughfor me.. but
I'm unfamiliar with using this CD4049B as an " inverting hex buffer" ?? (says the datasheet).
I have to admit I do not know how to connect the 18 pins of it according to your sketch.

I figured my device should be some kind of 2 or 3 units of ne555 with a capacitor or more to define the delay and then the time to sound the alarm till it fades out.

Could you elaborate on the exact way these CD4049B units/pins should be connected ?
You write that I need a switch to turn off the 9V .. Can I use some kind of a transistor as a switch - once the previous cycle has ended ?
I have no idea how to do that too.

Thanks again.

Last edited:

#### Audioguru again

Joined Oct 21, 2019
4,798
The high frequency beeper is loud at a distance of only 10cm (four inches). Then in the next room about 1600cm away it is not loud enough. Some people cannot hear the high squeak frequency.

You might have many products that beep. Which one is beeping now?

#### MrAl

Joined Jun 17, 2014
9,169
Hello. Im new to electronics..
I want suggestions + schematics for a chipest simplest project:
USB power outage alarm that is triggered 10 seconds after the USB power went down.. also the alarm should make enough noise to hear from other room and should last for 10 seconds.

The basic bom:
buzzer is sfm-27
9V backup battery to drive the buzzer
usb cable
bc547 / 2n2222 transistor
capacitor
diode
resistor

optional components:
c005 timer modules

Eventually I will send it to PCBway for my first pcb manufacturing ever.
D
Hi,

What sort of power source do you intend to have available or already have available when the USB power drops?
You need another power source such as a battery or other computer power supply line (like the 12v line for example) to power the circuit so it can power the buzzer when needed. If none, a super capacitor may help if the buzzer does not have to buzz for a very long time.

Also, do you only need to detect when the USB power goes to zero (or near zero) or do you want to detect an under voltage condition too such as 4.5 volts or 4.0 volts or something like that?

#### crutschow

Joined Mar 14, 2008
30,116
You write that I need a switch to turn off the 9V .. Can I use some kind of a transistor as a switch - once the previous cycle has ended ?
Okay, I missed that you wanted the buzzer to stop 10 seconds after the 10 second delay.
Revised schematic below:

Since the buzzer now shuts off automatically, you don't need a switch.

#### crutschow

Joined Mar 14, 2008
30,116
What sort of power source do you intend to have available or already have available when the USB power drops?
In his list of materials, there is a 9V battery.

#### crutschow

Joined Mar 14, 2008
30,116
Below is a circuit that uses a supercapacitor to power the circuit, which charges from the USB 5V power.
But don't know if the 0.33F 6V supercapacitor cost is too high for this application.

#### dankori

Joined Jul 1, 2022
9
Hi,

What sort of power source do you intend to have available or already have available when the USB power drops?
You need another power source such as a battery or other computer power supply line (like the 12v line for example) to power the circuit so it can power the buzzer when needed. If none, a super capacitor may help if the buzzer does not have to buzz for a very long time.

Also, do you only need to detect when the USB power goes to zero (or near zero) or do you want to detect an under voltage condition too such as 4.5 volts or 4.0 volts or something like that?
9v battery should power the sfm-27 . I tested it to be sufficient.

1.at random hour - the USB goes to zero .
2.After 10 seconds or so- the 9V battery will power the buzzer for about 10 seconds.
3.USB comes back eventually..so go back to 1.

#### MrAl

Joined Jun 17, 2014
9,169
9v battery should power the sfm-27 . I tested it to be sufficient.

1.at random hour - the USB goes to zero .
2.After 10 seconds or so- the 9V battery will power the buzzer for about 10 seconds.
3.USB comes back eventually..so go back to 1.
Hello again,

Ok thanks.

I dont know if you worked with any microcontrollers yet but if you did that would be the best way to handle this i think. You can program them to give you precise delays and turn on times and stuff like that. For example, you can program one to turn on after 10 seconds, 7 seconds, any time, then turn off at any time, then turn back on at another time, then turn off again later, then on, then off, then on, then off, etc. You can program it to turn on and off at more than 100 time points if you wanted to.
Cost is maybe $2 USD or even less. Chip would be an 8 pin dip package. You can even get a PC board already made with a chip on it so all you have to do is plug it into your USB port, download the IDE software, follow a few simple examples, and probably within one day you would have the most sophisticated timer you ever could image that would be very very difficult to do with logic gates or similar. The Arduino line of microcontroller boards and chips are very popular and easy to work with. You can start with that then move to a single chip if you like. Worth looking into if not anything else. You'll never go back to logic gates. Also, with the single chip solutions you can program them to power down for some time so they dont use battery power all the time. I created a custom refrigerator monitor that used 3 AA batteries that lasted for two years before they needed replacement. If you still wanna use a 9v battery then you also need a low quiescent current voltage regulator to supply 5v. Better to use three AA cells though. Oh and also, with a single 8 pin DIP package microcontroller you could monitor four different USB ports at the same time. Either of them goes out you can trigger the alarm. You can also program the voltage trip point to be 0.1v, 0.5v, 1v, 2v, 3v, etc. with little difficulty. Thread Starter #### dankori Joined Jul 1, 2022 9 Hello again, Ok thanks. I dont know if you worked with any microcontrollers yet but if you did that would be the best way to handle this i think. You can program them to give you precise delays and turn on times and stuff like that. For example, you can program one to turn on after 10 seconds, 7 seconds, any time, then turn off at any time, then turn back on at another time, then turn off again later, then on, then off, then on, then off, etc. You can program it to turn on and off at more than 100 time points if you wanted to. Cost is maybe$2 USD or even less. Chip would be an 8 pin dip package. You can even get a PC board already made with a chip on it so all you have to do is plug it into your USB port, download the IDE software, follow a few simple examples, and probably within one day you would have the most sophisticated timer you ever could image that would be very very difficult to do with logic gates or similar.

The Arduino line of microcontroller boards and chips are very popular and easy to work with. You can start with that then move to a single chip if you like. Worth looking into if not anything else. You'll never go back to logic gates.

Also, with the single chip solutions you can program them to power down for some time so they dont use battery power all the time. I created a custom refrigerator monitor that used 3 AA batteries that lasted for two years before they needed replacement.

If you still wanna use a 9v battery then you also need a low quiescent current voltage regulator to supply 5v. Better to use three AA cells though.

Oh and also, with a single 8 pin DIP package microcontroller you could monitor four different USB ports at the same time. Either of them goes out you can trigger the alarm. You can also program the voltage trip point to be 0.1v, 0.5v, 1v, 2v, 3v, etc. with little difficulty.
Thank you. I did consider using the digispark attiny85 (with usb pcb) and even purchased 5 units but haven't got to the point of playing with it and figured it will only slow me down .. so I have zero knowledge how to code it and connect the parts around it .

Would you like to help me with that?

I guess this Digispark code should wait for USB power to go down .. and if so - will wait 10 seconds then activate the buzzer for 10 seconds using the 9V battery ..

#### Attachments

• 45.4 KB Views: 3

#### MrAl

Joined Jun 17, 2014
9,169
Thank you. I did consider using the digispark attiny85 (with usb pcb) and even purchased 5 units but haven't got to the point of playing with it and figured it will only slow me down .. so I have zero knowledge how to code it and connect the parts around it .

Would you like to help me with that?

I guess this Digispark code should wait for USB power to go down .. and if so - will wait 10 seconds then activate the buzzer for 10 seconds using the 9V battery ..
You should look at the help files especially the one with the commands in it. There are not that many to learn.

#### MisterBill2

Joined Jan 23, 2018
12,424
Below is an LTspice simulation is my take on a simple circuit that does what you want:
I used a CMOS inverter buffer to drive the buzzer, since it has a fairly predictable trigger point to minimize variation in the delay time, and draws only a minute leakage current for power.
Each output can sink about 8mA worst-case, so four in parallel should be more than enough to power the buzzer.

The 1 megaohm resistor will be drawing current from the 9V battery when the 5V USB voltage is applied, but that is only about 0.08 Ah/year so the battery will still last its normal shelf life.

Of course you need a switch to turn off the 9V when the device is not connected to the USB port.

View attachment 270522
Use the same circuit, EXCEPT that use one of the inverters as the pulse oscillator That makes it stand alone and not using the transistor. Use a piezo sounder disck and drive it at resonance and it will be quite loud. Add a diode OR gate so that the +5 from the USB supply keeps the osc off, and replace the 9 volt battery with a large capacitor charged from the USB through a diode.
AND note that the CD4049 only has 14 pins. or is it 16, but not 18. And if the TS is not able to locate the pinout then probably not able to build it anyway.

#### MrAl

Joined Jun 17, 2014
9,169
Below is a circuit that uses a supercapacitor to power the circuit, which charges from the USB 5V power.
But don't know if the 0.33F 6V supercapacitor cost is too high for this application.

View attachment 270539
Hi,

Just one thing i would check also.
The power source is not shown but i assume it is Vdd and that is positive.
The other thing i would check is what happens to the azz end of the 15uf caps when the power source (Vdd) either shorts or goes away. With the transistor on it looks like the positive end of the first 15uf cap sees low impedance to ground while the negative end sees high impedance, so with a charge in that cap the negative end could go very negative possibly blowing any protection diode in the CMOS inverter.
Just something to be aware of with these kinds of circuits.
I'd also check the negative end of the second cap too to make sure it cant go negative at any point. I an wondering what the voltage is there when the previous CMOS output goes low. Usually if something like that goes negative there is a current limiting resistor to limit the current into the input of the next stage (or even transistor base in some circuits) so that the protection diode, if any, does not blow out.

Last edited:

#### Danko

Joined Nov 22, 2017
1,365
And if the TS is not able to locate the pinout then probably not able to build it anyway.
I guess he is able:

#### dankori

Joined Jul 1, 2022
9
Thank you all for the huge help and time spent on this.

While I wait for the components (mainly CD4049) to arrive I found an online simple simulation site called tinkercad and managed to tinker with all the different approaches I found online -to get me to my original goal.

While this may be too "noob"'s perspective on the solutions - they are still a good (start of a) solution for me.
I still have problems with each of them and decided to ask you guys( and girls??) on your perspective on each of the three approaches. I think The Relay approach is the simplest one..