I am continuing my exploration of the particle devices. This time, I have a Xenon that is connected to a TMP36 temperature sensor sitting in my office at home. Every second, it updates a variable on the cloud that contains the current temperature of my office.
Again, the code running the Xenon is nothing special, just the demonstration code found in the tutorial for reading analog sensors. Oddly, I can find nowhere in the Particle documentation that the analog pins on a Xenon are 10-bit, but they are, which is a bit convenient after having worked with 8-bit analog pins on the Arduino. The Mathematica code is pretty straightforward. Since I am using a variable instead of a function, the HTTPRequest
is GET
instead of POST
.
req = HTTPRequest[<| "Scheme" -> "https", "Domain" -> "api.particle.io", "Path" -> {"v1", "devices", device, "temp"}, "Query" -> {"access_token" -> token} |>] roomtemp = Association[]; tsk = SessionSubmit[ ScheduledTask[roomtemp[Now] = Association[URLExecute@req]["result"], 10]]
I created a scheduled task that would grab the room temperature every 10 seconds and store that in a Mathematica session. The data could then be placed in a dynamic DateListPlot
that has been updating on my work-office computer all day. Nice.
What’s cool (to me) about this project is that the Xenon is not connected to the internet. It is part of a mesh network with an Argon that is just sitting on my desk doing nothing. Once the mesh network was set up, I did not have to do anything on the Xenon to have it push information to the Cloud – it just happens. I’m starting to like this platform.