I have a temperature sensor in my cup of tea, and I have configured a trigger that sends me a text message when the temperature drops below 60°C.
Now I want to build an Android app with virtual reality that displays on my cup of tea the temperature.
Is there a way to get the sensor value with an API or something like this ?
I must say that when I think of IoT, and what can be done with it; monitoring the temperature of my favorite warm beverage was not on list of things that could be done.
But now that you mention it, what a splendid idea! After all, is there anything worse than finding your beverage has gone cold on a day like we are having today?
@bestes I’m happy to read that you are working on the API ! I am trying to convice my boss to use Cayenne for our IoT and VR projects, do you think I can get the temperature with some “little hack” to setup a quick demo ?
I’d love to participate to the meetup, but it will be in the middle of the night for me (i’m in France). With some cups of coffee (at the right temperature with my sensors ), maybe I could be awake !
@Ian Could you please send a little of your snow in my city ? ^^
You would do fine, of course driving in this stuff has a slight learning curve.
@etienne.villedieu
Sure! How much do you want? Better hurry, most of it will be gone today. All should be gone by Sunday, looking at temperatures near 16°C (60°F) by then.
See, things are already looking up, we’re above 0°C
Yes ! In facts this is a very dirty hack and I can’t wait to test your API !
I use a Python script with Heliumhq (http://heliumhq.com/), a web automation library. This script logs me on cayenne and go to the page Log in to Cayenne which contains a json file with the temperature of my sensor
Here is my python code that gets the temperature and sends it to my server :
from helium.api import *
import time
import json
import urllib2
# Open chrome on the cayenne's login page
start_chrome("https://cayenne.mydevices.com/cayenne/login")
time.sleep(2)
# Fill form with email and password
write("xxxxxxxxxx@xxxxxxxx.xxx", into="email")
write("xxxxxxxxxxxxxxxxxxxxxxx", into="password")
# Click on the "Log In" button
press(TAB)
press(ENTER)
# DEVICE_CODE can be found in the dashboard's URL
go_to("https://cayenne.mydevices.com/cayenne/api/raspberrypi/DEVICE_CODE/info")
# Get the temperature every 10 sec
while 1:
refresh() # Refresh the page
data = S("//html/body/pre").web_element.text # Get the json file
data_json = json.loads(data) # Load json
temp = data_json['info']['SensorsInfo'][1]['Celsius'] # Get the Celsius value of the sensor's temperature
# Send the temperature to my server
reponse_page = urllib2.urlopen("http://xxxxxxx.fr/cayenne/add.php?temp="+str(temp)).read()
print temp
time.sleep(10) # Wait 10sec
Python and electronics is getting deep but I think has a nice fit between electronics and programming and right through to some networky sorts of ideas I.e. great for kids project work. Standard upper level project work in nz schools here.
Modules of python as examples or set up as functions, library etc could be a faster way to get data over the fence and into Cayenne GUI area. This is really nice for the quick
Either way I am dead keen to see some tinker and hack-ability.
For those that want to break new ground
Dev new sensors early and up front and get it working (for you guys etc)
Mad stuff. Fun, art, creativity ‘mix it up’ sort of IoT ideas
Dropping the serial idea that I realise will be too complex… The main idea is to get a function or lib sort of thing that allows passing of data across to and from Cayenne to other ‘things’ going on in the Pi. Kids projects and python tinkering in my case.