This is a smartwatch version of the particle Tinker app, that let you control all the pins of Photon board, from your pebble.
I tested it only with Photon, but should work also with Core and Electron.
On the board side, all you need to do is upload the tinker.ino scketch, available on on the example section of the Particle cloud IDE, or in the software section of this article.
Then install the watchapp from the Pebble App store.
Here is a little demo
SOFTWARE
For the watchapp a used Pebble.js, which is very easy to use, and lets you code in JavaScript. Here is the reference page.
The software I wrote is quite simple to understand. I only create some menus to list pins and actions, and a window to show information from Photon , and interact with it.
Remember to replace your device id and access token in the code.
var DEVICE_ID = '123456987456321456987456'; //Replace with your photon device ID
var ACCESS_TOKEN = '1234567890abcdef1234567890abcdf123456789'; //Replace with your particle access token. Remember not share it
An important thing you have to know is that when you write your app with Pebble.js, the JavaScript code is run on your smartphone, and UI changes are sent to the watch through bluetooth when needed.
For this reason, Pebble.js guidelines say that you should avoid using setTimeout, setTinterval and friends in your code, because the app can stop at any time if the connection between phone and watch is lost.
I discovered this only after finishing the entire project, thats why I used it in my project.
To communicate with Photon I used REST APIs, which let you interact with your board using HTTP requests.
In this case I used the API for calling functions exposed by the device.
I didn't find any documentation of how command has to be sent to use the fuction of the already existing tinker.ino sckecth, but looking at he code you can understand it;
- command to write a pin: PIN_NAME VALUE
- command to read a pin: PIN_NAME
When reading data from the board, I refresh them every 500ms, but you can change this delay
var intervalID = setInterval(function()
{
readValue(e3.itemIndex === 0?'digitalread':'analogread', e.item.title);
}, 500); //Change this value
Comments