Python script


Hi, I am trying to extract the wide range voltage from the strompi, and send it to another Programm. I have a script set-up to do this, but I need some support to finish it as it only extracts the value 0.
Hope you can support!
import signal, sys, time, socket, datetime, subprocess, math, serial
# Control-C signal handler to suppress exceptions if user presses Control C
# This is totally optional.
def signal_handler(sig, frame):
print(‚You pressed Ctrl+C!!!!‘)
# init
signal.signal(signal.SIGINT, signal_handler)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ser = serial.Serial(‚/dev/serial0‘, 38400, timeout=1)
Value = 0
# forever loop until user presses Control-C
while 1:
serLine = ser.readline()
if ‚ArduinoValue:‘ in serLine:
Value = serLine[13:-1]
#print Value
SignalK = ‚{„updates“: [{„$source“:“OPserial.BAT.V1″,“values“:[{„path“: „electrical.batteries.main.voltage“,“value“:’+str(Value)+‘}]}]}\n‘
#print SignalK
sock.sendto(SignalK, (‚localhost‘, 55559))
Extra information:
The default script for strompi works, all values are printed.
The value I need in the above script is: sp3_ADC_Wide
Strange thing is, when I manually edit the Value = 0 in line 15 to for example, 12, that value is sent to the external Programm. So I know the script works, just need to inject the sp3_ADC_Wide value somehow, but when I put Value = sp3_ADC_Wide, it doesn’t work.
Thanks in advance!

Answered question

3 Answers

Hi Jamos,
I modified the status script for your usecase. You can download it here. You need to insert your script in the modified script. I hope that’s what you were looking for.

Best regards
Nils (Joy-IT)

Answered question
You are viewing 1 out of 3 answers, click here to view all answers.
Write your answer.