Help required. I broke Daniels Raspberry Pi SDM630 system

tccack

New member
Joined
Dec 17, 2018
Messages
26
I have been using Daniels ISO for the Raspberry Pi. Took a little debugging which may have been due to the massive number of updates that occurred to the OS once it was first started (I never tried running it without updating it)

I had it running quite well but noticed a couple of glitches but not being very experienced with Linux systems I've exhausted my ability to try to solve the problem.

Firstly I notice that it wont run forever. Its started automatically via systemctl (actually through webmin) and it comes back on line after a reboot perfectly. But I can check it at night and its outputting happily then in the morning its dead and wont respond to manually restarting.

This morning though it got terminal...
It stopped running which wasnt unexpected but when I tried to restart (via reboot and manually running mat.py) I get this error...

I've been able to decipher some previous errors but this one I cant. I just dont understand the OS enough.

Readout started
###################################
Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
File "mat.py", line 200, in <module>
l.start(READ_INTERVAL)
File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 173, in start
self()
File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 218, in __call__
d = defer.maybeDeferred(self.f, *self.a, **self.kw)
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 139, in maybeDeferred
result = f(*args, **kw)
File "mat.py", line 121, in doWork
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big, wordorder=Endian.Big)
exceptions.AttributeError: 'ModbusIOException' object has no attribute 'registers'
^Cstopped by Ctrl-C

I am hoping there are some red-hot Linux / Python people out there who can help as this ISO is just what I need for my monitoring needs (if I can keep it running overnight...)

Thanks
 
The old python script is very sensitive to the hw and data comming in. Just minor data miss and it dies. No recovery built in :)

Should most likely sort that some day but on other hand I dont use that anymore. I use the ESP8266
 
daromer said:
The old python script is very sensitive to the hw and data comming in. Just minor data miss and it dies. No recovery built in :)

Should most likely sort that some day but on other hand I dont use that anymore. I use the ESP8266

I have installed the two meters now and am working on a py file to poll them.
What is the difference when using the ESP8266? Does the code change given the data is no longer coming through the USB dongle?
I like the node-red dashboard system but its not as graphically nice as grafana, but I havent started to learn this yet so I have to stick with node-red for now.

I have the Pi with your ISO on an ethernet cable now attached to a DD_WRT based router which acts as a wifi connected bridge (distance to shed from house was issue but seems resolved with a high gain antenna etc)

I may also try to find an interface which will connect to the SDM630 meters which provides its own GUI for selecting the registers and sending the data out on serial or wifi.
 
The esp is a mcu and not a rasp. Not sure what you sk for.

Node red is a work flow system and grafana visualisation. One does not replace the other.

Use esp instead and send the data on mqtt
 
daromer said:
The esp is a mcu and not a rasp. Not sure what you sk for.

Node red is a work flow system and grafana visualisation. One does not replace the other.

Use esp instead and send the data on mqtt

My question is more about the code. The code out of the box works well with the USB.
Does the existing code in mat.py work with the ESP also or is there another service that is run on the Raspberry Pi?

It seems like you are suggesting that the mat.py file is no longer used and the raspberry pi is using the ESP as the data source point (in the same way that mat.py uses USB0 as the data point)
 
mat.py is a python script and it need a python intepreter. In this case this code is written to work on Linux only and therefore you cannot run it anywhere else.
ESP is a micro computer and does not run any intepreter as such.

I dont use that code any longer and will not maintain it. I have switched over and using ESP modules for all nodes i can and built code for that. I have the ESP to collect and send out the data via MQTT. Then i have Node red to parse the data and store some parts in InfluxDB and others goes to a work-flow that do "things" with the data like turning things on and off.

the mat.py kind of did the same thing in the beginning.

Hope that answers your question
 
daromer said:
Hope that answers your question

Hi Daniel... Thanks for the explanation.
I ended up modifying the python script so that it would poll more registers off the meter. The output seems stable and reliable as far as the node-red displays are running as expected.
I would like to re-introduce sending the data to a local emoncms as you had laid out in the original mat.py.

I have the local instance running with an API key but am struggling to find a good resource to assist with how to format the emoncms input string.
I have done a practice on emoncms.org website with one input which I pulled from node-red. This worked for the single input/output (current on phase 1).
In the mat.py file there seems to be a process which consolidates the data so that it can be sent to the local emoncms.

I would like to create a single input to emoncms which has the titles and values of the data so that I can select from them in order to create the dashboard nicely. Is there a way of doing this or is it a matter of creating a dedicated flow in node-red that outputs to emoncms and then create multiple inputs to have them all available to emoncms for feeds and dash?

Hopefully this is clear enough :huh:
 
After quite a reasonable time I managed to get some good data happening and a nice grafana dash setup.
Once all this was done, I have found that the python on Pi is very unreliable. Even with a cron job to restart the meter service I still get unrecoverable crashing once every couple of days. This requires total power off of the pi and restart, then usually another restart of meter service.
Grafana side is good, but if the python does get everything just right the node-red is not getting anything.

Is there a way to perhaps give the python script more tolerance to failures?

I've gotten the ESP8266 and TTL chip and have ordered a 5v rail power supply. I think I'll have to migrate over to this as you have done.

Can you tell me how to get your code up onto the ESP8266?
I have installed the Arduino IDE and the ESP board manager to be able to select the correct board type.

The ESP8266 shows a wifi point of 192.168.4.1 which can be connected to but how to add the code?
 
Back
Top