Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Just had a power cut now EmonPi won't start

I just got home to find that we have had a powercut.

I tried to log in to my emonpi and its not responding.

Went out to the fuse board where to lives and its says ‘Booting Please wait’

What can I do next? I am happy to get my hands dirty but I am not sure what I need to do to get it working again, In addition why has a powercut caused it to fail, its only about 2 months old.

Um, worrying no replies or pointers, I have done a bit more searching and I can’t find out how to sort this problem out, can anyone help with where I should try next, are there any other forums or groups where I can look?

At the moment I have a useless power monitor, I was hoping emonpi would be better than the Intuition Owl system I had before, despite its limitations that ran for several years without any issues, my EmonPi has become unusable after a few weeks.

I’m sorry no-one else has picked this up. I was away all day doing something other than OEM.

This comes from the “emon” part of the emonPi, which is a separate processor from the RPi, so what it really means, when that message isn’t replaced, is the Pi itself hasn’t started properly.

I’m not a Pi expert, but my first suspicion is that the SD card had got corrupted, either because it was being written when the power failed, or because there was a spike (possibly the cause of the mains failure) that’s caused damage. If no-one chips in with a better suggestion, I’d take the SD card out and re-flash it with a clean copy. You’ll need to take the plastic end off to get at the SD card. The SD card itself might also be damaged, rather than just had its data corrupted.

Hello @wytco0 If you have data recorded locally there is a guide that covers restoring data from a corrupted SD card here Import / Backup - Guide | OpenEnergyMonitor. If this looks too complex please get in touch with [email protected] and we should be able to sort this out for you.

I am sure you may have already done this but have you rebooted the unit yet?
Either with a power down or via the reset button.

John

Hi All thanks for the info, I will get a new card fash it and try the Import/Backup Guide.

I am just trying to find what sort of SD Card to get, is there a recommended list as there is a large number available.

Try reading this

and

Whatever you do, DON’T get a card smaller than the pre-packaged image. It is possible to reduce the image from 16 GB to 8 GB (I’ve done it to use an “old” SD card for testing purposes), but it’s infinitely harder than expanding an 8 GB image to 16 GB.

Balena Etcher is the recommended way to flash the card, and if you do get a 32 GB one, expanding the 16 GB image with GParted whilst still in your laptop/card writer to use all of it is very easy and quick.

Thanks Robert, I have just been and bought a 64GB Sandisk ‘High Endurance’ card that’s meant to be good for lots of writes. So about to try and flash it with a new image.

OK well I have made some progress, I got the new cars and downloaded the image and flashed it to the new card, after a bit of filing I now have the image booting and updated.

When I look at the disk in the Admin section it only seems to be about 16GB but I have a 64GB card. After some searching, I see that the partition needs to be expanded and I found some threads about using a tool called GParted which apparently makes this easy, I downloaded Gparted but I have no idea how to make it work it is meant to be a GUI tool I can’t make it work under Windows, does it only work with Linux (which I don’t use). Is there another way of expanding the partition?

You can have GParted on a live CD - it means rebooting to the CD, do what you need with the SD card, remove the CD and start Windows again. It will be slow working from a CD, but hopefully a 1-off exercise.

https://gparted.org/livecd.php

Two obvious warnings: Don’t try to install anything, and make sure you correctly identify the SD card.

Thanks Robert but my PC doesn’t have a CD !

Thanks for the other warning especially the one about Identifying the correct card it brings back memories of getting that wrong on someones PC many years ago !.

EDIT I just had a look on the GParted site and I see it can be setup to boot from a USB drive but my PC only had one USB drive (its a slimline lenovo) and I need the USB drive for the SD Card adapter so I don’t think that would work either.

Can you boot off a USB drive? Or an external HDD?

Hi Robert, I just edited my earlier comment I only have 1 USB socket on my Lenovo Yoga, so I don’t think either USB drive or USB hard drive will work.

I also have a Imac with several USB sockets but I dont think I can make that boot from USB

Isnt there another way of expanding a SD Card?

Yep, I saw the edit. It looks like you’ll need to expand the card in the RPi itself, then.

I’ve never done that because as a Linux user, I keep GParted on my machine (also a Lenovo but with 3 USB ports and I have an external CD drive). I believe we have a script to expand the SD card, and from memory, you should use that rather than the Raspberry OS’s method.
The script is on your SD card when it’s in the Pi, here:
/opt/emoncms/modules/usefulscripts/sdpart/sdpart_imagefile
or rootfs/opt/emoncms/modules/usefulscripts/sdpart in your card reader. (rootfs is the partition.)

My preferred alternative would be a USB Hub :smiley:

:thinking: Do you have GParted on your Mac?

1 Like

well, a mixed day, I tried to expand the partition on my newly flashed card using a windows program, it seemed to work OK but the image would not boot in my Emonpi so I had to reflash so now I am back to where I was last night :wink:

Robert, I don’t know much Linux and I have searched but I can’t see how to run that script you mention ( /opt/emoncms/modules/usefulscripts/sdpart/sdpart_imagefile) is it just a matter of finding the scrip and clicking it?

Not quite just that, but nearly so.

It needs to be executable (and it should be). If it isn’t

chmod u+x /opt/emoncms/modules/usefulscripts/sdpart/sdpart_imagefile

should fix that. Then run it:

bash /opt/emoncms/modules/usefulscripts/sdpart/sdpart_imagefile

If it complains about permissions, you might need sudo:

sudo bash /opt/emoncms/modules/usefulscripts/sdpart/sdpart_imagefile

Thanks, Robert, on the grounds that using SUDO wouldn’t do any harm and after making an ssh connection I went straight for that option and ran the command:

sudo bash /opt/emoncms/modules/usefulscripts/sdpart/sdpart_imagefile

This did some stuff and then said it would reboot after 20 seconds, I didn’t notice a reboot but it did drop the ssh connection so I assume it was rebooting and I know from my searches that this process takes some time so I am leaving it alone until the morning to see if it completes OK but intial feelings are that its working

It worked when I checked first thing today I thought it had failed as EmonPi wasn’t responding, I restarted it and its now showing the expanded partition using the who of the SD Card.

I thought everything was working but I have just noticed that although I can see a value in the Input for ‘vrms’ when i try and look at it or graph it I get a message saying

Request error: Received data not in correct format. Check the logs for more details’

I cant see anything is the logs although I am not sure what logs I am meant to be looking at, I saw lots of lines saying :
2021-06-01 17:32:28.899|ERROR|PHPFina.php|post_bulk_prepare() start_time=0, npoints>0
2021-06-01 17:32:28.899|ERROR|PHPFina.php|post_bulk_prepare() start_time=0, npoints>0
2021-06-01 17:32:28.900|ERROR|PHPFina.php|post_bulk_prepare() start_time=0, npoints>0

Do these help work out what happening as I have no idea how to resolve the issue from those messages?

When I restored my old data from the card that would not boot after the power cut, did something go wrong then? the history for my other inputs seems fine it’s just vrms that doesn’t work.

I’m afraid the detailed inner workings of emonCMS are outside my area of knowledge. Someone more familiar with this will need to help you here.

This error suggests that the meta data that specifies the start time of the feed is corrupt or at least incorrect. Do you know the feed id for this feed? Can you try:

ls -lh /var/opt/emoncms/phpfina/1.meta

replace the number 1 with the feed id of the Vrms feed.

You could either try recopying specifically this meta file from your old SD card or using a meta file from another feed created at the same time in its place (liable to timing issues but it can work).