Hello, i try run my raspberry pi send data to ubidots for several hours. While running, my raspberry suddenly stop send data to ubidots without getting any error, also the internet connection just fine. Here my codes
import serial
import time
from ubidots import ApiClient
serPort = serial.Serial('/dev/ttyACM0', 9600)
time.sleep(0.2)
serPort.readline()
try:
print "Connect to Ubidots"
api = ApiClient("43936d6645f2b8455336df48b448edc945fa3c07")
except:
print "Error Connecting"
light = api.get_variable('575ecb1c7625426cfe20a381')
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()
sensorVar = sensorRead.split()
lightvar = int(sensorVar[0])
humidityvar = float(sensorVar[1])
tempvar = float(sensorVar[2])
phvar = float(sensorVar[3])
flowvar = int(sensorVar[4])
sensor = 'light: %d , humidity: %f , temp: %f , ph: %f , flow: %d' % (lightvar, humidityvar, tempvar, phvar, flowvar)
print sensor
light.save_value({'value':lightvar})
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:
pass