[SOLVED] Another case of "Variable not found"

Hi!

I have just started developing using the Photon and I am encountering an error using the Spark.variable. For some reason, every other variable name than “result” returns the "variable not found"error, regardless of the content of the Particle.variable. In the following example, I am able to read my data using https://api.spark.io/v1/devices/ID/result?access_token=TOKEN, using both the terminal (curl) or in a browser (Safari, Firefox):

void setup(){
   Particle.variable("result", "0,1,2,3");
}
void loop (){
}

results in

{
  "cmd": "VarReturn",
  "name": "result",
  "result": "0,1,2,3",
  "coreInfo": {
    "last_app": "",
    "last_heard": "---",
    "connected": true,
    "last_handshake_at": "---",
    "deviceID": "---",
    "product_id": 6
  }
}

However, any other name than “result”, e.g. “temp” or “data” gives an error:

void setup() {
    Particle.variable("temp", "0,1,2,3");
}
void loop() {
}

Produces

{
  "ok": false,
  "error": "Variable not found"
}

It should be noted that I experience this problem with two individual Photons. I am absolutely perplexed. I have read numerous other “variable not found” threads, but none of them has provided me with a solution. I hope that someone is able to help! Thanks in advance!

Could you check if these variables really don’t exist with one of these interfaces
http://jordymoors.nl/interface/
http://suda.github.io/particle-web-interface/

It might also be that you need to wait a few seconds after rebooting your device for the cloud to register the new variables.
Also make sure your code actually gets replaced on the device (e.g. add some different D7 blink patterns or Serial.print() statements)
You can also look at the device events via
https://console.particle.io/logs

BTW, I assume you adapted your URL along with the variable names
https://api.spark.io/v1/devices/ID/result?access_token=TOKEN
https://api.spark.io/v1/devices/ID/temp?access_token=TOKEN
https://api.spark.io/v1/devices/ID/data?access_token=TOKEN

3 Likes

No I haven't :sweat:

That was the problem, thanks a lot for your help!

1 Like