How's the tinker app working? Is photon using MQTT to talk to server?


I’m trying to understand how the tinker app works across the system.
From reference, the function can be called by POST /v1/devices/{DEVICE_ID}/{FUNCTION}.
Particle.function(“FUNCTION”, funcName);

I got confused.
There are 3 parts in the whole system --> Photon, Particle Cloud, Android phone client.

  1. Android phone client POST /v1/devices/{DEVICE_ID}/{FUNCTION}.
  2. Particle Cloud server get the request, and send a query request to Photon via MQTT?
  3. Photon should have a server running to listening for the request from Cloud server?

I’d like to read the source codes in Photon firmware, Cloud server app and Android client app. I’ve already got and am reading Photon firmware, couldn’t find a clue how the Photon sensor data got sent to Cloud.

Hi @neilengineer

The Particle Cloud does not use MQTT. They use a protocol that runs over CoAP, on TCP for Photon and UDP for Electron. That protocol enables a RESTful interface to the cloud with HTTPS GET requests for variables, POST requests for functions, SSE events for published events. The Particle Cloud is optional with Particle devices so you can choose to use it or not.

Tinker is an example application that allows Particle functions and variables to control the GPIO pins on devices. Once you write your own code, it replaces Tinker on your device and you stop using Tinker. Tinker is also a “known good” application for your device that help you find connection issues, etc. You can always reflash Tinker if you need it.

The iOS and Android apps are there to (1) help setup new Particle devices and (2) let you use the Tinker application for examples and (3) learn from the open source code that makes them up. Once your devices are online and setup, you don’t use the iOS and Android apps as much. Once your device is running code that you wrote instead of Tinker, the specific Particle functions and variables that Tinker provides are no longer present, so these are not really useful except as learning vehicles and for checking device status.

All of the available source is on github.


Thank you very much bko. I’m pretty interested on how the tinker app works itself.
Want to get the general idea how these 3 communicate.

  1. Android phone client POST /v1/devices/{DEVICE_ID}/{FUNCTION}. ===> HTTP
  2. Particle Cloud server get the request, and send a query request to Photon ===> CoAP ?
  3. Photon should have a server running to listening for the request from Cloud server? ===> CoAP and Photon has a server listening?

The Tinker application source is on github as is the source for the iOS, Android, Window Phone, and a JS library. Here are some links.

The cloud connection is initiated from the device (Photon or Electron or RPi) over CoAP. There is a then a more-or-less continuous connect between device and cloud until your code turns it off. I say more-or-less because Electron over UDP works is a slightly different way trying to minimize cellular data usage. There is not a server per se on the device since the device initiates the connection and I could call the cloud the server and device the client. On Photon there is a continuous TCP connection when the device is connect to the cloud, indicated by the main RGB LED breathing cyan, but you can control the cloud connection–use it or not, disconnect and reconnect as you like.

The best way to learn about these devices is to use them. I am sensing that you don’t have one yet and I would say that a Photon is a small investment to learn about these technologies.

@bko Thanks very much, I just bought a photon, I ran tinker app and other example apps already. Trying to read the firmware codes to understand what’s going on underneath now, :slight_smile: