[SOLVED] Get error after sending some data to ubidots

Hello, i got some errors after sending data from my raspberry pi to ubidots server
my program have worked for a few minutes, and sending data to ubidots withouht getting any problems.
but suddenly i got this errors.
here the errors

 Traceback (most recent call last):
 File "test.py", line 61, in <module>
 humidityval.save_value({'value':humidity})
 File "/usr/local/lib/python2.7/dist-packages/ubidots/apiclient.py", line 148, in wrapped_f
 return fn(self, *args, **kwargs)
 File "/usr/local/lib/python2.7/dist-packages/ubidots/apiclient.py", line 307, in save_value
 return self.bridge.post('variables/' + self.id + '/values', data).json()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 808, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/simplejson/__init__.py", line 516, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
File "/usr/local/lib/python2.7/dist-packages/simplejson/scanner.py", line 127, in scan_once
return _scan_once(string, idx)
File "/usr/local/lib/python2.7/dist-packages/simplejson/scanner.py", line 118, in _scan_once
raise JSONDecodeError(errmsg, string, idx)
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

here my program code

import serial
import time
from ubidots import ApiClient
import random

serPort = serial.Serial('/dev/ttyACM0', 9600)
dS = None

def getVarbyNames(varName,dS):
   for var in dS.get_variables():
        if var.name == varName:
            return var
return None

try:
   api = ApiClient("43936d6645f2b8455336df48b448edc945fa3c07")

for curDs in api.get_datasources():
 if curDs.name == "HidroponikTA":
           ds = curDs
           break
if dS is None:
 dS = api.create_datasource({"name":"HidroponikTA"})

lightval = getVarbyNames("Light",dS)
if lightval is None:
 lightval = dS.create_variable({"name":"Light","unit":"lux"})

humidityval = getVarbyNames("Humidity", dS)
if humidityval is None:
 humidityval = dS.create_variable({"name":"Humidity","unit":"%"})

tempval = getVarbyNames("Temperature", dS)
if tempval is None:
 tempval = dS.create_variable({"name":"Temperature","unit":"C"}) 

phval = getVarbyNames("PH", dS)
if phval is None:
 phval = dS.create_variable({"name":"PH","unit":" "})

flowval = getVarbyNames("Flow", dS)
if flowval is None:
 flowval = dS.create_variable({"name":"Flow","unit":"L/h"})

except:
print("cant connect")

while True :
sensorRead = serPort.readline() 
sensorVar = sensorRead.split(" ")
light =  int(sensorVar[0])
humidity = float(sensorVar[1])
temp = float(sensorVar[2])
ph = float(sensorVar[3])
flow = float(sensorVar[4])
var = 'light: %d , humidity: %f , temp: %f , ph: %f , flow: %f'  % (light, humidity, temp, ph, flow)

print var

lightval.save_value({'value':light})
humidityval.save_value({'value':humidity})
tempval.save_value({'value':temp})
phval.save_value({'value':ph})
flowval.save_value({'value':flow})

here the serial monitor data print

light: 3 , humidity: 51.900000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000
light: 3 , humidity: 52.000000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000
light: 3 , humidity: 52.100000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000
light: 24 , humidity: 52.100000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000
light: 3 , humidity: 52.100000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000
light: 3 , humidity: 52.000000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000
light: 3 , humidity: 51.900000 , temp: 26.100000 , ph: 7.520000 , flow: 0.000000

pls help me, thanks

It seems that you didn’t receive a response from the server. I recommend you to wrap your save_value() calls in a try…except block.

try:
    lightval.save_value({'value':light})
    humidityval.save_value({'value':humidity})
    tempval.save_value({'value':temp})
    phval.save_value({'value':ph})
    flowval.save_value({'value':flow})
except ValueError:
    print "No JSON received"