Hello: I have an error in my code after 10-20 minutes I run my python script. This is the script:
#!/usr/local/bin/python3.5
import RPi.GPIO as GPIO
import serial
import rs485
import time
from ubidots import ApiClient
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(24, GPIO.OUT, initial=GPIO.LOW)
api = ApiClient(token='')
port = serial.Serial(
port='/dev/ttyAMA0',
baudrate = 115200,
rtscts=True,
timeout=0)
rs485 = rs485.SerialWrapper(port)
while True:
time.sleep(240)
if rs485.update():
msg = 0
packet = rs485.getPacket()
msg = bytearray(packet)
if msg[0]==3:
hum = msg[1]
press = msg[2]*100 + msg[3] + msg[4]/10
temp = msg[5] + msg[6]/10
print(temp,press,hum)
api.save_collection([
{'variable': '57556d2876254208bf20b2c3', 'value': hum},
{'variable': '57556d1e76254208bf20b2a6', 'value': temp},
{'variable': '57556d16762542084bf0f9bb', 'value': press}
])
elif msg[0]==2:
tempin = msg[1] + msg[2]/10
tempout = msg[3] + msg[4]/10
print(tempin,tempout)
api.save_collection([
{'variable': '57556c9676254203723fddea', 'value': tempin},
{'variable': '57556ca3762542043aaa720e', 'value': tempout}
])
and this is the error:
Traceback (most recent call last):
File "./rs485_prog.py", line 45, in <module>
{'variable': '57556ca3762542043aaa720e', 'value': tempout}
File "/usr/local/lib/python3.5/site-packages/ubidots/apiclient.py", line 148, in wrapped_f
return fn(self, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/ubidots/apiclient.py", line 491, in save_collection
response = self.bridge.post(path, data)
File "/usr/local/lib/python3.5/site-packages/ubidots/apiclient.py", line 108, in wrapped_f
response = fn(self, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/ubidots/apiclient.py", line 97, in wrapped_f
raise error
ubidots.apiclient.UbidotsError404: Resource responseed not found:
Could you help me to understand why this happens?
Thanks
Francesco