Helpdesk

Hello,

I am unable to run the adc-output command by writing it through serial in python.

when I do something like:
ser = serial.Serial(
port='/dev/serial0',
baudrate = 38400,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)

ser.write(str.encode('Q'))
sleep(1)
ser.write(str.encode('\x0D'))
sleep(1)
ser.write(str.encode('date-rpi'))
sleep(0.1)
ser.write(str.encode('\x0D'))
ser.readlines(9999);

It works correctly and the output is: [b'200824']

But when I do:
ser = serial.Serial(
port='/dev/serial0',
baudrate = 38400,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)

ser.write(str.encode('Q'))
sleep(1)
ser.write(str.encode('\x0D'))
sleep(1)
ser.write(str.encode('adc-output'))
sleep(0.1)
ser.write(str.encode('\x0D'))
data = ser.readlines(9999);

It does not work and only returns an empty byte

Simon

24.08.20 20:29

Hello Simon,

You can do it like in the StromPi3_Status.py script, there the status-rpi command is used to read the values.

You have to read the values line by line like in the script and then you can display the adc values you need.

Best regards

Tim (Joy-it)

Tim

27.08.20 15:36