Small network node without SD corruption issue of raspberry pi?

JimS

Senior Member
I have used the pi for several nodes on my HA and it works great except for the SD corruption issue when power is lost.  I addressed this for some nodes by a DIY power over ethernet from a UPS in my wiring closet.  But I have a location that can't easily be done that way so looking at options. 
 
I could do what I want with a small python script on a linux box and an arduino for sensor inputs (although an audio output would be nice) so am contemplating an arduino connected to the USB connector of a router running ddwrt. 
 
Any other low cost options?  I already have ddwrt router at the needed location. 
 
There are such things as UPS 'hat' boards for the Pi.  Another option would be to power the Pi via PoE from the switch, and use a UPS on that switch.  There are PoE hat boards, along with external Poe-USB arrangements.

You could, potentially, power both the ddwrt router and the pi using PoE and suitable voltage adapters.

Lastly, there's also the possibility of using NUT or apcupsd networking daemons to send UPS instructions via the network.
 
Not really a fan of the battery boards for the pi.  And this is in a detached garage that I don't really want to set up a UPS although I suppose I could.  Was looking for solutions that could gracefully recover from a power outage without the need for a UPS.  The router can, the arduino can, but a PI can't, at least not reliably.  I could link the arduino directly to the ddwrt router via the stock router USB port - would take some setup but it would eliminate the pi. 
 
SD card corruption is a big negative for the pi IMHO.  Otherwise I love them. 
 
I am using a POE powered RPi for a DIY'd ZWave Z-Net like device in the attic. 

Stacked a ZWave board / RTC board inside of an RPI generation #2. Don't use ZWave much these days though.
 
It's been in the attic now for over 5 years with the same SD card and extremes in cold and heat.
 
There is a second POE RPi / SDR radio in the attic that is used to download NOAA maps direct from the weather satellites. This one has been in the attic for about 2 years.
 
Just recently connected a single relay ESP WiFi board with Tasmota with a buck transformer to my alarm panel 12VDC line and it works well.  I am using this to convert the Doorbell built in PIR to a zone on the alarm panel via MQTT running PAHO-MQTT / Python3 on a modded OpenWRT microrouter (NeXX 3020).  Modded with a 32Gb USB stick for more play space.
 
BTW DDWRT folks stopped upgrading a few years back.  OpenWRT is still being upgraded today.
 
pete_c said:
t's been in the attic now for over 5 years...
It doesn't take long before Pete, the man that has probably implemented just about every HA gadget, chimes in.  Bravo.
 
JimS said:
Not really a fan of the battery boards for the pi.  And this is in a detached garage that I don't really want to set up a UPS although I suppose I could.  Was looking for solutions that could gracefully recover from a power outage without the need for a UPS.  The router can, the arduino can, but a PI can't, at least not reliably.  I could link the arduino directly to the ddwrt router via the stock router USB port - would take some setup but it would eliminate the pi. 
 
SD card corruption is a big negative for the pi IMHO.  Otherwise I love them. 
 
Yep, I set one of mine up to use an SSD via USB.  Just uses the SD card to boot and then swaps over.

I hear you on battery setups.  One... more.. thing.. to babysit.

But let me ask, if power is going out, you're already screwed, right?  Without something supporting the power to the Pi it's not going to stay alive long enough to gracefully shut down.
 
Yes better than an RPi and priced right is a modified Android TV box with built in USB 3.0, Bluetooth, Wireless, Gb NIC and Armbian on it.
 
It is even smaller than an RPi and heavily discounted cuz everybody uses these for KODI boxes.
 
Last test here was using an Android 9 core TV box with 3Gb of RAM.  
 
Wiped out Android, installed Ubuntu on it and running HA and Homeseer on it. (64Gb eMMC chip)
 
Only thing with the box is that I cannot run Oracle VB on it so switched over to a micro Intel Based TV box.
 
Rest of them (4) installed Kodi in Ubuntu and it plays back streaming 4K just fine for me.
 
Yes better than an RPi and priced right is a modified Android TV box with built in USB 3.0, Bluetooth, Wireless, Gb NIC and Armbian on it.
 
It is even smaller than an RPi and heavily discounted cuz everybody uses these for KODI boxes.
 
Originally went from the RPi to the Rockchip stuff then over to the mini Android boxes.
 
Last test here was using an Android 8 core TV box with 3Gb of RAM.  
 
Wiped out Android, installed Ubuntu on it and running HA on it.  Only thing with the box is that I cannot run Oracle VB on it so switched over to a micro Intel Based TV box.
 
Rest of them (4) installed Kodi in Ubuntu and it plays back streaming 4K just fine for me.
 
pete_c said:
I am using a POE powered RPi for a DIY'd ZWave Z-Net like device in the attic. 

Stacked a ZWave board / RTC board inside of an RPI generation #2. Don't use ZWave much these days though.
 
It's been in the attic now for over 5 years with the same SD card and extremes in cold and heat.
 
There is a second POE RPi / SDR radio in the attic that is used to download NOAA maps direct from the weather satellites. This one has been in the attic for about 2 years.
 
Just recently connected a single relay ESP WiFi board with Tasmota with a buck transformer to my alarm panel 12VDC line and it works well.  I am using this to convert the Doorbell built in PIR to a zone on the alarm panel via MQTT running PAHO-MQTT / Python3 on a modded OpenWRT microrouter (NeXX 3020).  Modded with a 32Gb USB stick for more play space.
 
BTW DDWRT folks stopped upgrading a few years back.  OpenWRT is still being upgraded today.
Power from the alarm panel is an option I hadn't thought of.  My panel is close by.  My DIY POE is just a 12V wall wart coupled with some power injector/breakout and a 12 to 5V regulator at the pi.  I could use the 12 to 5V regulator off the alarm panel battery.  Most outages are just brief line switching events that are less than a minute so run time isn't really an issue.
 
Guess I should check out the ESP wifi board too.  Have heard of it but don't know much detail. 
 
wkearney99 said:
But let me ask, if power is going out, you're already screwed, right?  Without something supporting the power to the Pi it's not going to stay alive long enough to gracefully shut down.
Not sure exactly what your point is.  If the power goes out for longer than the backup you need something to power it until it can shut down.  You also need something to detect power dropped to do the shutdown.  And you need to have the pi reboot if power comes back on which can be complicated if the power comes back on fairly quickly.  So there are some timing details.
 
But most of my outages are short ones of maybe as long as a minute.  I can only remember one day long outage during a big ice storm in the last 15 years so I haven't bothered to deal with shutdown since just having a short backup takes care of all but the once every 15 years events.
 
Another choice is to use something that can handle power drops and restart when power is restored.  Lots of other devices do that so thinking about other options than the pi.  I am familiar with the pi and going to something else will involve some extra effort though...
 
pete_c said:
Yes better than an RPi and priced right is a modified Android TV box with built in USB 3.0, Bluetooth, Wireless, Gb NIC and Armbian on it.
 
It is even smaller than an RPi and heavily discounted cuz everybody uses these for KODI boxes.
 
Last test here was using an Android 9 core TV box with 3Gb of RAM.  
 
Wiped out Android, installed Ubuntu on it and running HA and Homeseer on it. (64Gb eMMC chip)
 
Only thing with the box is that I cannot run Oracle VB on it so switched over to a micro Intel Based TV box.
 
Rest of them (4) installed Kodi in Ubuntu and it plays back streaming 4K just fine for me.
I quickly looked up the tv box.  Apparently there are various ones?  Any in particular you can suggest?
 
The site I read about replacing the OS put it on an SD card and booted from the SD card rather than replacing Android in the box memory.  That may put me back with SD card issues.  I take it you replaced the OS in the internal memory on yours?
 
I use little mini buck transformers in the alarm panel and the automobiles to power the smartphones for years now.
 

Hard Wire Charger Cord Cable Left Angle Micro USB 1.2 Meters Universal DC 12V to 5V Power Inverter Converter
These are tiny footprint and sell for ~$10 on Amazon.
 
I have two of these in my OmniPro 2 panel and 3 in three automobiles.  
 
In the automobiles I tapped in to the fuse panel and pulled the console out running behind the console to a nice spot (BMW).  
 
The last tinkered Android boxes used an S912 chipset.
 
Here is an el cheapo to tinker with:
 

TV Box, TUREWELL T95 Max Android 9.0 TV Box Chip H6 Quad-core Cortex-A53 4GB RAM 32GB ROM Smart TV Box 3D 6K Ultra HD H.265 2.4GHz WiFi Ethernet HDMI [2019 Newest] for $39.
 
I did not have the Ubuntu TV boxes plugged in to any monitor or keyboard.
 
Most folks buy these boxes and just install Kodi on Android.  I prefer Ubuntu Linux over Android.  
Read this:
 
Armbian getting started
 
Go to the Armbian web site, download an Ubuntu 20.X build and install it on an SD card.  I use 64 or 128 Gb SD cards.  
Once you have the image on the SD card you edit the ini for the TV box chipset you are using.
 
You can even control the LED display using these images if there is an LED display.  I wrote about this here on Cocoontech a couple of years ago.
 
Have a read here on Cocoontech..
  Rockchip-Intel TV Box Homeseer and Home Assistant installation  (March, 2019)
 
Started here with a Rockchip board then went to a TV box.
 
Then went to an Intel based TV box which I am using today.
  Beelink BT3 Pro II Automation Server July, 2019
 
This one came with Windows 10 on it.  I wiped out Windows 10 and installed Ubuntu on it.
 
Thing is with this box I can run Oracle VB on it and run a very lite Windows 7 embedded instance on it.  Note this box only has 4Gb of RAM on it.
 
JimS said:
Not sure exactly what your point is.  If the power goes out for longer than the backup you need something to power it until it can shut down.  You also need something to detect power dropped to do the shutdown.  And you need to have the pi reboot if power comes back on which can be complicated if the power comes back on fairly quickly.  So there are some timing details.
 
But most of my outages are short ones of maybe as long as a minute.  I can only remember one day long outage during a big ice storm in the last 15 years so I haven't bothered to deal with shutdown since just having a short backup takes care of all but the once every 15 years events.
 
Another choice is to use something that can handle power drops and restart when power is restored.  Lots of other devices do that so thinking about other options than the pi.  I am familiar with the pi and going to something else will involve some extra effort though...
 
No negativity intended, rather a need for clarification.
 
My point was it seemed like you had no power backup supporting the pi, and that outages were leading to corruption on the sdcard.  If you have power backup then it would seem like sending network commands to handle shutdown should avoid the shutdown corruption problem. 

What that would lack, however, would be signaling the device to resume operating on the return of /reliable/ power.  To avoid the hassle of a resumption being 'false' and the power going back down again; made worse by being faster than network signaling could handle.  That and it runs into the problem of too many interdependent pieces.  For a PC this would be relatively simple using Wake-On-LAN. (he says, knowing full well that WoL is never a guaranteed scenario either).

So that leads to the question of how to best handle power-on state in that Pi.  I've not looked into it, do any of the PoE switches out there support software control over the power to the port?  That would be one way, in that presumably something capable of interacting with a switch would also be capable of being programmed/scripted such that it could be sensible about power management on the Pi.

I have to think there's a 'wheel reinvention' developing here.  But I've not followed the Pi communities a lot so I'm not savvy on how they're approaching this lately.
 
wkearney99 said:
No negativity intended, rather a need for clarification.
 
My point was it seemed like you had no power backup supporting the pi, and that outages were leading to corruption on the sdcard.  If you have power backup then it would seem like sending network commands to handle shutdown should avoid the shutdown corruption problem. 

What that would lack, however, would be signaling the device to resume operating on the return of /reliable/ power.  To avoid the hassle of a resumption being 'false' and the power going back down again; made worse by being faster than network signaling could handle.  That and it runs into the problem of too many interdependent pieces.  For a PC this would be relatively simple using Wake-On-LAN. (he says, knowing full well that WoL is never a guaranteed scenario either).

So that leads to the question of how to best handle power-on state in that Pi.  I've not looked into it, do any of the PoE switches out there support software control over the power to the port?  That would be one way, in that presumably something capable of interacting with a switch would also be capable of being programmed/scripted such that it could be sensible about power management on the Pi.

I have to think there's a 'wheel reinvention' developing here.  But I've not followed the Pi communities a lot so I'm not savvy on how they're approaching this lately.
No problem.  I was just a bit unclear what you were getting at.  Yes, the whole shutdown thing gets complicated.  Seems like you almost need another programmable device to manage the pi power - there are "hats" that are basically an arduino for power management.  If you tell the board to shut down then you have to wait for it to complete.  You then need to remove power and reapply to get the board to restart.  If the power comes back on right after the shutdown command you still need to wait for shutdown and break power to restart.  Since extended power failures are very, very rare I have just dealt with short ones with a UPS and will have corruption for a long one if I am not around to shut them down manually.  People have done various things to deal with it but none seem elegant. 
 
I just realized I have a small UPS on the shelf gathering dust so I will probably just throw that on it like I did for my other pi boards. 
 
Back
Top