hi, looking simple serial read , return value. cannot seem figure out why return value bad. when run python script, looks great, when call same python script php, repeats data has more readings behind it. help?!
import time
import serial
ser = serial.serial("/dev/ttyusb0", 9600, timeout=1)
try:
read = ser.readline()
ph = read.strip('*er\r\n')
ph = round(float(ph),2)
except valueerror:
pass
print ph
********************************************************************************************************************************
python prompt output '8.125'
********************************************************************************************************************************
when run php, output '8.125 8.124 8.126 8.123' , output shorter repeated or longer.
thank you
import time
import serial
ser = serial.serial("/dev/ttyusb0", 9600, timeout=1)
try:
read = ser.readline()
ph = read.strip('*er\r\n')
ph = round(float(ph),2)
except valueerror:
pass
print ph
********************************************************************************************************************************
python prompt output '8.125'
********************************************************************************************************************************
when run php, output '8.125 8.124 8.126 8.123' , output shorter repeated or longer.
thank you
if python code working , problem arises when calling php check php code first...
possible python script gets called several times?
possible python script gets called several times?
raspberrypi
Comments
Post a Comment