Send an integer/float variable from particle cloud to photon

i need to set a variable from particle cloud console and send it to the photon throught the particle cloud. the variable is a float or integer and i need to use this variable in the loop for some calculation.

now i’m able to read read variable in the cloud from photon using “particle.variable()” but i can’t understand how to set a variable in the cloud and send it to the firmware loop that run in the photon

thank you

Have a look:

1 Like

A Particle variable can not be of type “float”. Only int, double, and string are permitted. Here is an example using a double:

  double Double = 0;

void setup() {
    Particle.function("setDouble", setDouble);
    Particle.variable("Double", Double);
}

void loop() {

}

int setDouble(String s) {
    Double = atof(s);
}

The variable “Double” is a global variable, and can be referenced in loop().
Note: atof() actually returns a double.

1 Like

Your setDouble() should return an int as result code.

1 Like

thank you all!

now i’m able to set a variable from the clud and make it run in to the loop

bye

carlo