Hello, i still have error while read data serial arduino to raspberry pi. This the error
humidity: 61.000000 , temp: 25.800000 , ph: 7.670000 , flow: 0
Raw: 61.00 25.80 7.67 0
humidity: 61.000000 , temp: 25.800000 , ph: 7.670000 , flow: 0
Raw: 61.00 25.80 7.67 0
humidity: 61.000000 , temp: 25.800000 , ph: 7.670000 , flow: 0
Raw: 61.00 25.80 7.67 0
humidity: 61.000000 , temp: 25.800000 , ph: 7.670000 , flow: 0
Raw: 61.00 25.80 7.67 0
humidity: 61.000000 , temp: 25.800000 , ph: 7.670000 , flow: 0
Raw: 61.00 25.80 7.67 0
humidity: 61.000000 , temp: 25.800000 , ph: 7.670000 , flow: 0
Raw: 61.00 0 25.60 7.81 0
No Input Data
this my code
import serial
import time
from ubidots import ApiClient
serPort = serial.Serial('/dev/ttyACM0', 9600)
time.sleep(0.2)
serPort.flush()
serPort.readline()
try:
print "Connect to Ubidots"
api = ApiClient("43936d6645f2b8455336df48b448edc945fa3c07")
except:
print "Error Connecting"
humidity = api.get_variable('575ecb1d7625426ce1af47fb')
temperature = api.get_variable('575ecb1f7625426c8bd7476e')
ph = api.get_variable('575ecb207625426c8bd74774')
flow = api.get_variable('575ecb217625426c8bd7477a')
try:
while True :
sensorRead = serPort.read()
if sensorRead == '$':
sensorRead = serPort.readline()
print "Raw: "+sensorRead
sensorVar = sensorRead.split()
if len(sensorVar) >= 4 :
humidityvar = float(sensorVar[0])
tempvar = float(sensorVar[1])
phvar = float(sensorVar[2])
flowvar = int(sensorVar[3])
sensor = 'humidity: %f , temp: %f , ph: %f , flow: %d' % (humidityvar, tempvar, phvar, flowvar)
print sensor
humidity.save_value({'value':humidityvar})
temperature.save_value({'value':tempvar})
ph.save_value({'value':phvar})
flow.save_value({'value':flowvar})
except KeyboardInterrupt:
serPort.close()
except ValueError:
print "No Input Data"
any solution? thanks