Particle variable not registering

Particle variable not registering!

When I run the following code:

int led = D0;

int photoresistor_right = A0; 
int photoresistor_left = A1;

int analogvalue_right = 1;
int analogvalue_left = 1;

// Next we go into the setup function.

void setup() {
    Particle.variable("analogvalue_right", &analogvalue_right, INT);
    Particle.variable("analogvalue_left", &analogvalue_left, INT);
    pinMode(photoresistor_right,INPUT); 
    pinMode(photoresistor_left, INPUT);


}
void loop() {
    analogvalue_right = analogRead(photoresistor_right);
    analogvalue_left = analogRead(photoresistor_left);
}

and access: https://api.particle.io/v1/devices/<device_id>/?access_token=<token>

I see the following json as if no variables were registered. what could be going on?

{
id: "<device id>",
name: "<device_name>",
connected: true,
variables: { },
functions: [ ],
cc3000_patch_version: "wl0: Nov 7 2014 16:03:45 version 5.90.230.12 FWID 01-303c9c9b",
product_id: 6,
last_heard: "2015-12-28T04:21:14.017Z",
status: "normal"
}

Hi @crimsonalucard

This is common first-time failure mode–the name is limited to a maximum of 12 characters and you have 17 and 16 for the two variables. Try making the names shorter!

Below is a link to the doc for the which the summary is “Currently, up to 10 cloud variables may be defined and each variable name is limited to a maximum of 12 characters.”

https://docs.particle.io/reference/firmware/photon/#particle-variable-

3 Likes