Getting multiple variables from a Photon into an Android app

Hi peeps,

I’m making a temperature controlling rig using a sensor and relay output from my Photon to control a slow cooker.

I want an Android app that can act as the control interface, and allow you to set temperature, time, view those values in realtime, and start and stop the rig.

Currently I’m using an Asynctask running in a Handler to check the 5 variables with device.getVariable() every 5-10 seconds, but I’d like to get faster updates. If I set the cycle frequency too fast, the Photon falls over and reboots.

I’ve seen several posts talking about running TCP or UDP servers, is that a better idea in this application? Can I bundle variables together so I only need one request?

Happy for any tips or advice.

Yup, and I’d suggest doing that regardless. Combine your variables into an easy to parse string, and extract the needed information on the client side.
You can do the same with server sent events, which go up to 1p/s, and are pushed from the device.

How could i do that with an example like this?

public void getTemps(){
    Async.executeAsync(ParticleCloud.get(MainActivity.this, new Async.ApiWork<ParticleDevice, Integer>() {

        public Integer callApi(ParticleDevice particleDevice) throws ParticleCloudException, IOException {
            return particleDevice.getVariable("myVariable");

        public void onSuccess(Integer value) {
            Toaster.s(MainActivity.this, "Room temp is " + value + " degrees.");

        public void onFailure(ParticleCloudException e) {
            Log.e("SOME_TAG", e);
            Toaster.l(MainActivity.this, "Wrong credentials or no internet connectivity, please try again");