I sure would love to see an update to this project. Many suggestions have been made in the comments on how to improve on it. Did you manage to omit the battery display? Does a 5v step up converter give the PI more time and stability to shut down? Or does it consume too much on its own for it to give an advantage? I really love this idea and your solution is so simple and can potentially prevent a failure of any PI project. If you got the chance, an update on your findings would be very helpful.
Would it be beneficial to have a current limiting resistor in series with the caps, to limit the power draw from the power supply to prevent damage (or overload shutdown)? Along those lines, would a very high resistance "bleed resistor" make sense in parallel with the circuit, to ensure the caps drain fully when powered off? Or will the Pi attempting to power on with the residual voltage have the same effect?
1. Series resistor: Yes. But the thin wires of normal USB cables are more than enough for small capacitors. 2. Parallel resistors: Yes, this could be a good idea. My current setup draws enough energy that the caps are discharged in maybe 10 minutes (not measured).
Andreas Spiess if you put a 1M bleeder resistor across each individual super cap, the two together also act as a resistive divider that balances the two caps out.
I am not sure, if 1M is not too high. I would try 100 - 1000 Ohms, because the internal resistance of a capacitor during loading can be quite low and the 1 M then would have no effect. I think, that the 2.5 - 25 mA additional current would not hurt too much...
Compared to the specialized KA75xxx, I would recommend a more general hobbyist part like the LMV431x. This allows external voltage selection resistors to select function from ~1.24V to 30V. These parts can also be used as shunt regulators to balance across the supercaps. The LMV431 is but one variant of the TL431/TLV431 parts, and there are several others to select amongst as well. Useful additions to the parts box.
These two chips are somehow similar, but they behave different. I just checked both. The KA7533 makes exactly, what I expect: It pulls the output to zero if the input is below 3.3 volt. I connected pin 1 and 3 of the TL431 and via a resistor to the input. pin 1/3 is then the output (page 1 of the data sheet). Like this, it behaves like a 2.5 V zener diode, which is the contrary what we need. The output is caped at 2.5 volt, but there is no sharp edge below 2.5 volt, because the output follows exactly the input in this area (as with a zener...) But maybe there is a trick I do not know?
Thanks for checking this out. The trick is letting the regulating TL431 pull down the base/gate of a PNP/P-channel transistor to control the output. www.circuitlab.com/circuit/57h5dm6wghnm/ka75xxx/ So this requires some additional components compared to the KA75xxx approach. The upside is that it's all standard "jelly bean" components that can be easily obtained and used for other purposes. I'm still fairly new to electronics myself. Building circuits from common parts rather than using more specialized parts has been a good way to learn.
Thanks for the link. For me, this is more complicated and for such a small device like the power monitor, I like the KA75xxx (even it might be obsolete). It just does exactly what I need for a few cents.
Hi, thank you for your excellent video. I live in Spain and frequently get power blips (electric is cut for about 1 second or less) which causes the pi to stop working. To get it going again I have to repower it which is a pain. My pi is a 3B+ and runs from a 60Gb SSD. I wondered if I could use this just to keep the pi working during the blip (I don't want it to do a controlled power down when there is a blip). Cheers....
To make it cheaper, why not use a transistor to signal GPI 18; write the code so when the signal is low, it will shut down. It would also make your projects smaller.
I wanted to have a clear voltage level where the shutdown starts.If I start too low, I lose too much energy, if I start too hugh, the RPi shuts down if the USB is a little low for a moment. Here is an example where they do not use any transistor: www.hackerspace-ffm.de/wiki/index.php?title=Raspi_EDLC_UPS (link is from Urs). They use bigger capacitors.
Did you use constant current source for charging the caps? I would not rely on maximum current that the usb plug can supply. I did some industrial electronics with 50-400F banks of 6 supercaps which needed constant current charging and balancers for safety. I suggest at least small balancing resistors so the voltage will be divided equally over two supcaps.
You are right with big caps. But here, with the usually thin USB cables, and the current limits of the USB charger, I had no problems. The time of high currents (>1A) anyway is only seconds. But, of course, you can include a small resistor. The two resistors across could have another nice effect: Thy could discharge the caps faster that the RPI boots when power is back...
I think, this is a good idea to limit current spikes. I think they act more as current limiters than as resistors, so they should not have a lot of energy loss.
Great video!! I've just built this but i've a problem in balancing the supercaps: starting from both at 0V and charging with 5V, the second cap (the nearest to the ground in the schema) is charging very slow compared to the other. When the first cap reach is 2.7V, the second is around 2V...I thought to not use the active balancing because of cheap supercaps and meant to be used rarely, what do you think?
zener diode cant balance cells, it just can protect from overvoltage, capacitors dosent have any problems with unbalanced cells. only problem is overvoltage
Love your content, I am wanting to know if this could be used for a Pi in a car. I have an aftermarket ECU and want to monitor it through a Pi set up. The safe shut down is all i have left to figure out. Thank you!
@AndreasSpiess Thank you for your reply. Do you have an itemized list of hardware for this? I will be using a Pi 3. Thank you again. I'm so new to all of this.
Add a resistor in series with the 500F capacitor's ground. It should lower the initial power draw on the charger. Just make sure the Pi has sufficient voltage during shutdown. Alternatively you could also provide the Pi with a 3A charger; but should work with as low as a 1A charger for the 3B and 3B+, and 0.5A for the Pi 2, and lower models.
I think your low voltage detector should be BEFORE the caps along with a diode to prevent revere current from flowing into the monitor. This would allow to trigger shutdown immediately when power is removed. Now, you have to wait for the caps to go before a certain voltage.
Could you use a 10 ohm series resistor to limit current to 500mA when charging the larger supercaps? They would buffer any surge current needs of the rPi I think? It would take a lot longer to reach working voltage but would be safe on pretty much any USB charger that way.
A resistor can be used to limit current. Usually, USB chargers have a current limitation to around 2A. But if you try to limit the current for the Pi it will crash because the voltage drops if it does not get the needed current (ohm's law).
Put a small resistor over each capacitor like a resistiv divider so 2,5v gets connected between bouth caps. >The one whith more voltage gets discharged a little Bit faster than the other one over its resistor. And they discharge the caps until they are empty, so charging is always startet from 0v. Its Not the Best solution, But the simplest one.
Hi Andreas, this would not work for me, connecting discharged supercaps in parallel to the USB power supply is like a dead short, my "smart" USB power supply detects this and does not start.
Yes, that sounds sensible Javier - well, the existing supplies as documented elsewhere are not doing too well from flat either. I can see a custom design coming on.
I used my normal one and it worked. It is also not completely clear to me how your device would detect that because a RPI without super caps also start at zero volt.. The only way could be with over current.And this can be corrected by a small series resistor or thin wires of a (cheap) USB cable.
It has a DC-DC converter in it and the driver shutdowns the USB port whenever it detects a short. I once tested those 500F supercaps and they can easily pull 5Amps! from a power supply (and even higher, but the supply was limited to 5A).
You are right. Such large caps can also pull 500 A (they are built for that). Here, the caps are much smaller. But maybe your loader is really too smart. ;-)
5V power supply to LTC4411 INput pin. Supercaps and Raspi power input to OUTput pin. GPIO-pin and 3.3V pull-up resistor to STATus pin. GND and CTL to ground.
Have You tried other Raspis than Zeros? They have ideal diodes built-in. Needs only a voltage conversion Vin --> GPIO. One concern is how the polyfuse can handle the surge current of the capacitors.
Great video. One disadvantage always seems that you cannot take advantage of a large percentage of the capacitors energy because voltage drops too quickly. Do you have any thoughts about using some type of boost regulator to maintain the 5v as long as possible?
The idea here is, to have just enough energy to shut the RPi down. And I wanted it KISS (keep it simple and stupid). But, of course, you can add such a device.
I got a box of assorted caps, leftovers and there are supercaps. I didn't really know what they were so this video was great. I also have those meters so I'm gonna built this
Is this still a valid solution for the safe shutdown of e.g. a RPi 3B+? Also, couldn't you connect the USB-power (before the caps) to one of the GPIO pins (dropping to 3.3V with resistor) to check when it goes from high to low? And maybe add a resistor after the caps to gnd to make sure they discharge?
Thanks fo the video. I also use Supercaps for a similar purpose but for devices with less power consumption and/or a bigger Voltage tolerance (Homematic battery devices). For that cases they are a good choice. For your application they are not so good: The RasPi draws a lot of power and the voltage tolerance is quite small. This results in big and expensive supercaps drawing a lot of current during charging. For this purpose batteries or accus do a better job, they keep the voltage better. I overcame this charging issue with a schottky diode and a charging resistor, but this will not work here because of the low voltage tolerance. I also Lithium primary cells which have a promised shelf time of 15 years, but this will not work well for the raspi in this simple way. The easyest way for you would be a 1 cell power bank which allows charging while delivering current. It is easy and cheap. This was already mentioned before in another comment. Next possibility is using an Orange Pi Plus 2e with armbian instead of a RasPi. The Pus 2e has 16GB eMMC on board and you can get rid of the SD Card. It handles hard resets much better than the SD Cards of a RasPi.
I agree with battery vs super caps. This is, why, in my last video, I used a battery UPC. Here, the whole idea is to only get a proper shutdown. Therefore, I only need seconds of power and the caps are quite small. The idea with a power bank is very similar to the concept of the battery UPC. It still needs a protection against abrupt cutoff without shutdown (if you care about that). Maybe, the Orange Pi is the solution, if you do not need to shut it down before switching off. I had also problems with charging the power bank while using it to power the Pi. Obviously, this seems not to be a universal feature...
Thanks for your reply. I agree, unfortunately this is not an universal feature of power banks. some have it, some do not (the majority, I fear). My RasPis and OPis are atteched to the network. And beeing so, they also can be aggregated in a "server area" and for this area, includung the router, RasPis, OPis, NAS, Homematic central (CCU), DECT phone I use a commercial available USV, e.g. APC 700. This solves all these issues and is not too expensive. To do it even better you can add a bypass switch so you can change the accu of the UPS without powering down your devices. The Pb accus indeed have a limited livetime of 5 or 10 years depending on the type. For my distributed WeMos fleet I do not have a backup and up to now I do not need it. I use them as sensors.
Really cool project! Just wondering what the advantages are of your voltage detector over using an external ADC? I guess for the ADC to need a constant reference voltage?
@@paulpvhl1930 Great idea. Just connect the ADC in of the Pi-Zero via a divider to the 5V input. With a simple program, measure the voltage, and if it drops, shutdown. I will try that soon.
Is there a version of Jessie that has a read only boot partition? If you kept any app on a read/write partition, or write data to the cloud, you might be able to accept a power failure without issue.
John Washell yes, there are several distros based on debian which have a read-only system disc. just check out any live disc systems. i would also separate the write memory to different physical memory and not just a seperate partition.
can we use a diode and a resistor so the raspberry turns on immediately? the charge of the super capacitors is made through the resistor and the discharge through the diode, that way the charging of the super capacitors doesn't sag the power supply
@@AndreasSpiess The power up is really slow because you're charging the capacitors, and it sags the power supply. You can create a parallel path that powers the raspberry directly from the usb, from that parallel there's a resistor that charges the capacitors slowly and a diode that feeds the raspberry from the capacitors when the power supply is off. Maybe i'm seeing it wrong... just a though
It is only useable if you're using RPi almost-unloaded. If you're using a HiPower WiFi dongle or even a regular one - it won't do it's job and you'll have an unclean shutdown. Also there's a trick about a shutdown time: it can be minutes or tens of minutes depending on the task performed.
You are right. I use the RPI only for tasks like Mosquitto broker, data logging, node red, etc. So, my shutdown time is not very long. In your case, a battery like in my former video is then the right solution.
Actually, there's an idea I have about this type of shutdown - I'll post it if I'll be successfull in implementing it in hardware and software. Also - take a look at Orange PI, it is Allwinner CPU's, they can be used with powersave governor during shutdown to make it more power-efficient.
Does this circuit handle power up of the rpi when power is back online? It seems to me that if the rpi completely shutdown and the power was out the entire time it will power back up after power is restored but what happens if power is restored in the middle of the shutdown process? I've seen some complicated (complicated for me) circuits that should handle this but never figured them out enough to trust myself to build and debug them. I am thinking of using attiny as a controller for that to handle the work and interaction with the rpi.
Yes, it is. Actually, if you wait long enough, this setup should boot if power comes back (you have to wait a few minutes). You could add a resisor across the caps to reduce this time (proposal from a viewer)
This is pretty cool solution for a problem I've heard about several times. The ext4 filesystem gets corrupted when you force power off. Wouldn't migrating to a btrfs root filesystem be way easier than all this though? It's never in an inconsistent state.
Hmm, as a side bonus, this would create a power reserve if you are using a lower rated charger when the draw on the new raspberries spikes for a couple of seconds.
though i fully understood the workings with yr battery pack in the previous video, here i come upon something confusing. why is the monitor connected to the 3v3 as well? shouldn't it be connected just to the 5 volt via the 2 diodes, to ground and to gpio 17? or did i misunderstanding your circuit?
I do not use batteries here, I use super caps which are charged to 5 volts. I connect the wire to 3.3 volts which is connected to GPIO18 pin (through a FET). I read, that the Pi GPIOs are not 5 volt tolerant.
yes, that I fully understood, but my confusion was with the figure on 3:53 but I think i understand it by now: The gauge gets 5Volt through 2 diodes and the 3.3Volt goes to the transistor that triggers the shutdown via GPIO18. I had forgotten it was not open collector but had a pull up to 3V3. Great stuff, I have 2* 6 Volt supercaps that I will put in parallel, which brings me to 5F. Will give that a try.
nice, kannst du auch sagen welches wlan-modul und tastatur-maus-kit du nutzt ? mein pi rollt gerade an ;-) da brauch ich dann nicht lange zu suchen bzw experimentieren. danke.
No, they do not. But I did not find a lot of stuff concerning this topic. Because they are in series, both should get exactly the same amount of current at least. One source suggested, that for small caps and well below the maximum voltage should work ok. So, I did it. And, if the caps are destroyed after a while, it is not so expensive... (I mentioned it in the video, that I have no long tern experience)
the supercapacitors supply power to back in my usb pin where i connect other component so what to do to stop the power in reverse direction form super capacitors ( i used diodes all type but because of 5V and 3A there so voltage drop between 0.6V to 1.2V and raspberry pi 4 want minimum 4.63V and 3A power supply what to do now?
Hi Andreas, Thank you very much for this interresting video. I am currently building a Phoniebox for my 4 year old and the the "Göttibueb" of my wife and it would be neccesary to have something that is shutting down the Rasp when the cable is pulled. Kids can be very cruel with Raspis ;) I have bought a Geekworm Raspberry UPS Hat but this device has some major disadvantages (like a power button to switch it on after power failure) which makes it unuseable for my project. If you want I can also send you one of these to for analysis, hacking or improvement :) But my question would be if you can guide my to have small UPS with supercaps only without the fan control? What would be the smallest config to get this working? Cheers, Thomas
I do not know of a UPS with super caps. But with this video (and maybe the one I did for the protection of super caps) it should be possible to build one yourself.
link to your site points to the https version, which is configured wrongly (certificate for an other host) and then brings to a 403 forbidden page... going in http is fine
I'm trying to find a shop which sells the KA7... chip but I am unable to find it on BG or AE. neither the alternatives TCA... or MAX.... The link you did put in the remarks does not work for me. Any solution?
you should use a simple balancing circuit for the caps (just put an appropriate zener diode in parallel, one for each cap), because of their differing internal resistances they will act like a voltage divider, and one of them could get too much voltage
Do you have experience with that? Because, I am not sure, if Zeners alone are good enough, because they also have their tolerances. Usual balancers are more complicated. But they are also made for much bigger caps.
a zener would basically discharge the capacitor when the voltage drop over it gets too high(creates a lot of pixies when you just put a big overvolted supercap on it). you would have to experiment with values. but before you go through all the trouble, let the system run for a while and then measure the voltages of the caps. yes zeners arent perfect, and sadly not available in arbitrary values, but there are some available with 2.7V
I asked, because I did also some experiments :-) And it is not easy to get these low values, at least not for me. I have all of them, starting at 3 volt and up
you could try to put 4 normal diodes in series to get a similar voltagedrop :P or just buy a few here www.ebay.de/itm/Zener-Diode-VISHAY-500mW-10-25-50-100-Stuck-Spannung-2-4V-75V-Dioden-/192070809110 they are pretty cheap i guess. 100 of then for 6 bucks
Thanks for the great post could you provide a diagram using the supervisory circuit (KA75450) and the other resistors you talk about below? I want to test this on my PI. Also is there a way to have the capacitors discharge faster? Thanks - John
Are these Farad numbers on the capacitors real or we can't trust them (like some Chinese batteries) ? Maybe there is a capacitor contest in a later episode
You can make it without the voltage detection harware as well if you want it some cheaper. since most likely you will use ethernet for your server/24/7 running pi. that means that you can use the network connection to test for a power outage, no network mean no power, or at least no reason to be on anymore, you can edit the bootfile to wake on lan to automatically turn the pi back on, this is especially helpful for when you use wifi or such, since wifi sometimes has random periods of time where it stops working. you can either use a small ram only os pre-boot to make it work on wifi, even without the dedicated hardware, or setting up the router properly. another more easy step would be to save all files, and mount the drive as read only until the network reapears, this way you do not need to restart if it is only a network outage, by unmounting the sd or mounting it in readonly you won't corrupt it, many raspberry pi oses also have this functionality building, however you need to customize it since in general they boot the os in ram from start when this setting is enabled.
This device was mainly meant to avoid an fast shutdown which can corrupt your SD card. Your measures are good and can be added in addition. I think. Are you sure the Raspberry Pi supports WOL?
@@AndreasSpiess this is also solely meant to avoid corruption. The raspberry pi does not officially support WOL however it can be inplemented both softwate based and hardware based without to much weirdness. Hardware based it can be done easly by splitting the ethernet cable and connecting it to a small ic like a arduino, then when a network signal is detected it enables a transistor or io pin to trigger the raspberry power on pin, this method is really simple but has the cost of a small ic qnd optionally(for more accuracy such as requiring a speciffic package to start) a ethernet shield/chip connected. Note that a arduino in this case could be used without ethernet shield since the arduino uno is fast enough to work as a ethernet driver, so it can be quite cheap still. The other method however does not have hardware cost asociated to it since it is actually build in to the raspberry pi by default but rarely used for reasons such as wol. But the raspberry pi boots up whenever lower os connected, this can be used directly, however since the power might still be unstable wol might be desired, when you install a os on the raspberry pi it also installs a bootloader, that bootloader can be changed/modded if required to at first connect in read only to protect the msd/sd/usb might the power stop again. You can do the following directly in the bootloader, but also in a small micro os which you boot in ram mode and read only this only has the functionntonwait for a message and then when it gets the message it powers up the normal os/switches to it. The first steps are most easly done as a micro os, the last one is most easly done if you go for modding the boot loader. Many linux bootloaders allow you to easly mod them directly from the in linux terminal.
Another great video Andreas! Two questions: (1) for how long RPi Zero can work after power off on battery and how does it compare to super caps? I guess it can work longer on the batteries (2) after the shutdown when the power comes back does RPi start automatically? Thanks!
1. The Zero works only a few seconds after power off. Just enough for a safe shutdown 2. It does not boot when power comes back. Only if you wait for a certain time. Then, the caps are discharged completely and the RPi should boot again
Andreas Spiess can you please draw a more precise schematic for a guy like me? On your final schematic is only "monitor" not the transistor, also on your live picture is two blue resistor. I just dont want to blow up things.
If your data are so important to go to all this trouble I would choose to use a VPS from scaleway. It costs 3 euro per month but it is faster than the pi and downtime is very rare so it is very suitable for applications where sensor signals are important like fire alarms etc.
Then you need to have a good internet connection, that is not down for long times. There are other ways which you don't need to bother with a VPS at all, like MQTT service and storage in the cloud. You have a local machine because you want to control and log things locally, on the same site as the things you control. Because as long as you have a working local LAN, you want to be able to control your devices.
Yes, it totally depends on your needs and application. In my case I found it more productive to outsource the server/data center part to a 3rd party and focus on making my devices resilient to network and power outages as you describe. For my applications it makes more sense since my LAN is powered by my router which means that if the LAN is down then in all probability the internet is down also so a local server would not work either.
I don't see paying for an ongoing fee, introducing cost and connectivity potential issues, when you can do this reliably on a Pi. Despite one hiccup I've documented on the blog, almost definitely through not understanding power supply issues well enough at the time, I've recorded years' worth of data on a Pi without issue and now that we have Grafana, doing a decent job of displaying the data as well. Indeed the only service I've had trouble with - is online speech - with the company (presumably) selling off to Amazon.
Hello Peter, first I'd like to say that I am a fan of your blog and the work you did with the raspi setup script. Now, regarding the issues you brought up, as I said above there is no wrong/right way to do this, and yes ongoing fees is an issue you have to consider when setting this up (connectivity not so much, there are things you can do to easily mitigate any issues). The raspberry pi route requires upfront investment for hardware and time, the hosted solution requires a lot less upfront investment but you do need to pay 3 euros every month. It all depends on your needs. In my case I opted for the hosting solution because I need internet connectivity anyway and I much prefer working with something other that raspbian on a faster machine.
Well of course - you have me there - there is the cost of the Pi - I usually refer to Pi in the generic sense of course- you can buy a decent ARM board for far, far less than a real Raspberry Pi - your point is valid - except for the reliance on external connections and that depends partly of course on where you spend your time. I would not trust important data collection here in rural Spain to reliance on the broadband and until recently I would certainly not have trusted it to at Plusnet connection, though thanks to the new router that particular issue now seems to be history.
Interesting but not necessary. Just enable Overlay File System to make the boot sector read-only. That way an abrupt shutdown will not corrupt the SD card or USB drive.
I would suggest the way to fix this sort of problem isn't to try to stop a power failure but instead make the setup resistant to such failures i.e. making the OS read only so it can't get corrupted or in a bad state from power failure during a write.
I am not a Linux expert. But it seems not to be about the OS only. When I shutdown, also the running applications do some "shutdown" (probably saving some data). I assume, because of the limited # of write cycles on SD card it is not appropriate to write each bit immediately to the "disk"...
Disk IO is slow so Linux (Windows etc too) usually don't do write immediately but you can configure that stuff on Linux so that writes happen sooner with the loss of some performance etc. There are options you can use for ext4 file systems that make them a lot more tolerant of the power getting pulled too. I know of an expensive commercial product that uses a super cap setup with tweaked settings for the kernel/filesystem and it does work most of the time to save the from thing getting bricked but it's not perfect. A fixed OS image built with buildroot, yocto or similar + rw data that can be recovered over the network if it gets corrupted is the way to go IMHO. Wear levelling for SD/ eMMC is done in the controller on the card/chip itself which is why you can use regular filesystems like ext4 and not the special flash filesystems like ubifs, jffs etc.
ouch i deleted my comment by mistake!! I said basically i use cheap power banks (usd $ 2.5 dollars) and it provides about 40 minutes of power depending on load. (it includes battery + circuit board + case). Of course it also provides power while charging so it's like a mini UPS. I've been serviced by this during years.
search: "381674926080" on eBay. They claim 2600mAh or more, but that's bullsh*t, I tested them, usually store about 730mAh, but that's enough for a nice backup or mini UPS, and being honest, that's fair for what you pay. Just replace included crap battery for a decent one, if you want more capacity (or parallel with others). It would be nice a review of this at your style. Regards!
PD: item title is "Portable 2600mAh USB External Power Bank 18650 Battery Charger For Cell Phone" so you can choose at your convenience, be carefull many just sell the box/case "battery not included". {Of course I use soldered wires to the board, not the bulky USB connector}
Thanks for the video. This is food for thought for my problem; my mppt controller charges a battery and RPI zero during the day, at night the RPi discharges the battery until the battery's low voltage circuitry disconnects the battery from anymore drainage. The next day the battery remains in this disconnected state eventhough the charge controller is receiving energy from the solar panel. I have to manually disconnect & reconnect the battery to get things working again. So I need to design some circuit to do this for me...
This is a problem of many LiPo chargers. The UPS I used in my previous video has the same problem. You just should not discharge the battery completely. But the device has no protection
How about putting a Shotkky diode in parallel with a current limiting resistor, in series with the supercaps, with the diode pointing towards the +ve rail. In that way the diode will block charging current and so the charging current will flow through the resistor. You can then limit the charging current by choosing an appropriate resistor. Once the is lost, the diode will be forward biassed, and has a very low forward voltage, so your Pi will be powered from the supercaps largely unimpeded.
You are right. This is a good thing to solve a problem. But I did not experience any problems, because my cheap USB cable has already a resistance, my USB charger has a over-current protection, and the high current lasts only a few seconds. So, there was no need for more parts. But all of this changes, of course, if you use bigger caps.
Herzlichen Dank! Mir ist die Seite bisher nur durch Datenblätter aufgefallen; kannte ich neben Aliexpress und Banggood, die ich erst durch deinen YT-Channels kennenlernen durfte, noch gar nicht. Tolle Arbeit, besonders auch die Kniffe und Wissenstransfers zwischen deinen eigentlichen Kernthemen der einzelnen Videos!
Sie sind normalerweise etwas teurer und verrechnen Porto unter einem gewissen Betrag. Dafür bist du sicher, dass du echte Ware kriegst... Vielen Dank for dein Kompliment!
Love your channel Andreas! Sorry that this isn't relevant but I am struggling to find an answer and it would be much appreciated if anyone could help! I have built a neutron detector (university project) with a Raspberry Pi 2B and have programmed it in Python 2.7. I am detecting neutrons via an electrical signal sent to one of the USB ports by a soundcard and I am reading the signal using PyAudio. It works fine apart from the fact that it can only detect up to 40 counts per second as this is the highest amount of reading PyAudio seems to give me! Is there any way I can get PyAudio to give me more than 40 readings per second? This is the PyAudio code I am using: stream = pyaud.open( # Open input stream, 16-bit mono at 44100 Hz format = pyaudio.paInt16, channels = 1, rate = 44100, input_device_index = -2, # Input device likes to be -2 ;) input = True, frames_per_buffer=8192 ) # This function reads the data from the sound card: def RecordCounts(): global CV rawsamps = stream.read(1024) samps = numpy.fromstring(rawsamps, dtype=numpy.int16) CV = analyse.loudness(samps) Thanks in advance!
I have no idea. I never worked with any of these things. But maybe it would be a possibility to use a microphone, a small amplifier (OpAmp), a diode, and a capacitor to create a digital signal (one per neutron) out of the audio signal outside the RPI. Then, the RPi just has to count logical signals. And this is for sure faster... Or maybe you even do not need a microphone if you connect the output of the sound card directly into your amplifier.
I think, this is a very similar concept. The two resistors across the caps is a good idea, because then, they discharge faster and the RPi boots automatically... A PCB for my setup would be an "overkill because I soldered it together in about 5 minutes (two resistors and a transistor).
HUHHHH i did not see how you program it shutdown creating a signal is the easy part its software that is the problem since i do not know how linux work lets see if #131 has the anwser Edit1: it was in the 131 lul
Hello sir good Video I have a question about esp32 i want to make an auto switch between battery an dc power i have used this x804 ruclips.net/video/XA8qaMbrQ6Y/видео.html but like it said in the video it have 700 ms beteween the 2 state and the esp32 reboot how can i do for the esp32 do not rebbot
You are right. Thanks for the link! They use bigger caps and therefore use some protection resistors. And they have no voltage reference, which, I think, is not ideal. But with the bigger capacitors, they can maybe start the shutdown later and so, do not need an exact voltage level. The parallel resistors, however, are a good idea. With these, the RPI will re-boot after the power came back (they discharge the caps in minutes)
I sure would love to see an update to this project. Many suggestions have been made in the comments on how to improve on it. Did you manage to omit the battery display? Does a 5v step up converter give the PI more time and stability to shut down? Or does it consume too much on its own for it to give an advantage?
I really love this idea and your solution is so simple and can potentially prevent a failure of any PI project.
If you got the chance, an update on your findings would be very helpful.
We tried to create a power board with all the nice things in it. But unfortunately the project is on hold because of the supply chain problems...
Would it be beneficial to have a current limiting resistor in series with the caps, to limit the power draw from the power supply to prevent damage (or overload shutdown)? Along those lines, would a very high resistance "bleed resistor" make sense in parallel with the circuit, to ensure the caps drain fully when powered off? Or will the Pi attempting to power on with the residual voltage have the same effect?
1. Series resistor: Yes. But the thin wires of normal USB cables are more than enough for small capacitors.
2. Parallel resistors: Yes, this could be a good idea. My current setup draws enough energy that the caps are discharged in maybe 10 minutes (not measured).
Maybe a limiting resistor to slow down the caps charging and a diode in parallel with the resistor to allow a fast discharge?
Andreas Spiess if you put a 1M bleeder resistor across each individual super cap, the two together also act as a resistive divider that balances the two caps out.
I am not sure, if 1M is not too high. I would try 100 - 1000 Ohms, because the internal resistance of a capacitor during loading can be quite low and the 1 M then would have no effect. I think, that the 2.5 - 25 mA additional current would not hurt too much...
Bleeder resistors are not the solution for limiting the current, just for discharge and balancing. There's no reason not to do both!
Super capacitors are my favourite electronic component, mainly for testing how much current something can take before melting 😀
I also liked the concept. But here, I think, they work for the money... Not just producing fun!
Compared to the specialized KA75xxx, I would recommend a more general hobbyist part like the LMV431x. This allows external voltage selection resistors to select function from ~1.24V to 30V. These parts can also be used as shunt regulators to balance across the supercaps. The LMV431 is but one variant of the TL431/TLV431 parts, and there are several others to select amongst as well. Useful additions to the parts box.
These two chips are somehow similar, but they behave different. I just checked both. The KA7533 makes exactly, what I expect: It pulls the output to zero if the input is below 3.3 volt.
I connected pin 1 and 3 of the TL431 and via a resistor to the input. pin 1/3 is then the output (page 1 of the data sheet). Like this, it behaves like a 2.5 V zener diode, which is the contrary what we need. The output is caped at 2.5 volt, but there is no sharp edge below 2.5 volt, because the output follows exactly the input in this area (as with a zener...)
But maybe there is a trick I do not know?
Thanks for checking this out. The trick is letting the regulating TL431 pull down the base/gate of a PNP/P-channel transistor to control the output.
www.circuitlab.com/circuit/57h5dm6wghnm/ka75xxx/
So this requires some additional components compared to the KA75xxx approach. The upside is that it's all standard "jelly bean" components that can be easily obtained and used for other purposes. I'm still fairly new to electronics myself. Building circuits from common parts rather than using more specialized parts has been a good way to learn.
Thanks for the link. For me, this is more complicated and for such a small device like the power monitor, I like the KA75xxx (even it might be obsolete). It just does exactly what I need for a few cents.
Hi, thank you for your excellent video. I live in Spain and frequently get power blips (electric is cut for about 1 second or less) which causes the pi to stop working. To get it going again I have to repower it which is a pain. My pi is a 3B+ and runs from a 60Gb SSD. I wondered if I could use this just to keep the pi working during the blip (I don't want it to do a controlled power down when there is a blip). Cheers....
You can try it. It should work.
To make it cheaper, why not use a transistor to signal GPI 18; write the code so when the signal is low, it will shut down. It would also make your projects smaller.
I wanted to have a clear voltage level where the shutdown starts.If I start too low, I lose too much energy, if I start too hugh, the RPi shuts down if the USB is a little low for a moment. Here is an example where they do not use any transistor: www.hackerspace-ffm.de/wiki/index.php?title=Raspi_EDLC_UPS (link is from Urs). They use bigger capacitors.
Did you use constant current source for charging the caps? I would not rely on maximum current that the usb plug can supply. I did some industrial electronics with 50-400F banks of 6 supercaps which needed constant current charging and balancers for safety. I suggest at least small balancing resistors so the voltage will be divided equally over two supcaps.
i tough the same
You are right with big caps. But here, with the usually thin USB cables, and the current limits of the USB charger, I had no problems. The time of high currents (>1A) anyway is only seconds. But, of course, you can include a small resistor.
The two resistors across could have another nice effect: Thy could discharge the caps faster that the RPI boots when power is back...
I think, this is a good idea to limit current spikes. I think they act more as current limiters than as resistors, so they should not have a lot of energy loss.
Great video!! I've just built this but i've a problem in balancing the supercaps: starting from both at 0V and charging with 5V, the second cap (the nearest to the ground in the schema) is charging very slow compared to the other. When the first cap reach is 2.7V, the second is around 2V...I thought to not use the active balancing because of cheap supercaps and meant to be used rarely, what do you think?
Hello Mr. Spiess, what Diodes and NPN Transistor are you using in this build? Great Video, i learned a lot from you!
just what you have. It does not matter too much. Just no shottky diode because it has only 0.3 volts drop
Not sure if it is a good idea but if you place a 2.7 Volt zener diode over each cap it would solve balance and potential overvoltage issues.
not needed because max voltage is 5.25V and caps support up to 5.4V. and also if they are same capacitance they will balance itself up.
Wouldn't be too sure about that. Same issue happens with Li-Ion cells. A bit of tolerance like 10% and it might go wrong.
zener diode cant balance cells, it just can protect from overvoltage, capacitors dosent have any problems with unbalanced cells. only problem is overvoltage
Well at least it is some sort of protection that is cheap.
You can do that. I wanted to keep the parts count small. I also do not know, which voltage tolerance the super caps have.
Love your content, I am wanting to know if this could be used for a Pi in a car. I have an aftermarket ECU and want to monitor it through a Pi set up. The safe shut down is all i have left to figure out. Thank you!
I do not see why it depends on where the Pi sits.
@AndreasSpiess Thank you for your reply. Do you have an itemized list of hardware for this? I will be using a Pi 3. Thank you again. I'm so new to all of this.
@@johnhale6468 There is a bit more info in the comments of video #131.
Add a resistor in series with the 500F capacitor's ground. It should lower the initial power draw on the charger.
Just make sure the Pi has sufficient voltage during shutdown.
Alternatively you could also provide the Pi with a 3A charger; but should work with as low as a 1A charger for the 3B and 3B+, and 0.5A for the Pi 2, and lower models.
Good idea.
I think your low voltage detector should be BEFORE the caps along with a diode to prevent revere current from flowing into the monitor. This would allow to trigger shutdown immediately when power is removed. Now, you have to wait for the caps to go before a certain voltage.
That is a good idea! Thanks.
Wonderschön videos meine freund ! Danke fur alles !
Schweiz Felsen! lol !
:-)
Good work Mr Spiess, loving the new webpage and blog. 😊
Thank you. I hope, I can add some stuff there which is not good for a video.
Could you use a 10 ohm series resistor to limit current to 500mA when charging the larger supercaps? They would buffer any surge current needs of the rPi I think? It would take a lot longer to reach working voltage but would be safe on pretty much any USB charger that way.
A resistor can be used to limit current. Usually, USB chargers have a current limitation to around 2A. But if you try to limit the current for the Pi it will crash because the voltage drops if it does not get the needed current (ohm's law).
Put a small resistor over each capacitor like a resistiv divider so 2,5v gets connected between bouth caps. >The one whith more voltage gets discharged a little Bit faster than the other one over its resistor. And they discharge the caps until they are empty, so charging is always startet from 0v.
Its Not the Best solution, But the simplest one.
You are right. This is a good way, if you discharge the caps frequently. Probably (hopefully) not the case in a UPS situation.
Hi Andreas, this would not work for me, connecting discharged supercaps in parallel to the USB power supply is like a dead short, my "smart" USB power supply detects this and does not start.
Yes, that sounds sensible Javier - well, the existing supplies as documented elsewhere are not doing too well from flat either. I can see a custom design coming on.
I used my normal one and it worked. It is also not completely clear to me how your device would detect that because a RPI without super caps also start at zero volt.. The only way could be with over current.And this can be corrected by a small series resistor or thin wires of a (cheap) USB cable.
It has a DC-DC converter in it and the driver shutdowns the USB port whenever it detects a short. I once tested those 500F supercaps and they can easily pull 5Amps! from a power supply (and even higher, but the supply was limited to 5A).
You are right. Such large caps can also pull 500 A (they are built for that). Here, the caps are much smaller. But maybe your loader is really too smart. ;-)
How about LTC4411? A low loss ideal diode with status signal and it has limited 2.6 A output current. Or I miss something?
How would you connect it?
5V power supply to LTC4411 INput pin. Supercaps and Raspi power input to OUTput pin. GPIO-pin and 3.3V pull-up resistor to STATus pin. GND and CTL to ground.
That would also be a possibility. Unfortunately, I did not find many sources for the LTC4411 on Aliexpress and it was expensive
Have You tried other Raspis than Zeros? They have ideal diodes built-in. Needs only a voltage conversion Vin --> GPIO. One concern is how the polyfuse can handle the surge current of the capacitors.
Adding decharge resistors might help for startup balance (if fuel gage is not enough?)
Maybe you are right!
Great video. One disadvantage always seems that you cannot take advantage of a large percentage of the capacitors energy because voltage drops too quickly.
Do you have any thoughts about using some type of boost regulator to maintain the 5v as long as possible?
The idea here is, to have just enough energy to shut the RPi down. And I wanted it KISS (keep it simple and stupid). But, of course, you can add such a device.
I got a box of assorted caps, leftovers and there are supercaps. I didn't really know what they were so this video was great. I also have those meters so I'm gonna built this
Enjoy!
Is this still a valid solution for the safe shutdown of e.g. a RPi 3B+?
Also, couldn't you connect the USB-power (before the caps) to one of the GPIO pins (dropping to 3.3V with resistor) to check when it goes from high to low?
And maybe add a resistor after the caps to gnd to make sure they discharge?
This solution still should work.
@@AndreasSpiess Can it be done without the battery indicator?
I was thinking about having the USB power also connected with a GPIO?
You have to be able to measure battery voltage.
What model is that UNI-T bench VOM? Looks like something I need
Thanks fo the video.
I also use Supercaps for a similar purpose but for devices with less power consumption and/or a bigger Voltage tolerance (Homematic battery devices). For that cases they are a good choice. For your application they are not so good: The RasPi draws a lot of power and the voltage tolerance is quite small. This results in big and expensive supercaps drawing a lot of current during charging. For this purpose batteries or accus do a better job, they keep the voltage better.
I overcame this charging issue with a schottky diode and a charging resistor, but this will not work here because of the low voltage tolerance.
I also Lithium primary cells which have a promised shelf time of 15 years, but this will not work well for the raspi in this simple way.
The easyest way for you would be a 1 cell power bank which allows charging while delivering current. It is easy and cheap. This was already mentioned before in another comment.
Next possibility is using an Orange Pi Plus 2e with armbian instead of a RasPi. The Pus 2e has 16GB eMMC on board and you can get rid of the SD Card. It handles hard resets much better than the SD Cards of a RasPi.
I agree with battery vs super caps. This is, why, in my last video, I used a battery UPC. Here, the whole idea is to only get a proper shutdown. Therefore, I only need seconds of power and the caps are quite small. The idea with a power bank is very similar to the concept of the battery UPC. It still needs a protection against abrupt cutoff without shutdown (if you care about that). Maybe, the Orange Pi is the solution, if you do not need to shut it down before switching off.
I had also problems with charging the power bank while using it to power the Pi. Obviously, this seems not to be a universal feature...
Thanks for your reply. I agree, unfortunately this is not an universal feature of power banks. some have it, some do not (the majority, I fear).
My RasPis and OPis are atteched to the network. And beeing so, they also can be aggregated in a "server area" and for this area, includung the router, RasPis, OPis, NAS, Homematic central (CCU), DECT phone I use a commercial available USV, e.g. APC 700. This solves all these issues and is not too expensive. To do it even better you can add a bypass switch so you can change the accu of the UPS without powering down your devices. The Pb accus indeed have a limited livetime of 5 or 10 years depending on the type.
For my distributed WeMos fleet I do not have a backup and up to now I do not need it. I use them as sensors.
Really cool project! Just wondering what the advantages are of your voltage detector over using an external ADC? I guess for the ADC to need a constant reference voltage?
ADCs usually have built-in references.
Voltage detectors are much simpler.
@@AndreasSpiess OTH an ADC is already present on the SBC. Why not use it?
@@paulpvhl1930 Great idea. Just connect the ADC in of the Pi-Zero via a divider to the 5V input. With a simple program, measure the voltage, and if it drops, shutdown. I will try that soon.
@@harry4516 I'd like to know your results. I really can't see why it wouldn't work but still have no personal experience with the Zero. Thanks.
Is there a version of Jessie that has a read only boot partition? If you kept any app on a read/write partition, or write data to the cloud, you might be able to accept a power failure without issue.
+John Washell I am a Linux newby, so I do not know
John Washell
yes, there are several distros based on debian which have a read-only system disc. just check out any live disc systems.
i would also separate the write memory to different physical memory and not just a seperate partition.
can we use a diode and a resistor so the raspberry turns on immediately? the charge of the super capacitors is made through the resistor and the discharge through the diode, that way the charging of the super capacitors doesn't sag the power supply
I do not understand your question.
@@AndreasSpiess The power up is really slow because you're charging the capacitors, and it sags the power supply. You can create a parallel path that powers the raspberry directly from the usb, from that parallel there's a resistor that charges the capacitors slowly and a diode that feeds the raspberry from the capacitors when the power supply is off. Maybe i'm seeing it wrong... just a though
It is only useable if you're using RPi almost-unloaded. If you're using a HiPower WiFi dongle or even a regular one - it won't do it's job and you'll have an unclean shutdown. Also there's a trick about a shutdown time: it can be minutes or tens of minutes depending on the task performed.
You are right. I use the RPI only for tasks like Mosquitto broker, data logging, node red, etc. So, my shutdown time is not very long. In your case, a battery like in my former video is then the right solution.
Actually, there's an idea I have about this type of shutdown - I'll post it if I'll be successfull in implementing it in hardware and software. Also - take a look at Orange PI, it is Allwinner CPU's, they can be used with powersave governor during shutdown to make it more power-efficient.
Does this circuit handle power up of the rpi when power is back online?
It seems to me that if the rpi completely shutdown and the power was out the entire time it will power back up after power is restored but what happens if power is restored in the middle of the shutdown process?
I've seen some complicated (complicated for me) circuits that should handle this but never figured them out enough to trust myself to build and debug them. I am thinking of using attiny as a controller for that to handle the work and interaction with the rpi.
If power down is long, and the voltage is completely zero, then, the RPi should boot when it is powered again. But there is no guarantee
Thank you Andreas for another great video. Is it possible to auto start (boot up) a raspberry pi ?
Yes, it is. Actually, if you wait long enough, this setup should boot if power comes back (you have to wait a few minutes). You could add a resisor across the caps to reduce this time (proposal from a viewer)
This is pretty cool solution for a problem I've heard about several times. The ext4 filesystem gets corrupted when you force power off. Wouldn't migrating to a btrfs root filesystem be way easier than all this though? It's never in an inconsistent state.
I am not a Linux guy. So, I had to go the "hardware" route...
its not ext4, it is the SD card itself. If you use an SSD instead of an SD the problem is almost gone.
Hmm, as a side bonus, this would create a power reserve if you are using a lower rated charger when the draw on the new raspberries spikes for a couple of seconds.
Good idea!
though i fully understood the workings with yr battery pack in the previous video, here i come upon something confusing. why is the monitor connected to the 3v3 as well? shouldn't it be connected just to the 5 volt via the 2 diodes, to ground and to gpio 17? or did i misunderstanding your circuit?
I do not use batteries here, I use super caps which are charged to 5 volts. I connect the wire to 3.3 volts which is connected to GPIO18 pin (through a FET). I read, that the Pi GPIOs are not 5 volt tolerant.
yes, that I fully understood, but my confusion was with the figure on 3:53
but I think i understand it by now: The gauge gets 5Volt through 2 diodes and the 3.3Volt goes to the transistor that triggers the shutdown via GPIO18.
I had forgotten it was not open collector but had a pull up to 3V3.
Great stuff, I have 2* 6 Volt supercaps that I will put in parallel, which brings me to 5F. Will give that a try.
You are right. Maybe you look at the former video. I think, a diagram with the transistor is there.
Yes, I had seen it. I look at ALL yout videos Andreas, wouldnt want to miss a single one ;-)
:-)
nice,
kannst du auch sagen welches wlan-modul und tastatur-maus-kit du nutzt ?
mein pi rollt gerade an ;-) da brauch ich dann nicht lange zu suchen bzw experimentieren.
danke.
danke!
Great videos. Would you make a video going into more details of using 75XXX?
You mean voltage regulators?
Maxwell supercaps can retain charge for more than a day. Only dropped a volt in 24hrs I think.
:-)
do caps in serial balance during charging? (unlike batteries in series)
No, they do not. But I did not find a lot of stuff concerning this topic. Because they are in series, both should get exactly the same amount of current at least. One source suggested, that for small caps and well below the maximum voltage should work ok. So, I did it. And, if the caps are destroyed after a while, it is not so expensive... (I mentioned it in the video, that I have no long tern experience)
Sorry. I wrote it while I was watching and you mentioned right after posted.
the supercapacitors supply power to back in my usb pin where i connect other component so what to do to stop the power in reverse direction form super capacitors ( i used diodes all type but because of 5V and 3A there so voltage drop between 0.6V to 1.2V and raspberry pi 4 want minimum 4.63V and 3A power supply what to do now?
If you use Schottky diodes your drop is less.
Is this still possible to do with a Raspberry Pi 5? They are so power hungry,,,,
Maybe. But you probably need bigger capacitors.
Thanks, but after the pi has shutdown, it begins to reboot again. Any idea of the cause or fix fir this? Pi 3b+
Strange. Usually it only reboots if it is power-cycled
@@AndreasSpiess how is reboot triggered when power cycling? Does the pi detect a rising voltage?
It just boots when plugged-in
@@AndreasSpiess solved by using halt instead of shutdown now. Thanks for the video, very useful.
Hi Andreas, Thank you very much for this interresting video. I am currently building a Phoniebox for my 4 year old and the the "Göttibueb" of my wife and it would be neccesary to have something that is shutting down the Rasp when the cable is pulled. Kids can be very cruel with Raspis ;) I have bought a Geekworm Raspberry UPS Hat but this device has some major disadvantages (like a power button to switch it on after power failure) which makes it unuseable for my project. If you want I can also send you one of these to for analysis, hacking or improvement :) But my question would be if you can guide my to have small UPS with supercaps only without the fan control? What would be the smallest config to get this working? Cheers, Thomas
I do not know of a UPS with super caps. But with this video (and maybe the one I did for the protection of super caps) it should be possible to build one yourself.
link to your site points to the https version, which is configured wrongly (certificate for an other host) and then brings to a 403 forbidden page... going in http is fine
Thanks! I corrected it.
I'm trying to find a shop which sells the KA7... chip but I am unable to find it on BG or AE.
neither the alternatives TCA... or MAX....
The link you did put in the remarks does not work for me.
Any solution?
This is the only source for the 4.5 volt type I found on Aliexpress. 3.3 volt are available in TO-92
How do you know if the power is off
After waiting or if the LED stops blinking.
and which size of super capacitors i have to use for raspberry pi 4 model?
I did not do the calculations. Maybe even the same because it shuts down faster.
you should use a simple balancing circuit for the caps (just put an appropriate zener diode in parallel, one for each cap), because of their differing internal resistances they will act like a voltage divider, and one of them could get too much voltage
Do you have experience with that? Because, I am not sure, if Zeners alone are good enough, because they also have their tolerances. Usual balancers are more complicated. But they are also made for much bigger caps.
a zener would basically discharge the capacitor when the voltage drop over it gets too high(creates a lot of pixies when you just put a big overvolted supercap on it). you would have to experiment with values. but before you go through all the trouble, let the system run for a while and then measure the voltages of the caps. yes zeners arent perfect, and sadly not available in arbitrary values, but there are some available with 2.7V
I asked, because I did also some experiments :-) And it is not easy to get these low values, at least not for me. I have all of them, starting at 3 volt and up
you could try to put 4 normal diodes in series to get a similar voltagedrop :P
or just buy a few here www.ebay.de/itm/Zener-Diode-VISHAY-500mW-10-25-50-100-Stuck-Spannung-2-4V-75V-Dioden-/192070809110 they are pretty cheap i guess. 100 of then for 6 bucks
Thanks for the great post could you provide a diagram using the supervisory circuit (KA75450) and the other resistors you talk about below? I want to test this on my PI. Also is there a way to have the capacitors discharge faster? Thanks - John
I did not continue this project. So I have no additional diagram.
Are these Farad numbers on the capacitors real or we can't trust them (like some Chinese batteries) ? Maybe there is a capacitor contest in a later episode
I never tested them :-(
Another great video, thank for sharing Andreas.
You are welcome!
You can make it without the voltage detection harware as well if you want it some cheaper. since most likely you will use ethernet for your server/24/7 running pi. that means that you can use the network connection to test for a power outage, no network mean no power, or at least no reason to be on anymore, you can edit the bootfile to wake on lan to automatically turn the pi back on, this is especially helpful for when you use wifi or such, since wifi sometimes has random periods of time where it stops working. you can either use a small ram only os pre-boot to make it work on wifi, even without the dedicated hardware, or setting up the router properly. another more easy step would be to save all files, and mount the drive as read only until the network reapears, this way you do not need to restart if it is only a network outage, by unmounting the sd or mounting it in readonly you won't corrupt it, many raspberry pi oses also have this functionality building, however you need to customize it since in general they boot the os in ram from start when this setting is enabled.
This device was mainly meant to avoid an fast shutdown which can corrupt your SD card. Your measures are good and can be added in addition. I think.
Are you sure the Raspberry Pi supports WOL?
@@AndreasSpiess this is also solely meant to avoid corruption.
The raspberry pi does not officially support WOL however it can be inplemented both softwate based and hardware based without to much weirdness. Hardware based it can be done easly by splitting the ethernet cable and connecting it to a small ic like a arduino, then when a network signal is detected it enables a transistor or io pin to trigger the raspberry power on pin, this method is really simple but has the cost of a small ic qnd optionally(for more accuracy such as requiring a speciffic package to start) a ethernet shield/chip connected. Note that a arduino in this case could be used without ethernet shield since the arduino uno is fast enough to work as a ethernet driver, so it can be quite cheap still. The other method however does not have hardware cost asociated to it since it is actually build in to the raspberry pi by default but rarely used for reasons such as wol. But the raspberry pi boots up whenever lower os connected, this can be used directly, however since the power might still be unstable wol might be desired, when you install a os on the raspberry pi it also installs a bootloader, that bootloader can be changed/modded if required to at first connect in read only to protect the msd/sd/usb might the power stop again. You can do the following directly in the bootloader, but also in a small micro os which you boot in ram mode and read only this only has the functionntonwait for a message and then when it gets the message it powers up the normal os/switches to it. The first steps are most easly done as a micro os, the last one is most easly done if you go for modding the boot loader. Many linux bootloaders allow you to easly mod them directly from the in linux terminal.
Another great video Andreas! Two questions: (1) for how long RPi Zero can work after power off on battery and how does it compare to super caps? I guess it can work longer on the batteries (2) after the shutdown when the power comes back does RPi start automatically? Thanks!
1. The Zero works only a few seconds after power off. Just enough for a safe shutdown
2. It does not boot when power comes back. Only if you wait for a certain time. Then, the caps are discharged completely and the RPi should boot again
Andreas Spiess can you please draw a more precise schematic for a guy like me? On your final schematic is only "monitor" not the transistor, also on your live picture is two blue resistor. I just dont want to blow up things.
Ahh, but I also cant find any sources for ka75450. :(
www.aliexpress.com/item/100-New-original-KA75450MTF-KA75450/1990473688.htm (ordered, but not received yet)
I will put it in my blog
Any chance you (or anyone) make some for sale? I understand the concept but have no skill/knowledge to build one myself :(
We should get a result of the "superpower" project. But with batteries.
If your data are so important to go to all this trouble I would choose to use a VPS from scaleway. It costs 3 euro per month but it is faster than the pi and downtime is very rare so it is very suitable for applications where sensor signals are important like fire alarms etc.
Then you need to have a good internet connection, that is not down for long times.
There are other ways which you don't need to bother with a VPS at all, like MQTT service and storage in the cloud.
You have a local machine because you want to control and log things locally, on the same site as the things you control. Because as long as you have a working local LAN, you want to be able to control your devices.
Yes, it totally depends on your needs and application. In my case I found it more productive to outsource the server/data center part to a 3rd party and focus on making my devices resilient to network and power outages as you describe. For my applications it makes more sense since my LAN is powered by my router which means that if the LAN is down then in all probability the internet is down also so a local server would not work either.
I don't see paying for an ongoing fee, introducing cost and connectivity potential issues, when you can do this reliably on a Pi. Despite one hiccup I've documented on the blog, almost definitely through not understanding power supply issues well enough at the time, I've recorded years' worth of data on a Pi without issue and now that we have Grafana, doing a decent job of displaying the data as well. Indeed the only service I've had trouble with - is online speech - with the company (presumably) selling off to Amazon.
Hello Peter, first I'd like to say that I am a fan of your blog and the work you did with the raspi setup script.
Now, regarding the issues you brought up, as I said above there is no wrong/right way to do this, and yes ongoing fees is an issue you have to consider when setting this up (connectivity not so much, there are things you can do to easily mitigate any issues).
The raspberry pi route requires upfront investment for hardware and time, the hosted solution requires a lot less upfront investment but you do need to pay 3 euros every month. It all depends on your needs.
In my case I opted for the hosting solution because I need internet connectivity anyway and I much prefer working with something other that raspbian on a faster machine.
Well of course - you have me there - there is the cost of the Pi - I usually refer to Pi in the generic sense of course- you can buy a decent ARM board for far, far less than a real Raspberry Pi - your point is valid - except for the reliance on external connections and that depends partly of course on where you spend your time. I would not trust important data collection here in rural Spain to reliance on the broadband and until recently I would certainly not have trusted it to at Plusnet connection, though thanks to the new router that particular issue now seems to be history.
Interesting but not necessary. Just enable Overlay File System to make the boot sector read-only. That way an abrupt shutdown will not corrupt the SD card or USB drive.
I agree, but I don't know if it protects your data (unless you store it in a different place).
I would suggest the way to fix this sort of problem isn't to try to stop a power failure but instead make the setup resistant to such failures i.e. making the OS read only so it can't get corrupted or in a bad state from power failure during a write.
I am not a Linux expert. But it seems not to be about the OS only. When I shutdown, also the running applications do some "shutdown" (probably saving some data). I assume, because of the limited # of write cycles on SD card it is not appropriate to write each bit immediately to the "disk"...
Disk IO is slow so Linux (Windows etc too) usually don't do write immediately but you can configure that stuff on Linux so that writes happen sooner with the loss of some performance etc. There are options you can use for ext4 file systems that make them a lot more tolerant of the power getting pulled too.
I know of an expensive commercial product that uses a super cap setup with tweaked settings for the kernel/filesystem and it does work most of the time to save the from thing getting bricked but it's not perfect.
A fixed OS image built with buildroot, yocto or similar + rw data that can be recovered over the network if it gets corrupted is the way to go IMHO.
Wear levelling for SD/ eMMC is done in the controller on the card/chip itself which is why you can use regular filesystems like ext4 and not the special flash filesystems like ubifs, jffs etc.
2caps in series divides the capacity in half
You are right.
ouch i deleted my comment by mistake!! I said basically i use cheap power banks (usd $ 2.5 dollars) and it provides about 40 minutes of power depending on load. (it includes battery + circuit board + case). Of course it also provides power while charging so it's like a mini UPS. I've been serviced by this during years.
+rodstartube That is a good concept. However, not all power banks can be charged when used (either-or). Do you have a link to your device?
search: "381674926080" on eBay. They claim 2600mAh or more, but that's bullsh*t, I tested them, usually store about 730mAh, but that's enough for a nice backup or mini UPS, and being honest, that's fair for what you pay. Just replace included crap battery for a decent one, if you want more capacity (or parallel with others). It would be nice a review of this at your style. Regards!
PD: item title is "Portable 2600mAh USB External Power Bank 18650 Battery Charger For Cell Phone" so you can choose at your convenience, be carefull many just sell the box/case "battery not included". {Of course I use soldered wires to the board, not the bulky USB connector}
i use ebay.com
Unfortunaately, I do not get any hits. Can you send me the full link? Maybe then, I can look at it, at least...
I need to build this ASAP.
:-)
Thanks for sharing.
You are welcome!
its just fade away after few min , over charge more than 2.7 its start self discharge , thats why its rated for 2.7
And maybe the cap is destroyed if you go over 2.7V
Thanks for the video. This is food for thought for my problem; my mppt controller charges a battery and RPI zero during the day, at night the RPi discharges the battery until the battery's low voltage circuitry disconnects the battery from anymore drainage. The next day the battery remains in this disconnected state eventhough the charge controller is receiving energy from the solar panel. I have to manually disconnect & reconnect the battery to get things working again. So I need to design some circuit to do this for me...
This is a problem of many LiPo chargers. The UPS I used in my previous video has the same problem. You just should not discharge the battery completely. But the device has no protection
Yes, it seems so but how do I prevent it from discharging completely?
Not easy. Maybe add a protection circuit? Some of the LiPos contain already such devices, some not.
Thanks Andreas!
You are welcome!
Great video thanks!
You are welcome!
How about putting a Shotkky diode in parallel with a current limiting resistor, in series with the supercaps, with the diode pointing towards the +ve rail. In that way the diode will block charging current and so the charging current will flow through the resistor. You can then limit the charging current by choosing an appropriate resistor. Once the is lost, the diode will be forward biassed, and has a very low forward voltage, so your Pi will be powered from the supercaps largely unimpeded.
You are right. This is a good thing to solve a problem. But I did not experience any problems, because my cheap USB cable has already a resistance, my USB charger has a over-current protection, and the high current lasts only a few seconds. So, there was no need for more parts. But all of this changes, of course, if you use bigger caps.
use Google: soft start capacitor charging
Thanks!
thank you for your idea :)
:-)
Where can you get non-smd version of the ka75450? I cannot find anything on Aliexp. or Banggood. Is there an alternative? Thanks in Advance.
+Björn Nawrath I think, you get it at digikey or other distributors
Herzlichen Dank! Mir ist die Seite bisher nur durch Datenblätter aufgefallen; kannte ich neben Aliexpress und Banggood, die ich erst durch deinen YT-Channels kennenlernen durfte, noch gar nicht. Tolle Arbeit, besonders auch die Kniffe und Wissenstransfers zwischen deinen eigentlichen Kernthemen der einzelnen Videos!
Sie sind normalerweise etwas teurer und verrechnen Porto unter einem gewissen Betrag. Dafür bist du sicher, dass du echte Ware kriegst... Vielen Dank for dein Kompliment!
Grande, molto utile🇮🇹🇮🇹🇮🇹
Grazie!
@@AndreasSpiess Strong man👍🏻👍🏻
Love your channel Andreas! Sorry that this isn't relevant but I am struggling to find an answer and it would be much appreciated if anyone could help!
I have built a neutron detector (university project) with a Raspberry Pi 2B and have programmed it in Python 2.7. I am detecting neutrons via an electrical signal sent to one of the USB ports by a soundcard and I am reading the signal using PyAudio. It works fine apart from the fact that it can only detect up to 40 counts per second as this is the highest amount of reading PyAudio seems to give me! Is there any way I can get PyAudio to give me more than 40 readings per second?
This is the PyAudio code I am using:
stream = pyaud.open( # Open input stream, 16-bit mono at 44100 Hz
format = pyaudio.paInt16,
channels = 1,
rate = 44100,
input_device_index = -2, # Input device likes to be -2 ;)
input = True,
frames_per_buffer=8192
)
# This function reads the data from the sound card:
def RecordCounts():
global CV
rawsamps = stream.read(1024)
samps = numpy.fromstring(rawsamps, dtype=numpy.int16)
CV = analyse.loudness(samps)
Thanks in advance!
I have no idea. I never worked with any of these things. But maybe it would be a possibility to use a microphone, a small amplifier (OpAmp), a diode, and a capacitor to create a digital signal (one per neutron) out of the audio signal outside the RPI. Then, the RPi just has to count logical signals. And this is for sure faster... Or maybe you even do not need a microphone if you connect the output of the sound card directly into your amplifier.
I never thought of converting to digital first so I will try that, cheers Andreas!
:-)
MaD bEN I will always believe in Andreas! In the end it worked?
You are awesome
Thanks!
Maybe someone can design a small PCB for this? With in-out usb connectors.
Adrian for a normal RasPi look here hackaday.com/2014/10/04/supercapacitors-for-the-raspberry-pi/
or also at tindie.com
I think, this is a very similar concept. The two resistors across the caps is a good idea, because then, they discharge faster and the RPi boots automatically...
A PCB for my setup would be an "overkill because I soldered it together in about 5 minutes (two resistors and a transistor).
Thanks, ✌🏼🇧🇷
My pleasure!
HUHHHH i did not see how you program it shutdown creating a signal is the easy part its software that is the problem since i do not know how linux work
lets see if #131 has the anwser
Edit1: it was in the 131 lul
:-)
My rpi3 takes 2 min to Shutdown
That is a long time...
This is what I need
:-)
yeahh fantastic !!
Thank you!
Hello sir good Video I have a question about esp32 i want to make an auto switch between battery an dc power i have used this x804
ruclips.net/video/XA8qaMbrQ6Y/видео.html but like it said in the video it have 700 ms beteween the 2 state and the esp32 reboot how can i do for the esp32 do not rebbot
I would buy a battery-powered ESP32 board. If you run them from USB, they charge the battery and run a long time without any power
good idea :)
:-)
I want bigger
similar idea here: www.hackerspace-ffm.de/wiki/index.php?title=Raspi_EDLC_UPS
You are right. Thanks for the link! They use bigger caps and therefore use some protection resistors. And they have no voltage reference, which, I think, is not ideal. But with the bigger capacitors, they can maybe start the shutdown later and so, do not need an exact voltage level. The parallel resistors, however, are a good idea. With these, the RPI will re-boot after the power came back (they discharge the caps in minutes)
FIRST!!!!
My hero!
OMG you should join the Avengers.
you know what is so funny? I was actually contemplating doing that.
Damn it
hah hah. This is my third I think