Helpdesk

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!
Script:
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!!!!')
sys.exit(0)
# init
signal.signal(signal.SIGINT, signal_handler)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ser = serial.Serial('/dev/serial0', 38400, timeout=1)
ser.flush()
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))
time.sleep(0.300)
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!

Jamos

10.02.20 12:11

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)

Nils

10.02.20 17:34

Hi.
Ich habe vor mir ein Script zu schreiben, welches mir unter anderem die Akkuladung in % und den Ladestatus anzeigt. Kann ich diese beiden Daten auch mit dem Script abfragen? Ich finde zwar sowohl einen Akku- als auch einen Ladestatus, aber ich werde da nicht schlau draus. ;-)
Viele Grüße
Bernd

Bernd Schneider

01.08.20 16:41

Hat sich erledigt. ;-) Trotzdem danke.

Bernd Schneider

01.08.20 21:44