Skip to content

Instantly share code, notes, and snippets.

@hippyaki
Last active July 27, 2021 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hippyaki/4470c6a1cfcdc069ecf3dacab454188e to your computer and use it in GitHub Desktop.
Save hippyaki/4470c6a1cfcdc069ecf3dacab454188e to your computer and use it in GitHub Desktop.
Arduino - Bolt Tester
import bolt_conf
from boltiot import Bolt
import json, time, requests
mybolt = Bolt(bolt_conf.API_KEY, bolt_conf.DEVICE_ID)
print ("...............")
print ("Tester")
print ("...............")
print(".")
print(".")
responseA = mybolt.serialBegin('9600')
while True:
responseB = mybolt.serialRead('10')
dataB = json.loads(responseB)
print("Sensor value is: " + str(dataB['value']))
print(".")
print(".")
try:
error = str(dataB['value'])
if error != 'Command timed out' and len(error) != 0:
ret = str(dataB['value'])
print("Returned Value " + ret)
else:
print("Error Occured = " + error)
except Exception as e:
print ("Error occured: Below are the details")
print (e)
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment