emonPi hangs and stops logging

Hi there, My emonPi stops running regularly; sometimes it is hours, sometimes it is weeks, but sooner or later it stops logging and needs to be turned off and on again to get it to work. I know I have seen this as an issue for other users and was wondering if there was a solution to it?

Here is my data from the past week:

Hi John, what version of EmonCMS are you running?

I ran the update only a few days ago… so the most up to date version.
This has been an issue ever since I have had the emonPi - so 2 years or more.

I know I have seen this talked about here before, a fix was posted where the software periodically checked to see if the feeds were still alive and rebooted if not.

I think the issue is related to the three temperature sensors as there was a while where I did not have them connected and I don’t think I had the problem then.

How are the temperature sensors connected?

Is there anything in the logs?

Does the EmonPi hang completely or can you still SSH in?

Thank you so much for your response.

How are the temperature sensors connected?

I have three encapsulated DS18B20 connected via a CAT5 cable and a RJ45 to terminal block breakout.

Is there anything in the logs?

I don’t know, I will check when I get home.
Which logs should I be looking at? Where will I find them?

Does the EmonPi hang completely or can you still SSH in?

Again, I am not 100% sure… but I think it is still alive, it has just stopped logging. I will check when I get home.

Next time it stops, rather than rebooting it, you should check the logs and try restarting some specific parts. You can still reboot if all else fails, but armed with what you have learnt we may be able to locate the issue. The fact “it stops” and the fact it “starts again after a reboot” are just to general to be useful.

emonhub.log is the most useful log, but due to the way log rotation is set up on an emonSD, you only have an hour or so before the useful info is rotated out. The most useful part of the log is the period before and just after the data stopped flowing.

Can you also check the emonhub, feedwriter and mqtt services are still running ok with the following 3 commands?

sudo systemctl status emonhub

sudo systemctl status feedwriter

sudo systemctl status mqtt_input

if any one of those is not running, try restarting it using the same command with “status” replaced with “restart”.

Try to avoid restarting them unless absolutely sure they are stopped, we are aiming to find one thing that get the ball rolling again.

If the 3 services are all running ok, try restarting just emonhub with sudo systemctl restart emonhub and if that works, it is possibly one of 2 things, the emonpi board is stopping and restarting emonhub is resetting the board or there are is a “thread is dead” issue in emonhub. The logs you collected earlier will help determine which, or we can install a little utility so that the next time it stops you can reset the emonpi board without restarting emonhub.

Thank you Paul and Brian - I will get back to you with more info when I have it. Jon.

1 Like

I suffer from this “stops logging” problem on several occasions over the last year since I had my emonpi. It is frustrating to say the least, and from reading this community it appears to be a common problem that needs addressing centrally as surely the issue lies in the core code?

Indeed. And the more users that provide detailed info and logs, the better chance there is to discover the cause(s),

Many issues will manifest themselves as “stops logging” as have several previous issues that have been successfully fixed in the past.

If you can provide info and logs we can determine if the issue is the same and work towards a fix, either way. At the moment, even if we fixed Jon’s issue there are no guarantee’s it would fix your issue, or vice versa.

So please help us to help you by providing logs and info for your set up.

Annoyingly I have not had the issue since Feb 23rd, it is behaving perfectly at the moment (I think it must know we are talking about it). It can go months with no problem, but sometimes only hours.

I think my problem is related to the temperature sensors being disturbed / moved / touched, maybe the RJ45 to terminal block breakout has a poor connection somewhere. If it does not “stop logging” on its own soon I’ll go give it a jiggle.

I second that. I have a “shop” DS18B20 with an RJ45 on the end of a flat white cable, and at least one of the IDC connections in the plug was bad. I crimped them up again, and filled the cable entry with hot glue to act as a strain relief.

Can a bad connection to a temp sensor really cause an emonPi to “stop logging” ? I thought the FW was written to simply use a “30x” if no value was read from a temp sensor.

It should do, unless there’s an exception handler that isn’t working as it should; but a wiring fault still needs to be rectified.

Did you mean “shouldn’t do” ?

I don’t disagree that the temp sensor issue needs resolving, but I wanted to avoid it being a red-herring to this thread about the “emonPi hangs and stops posting”

however, I just took a quick peek at the code and found the emonPi doesn’t follow the “30x” convention.

and this line looks suspicious

what if it isn’t within -55 to 125 degC? Can the function return?

[edit] I know all actively warned faults will result in 85degC which is inside the -55 to 125, but I was wondering what if there is no response? How would that be handled?

That’s what it should do.

Yes. It does return zero, but according to K&R, the return value is undefined. So essentially, you cannot trust it to return anything or anything sensible, and what it does is probably compiler-dependent. It’s certainly bad practice to not define a return value.

[Unless of course it’s defined as void]

My emonPi also stops sporadically. Sampling at 5s and runs maybe a month. Latest emonPi firmware. This time I just rebooted it. It’s not obvious where to be looking.

Hi John,

I am still waiting for mine to stop logging again! That said I have been testing my electrics recently so the power has been going on and off and on and off so it may have done it and i did not notice.

If you look at reply # 6 from pb66 Paul he says what to do when it happens.


this is #6:

See the EmonPi became "inactive" over 12 months ago, EmonCMS is still working fine?! thread as maybe linked.

[This and the following 6 posts were moved here from a separate thread titled “EmonPi became “inactive” over 12 months ago, EmonCMS is still working fine?!” - pb66]

OK, this is very odd - looking at my EmonPi locally at (not something I do often, if ever, but i have been having some issues) and it appears that it has logged nothing whatsoever since 2nd March 2017 and all nodes and feeds have “inactive” since then. Looking at emoncms and no stop occurred at that time and it is still working (mostly) today.
Is it possible there are two versions of the software running on the same Raspberry Pi and I am talking to the wrong one? What on earth is going on?