[SOLVED] How do I retrieve and use exposed variables in the MIT App Inventor?

I’ve read through a number of posts here, searched Google and tried to wrap my head around the demo project created by Team Practical Projects for communicating between the Photon and the App creator, but I’m just not finding what I’m looking for.

It seems like a basic thing, but my lack of experience is making it difficult. I’ve exposed two variables to the cloud on my Photon - startLit and endLit. These are just basic integers that refer to LEDs on a strip. I want to create a simple app that first reads the current values on the device, does some math, and sends it back to the Photon based on which buttons are tapped in the app. I just can’t figure out which blocks in the MIT App Inventor actual do those calls.

I realize I could go the long way and build functions onto the Photon and just call those functions for adding/subtracting, but I feel like keeping the on the app is better for memory optimization and scalability.

There are some threads in this forum that already deal with App Inventor questions
e.g.

Although this is calling a Particle.function() rather than getting a Particle.variable(), but the principle is the same.

The difference is that you need a GET request (not POST as for functions) and catch the response (which really should be done with the function call too).

The documentation of the respective request can be found here
https://docs.particle.io/reference/device-cloud/api/#get-a-variable-value

The response will be in JSON format and can be parsed as shown here
http://ai2.appinventor.mit.edu/reference/other/json-web-apis.html

Thank you, this was a great jumping off point.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.