Python ubidots code review



I have scraped together some of the code which runs on RPi.

I noticed ubidots python library dos not support tags or name so only IDs can be send.

Does anyone knows a better approach?

I struggled some time before adding timeout logic. My code was simply stuck in ubidots library from time to time.

If anyone knows a better solution to replace timeout logic?

Best regards

Github sample code


Fortunately, both Python and Ubidots have made it soo easy to use HTTP requests, that is simpler to just hit Ubidots’ API directly than using a custom library (just 2 lines of code!):

1- Install requests (

sudo pip install requests

2- Use it in the code:

import time
import requests
import math

c = 0

    c = c + 1
    payload = {'variable1': round(20*math.cos(c),2), 'variable2': round(20*math.sin(c),2)}
    r ='', data=payload)

These are the results of this code:

Please note that “motor” is the API label of the device:


Many thanks.

It is always nice to see what others are using.

Best regards