Particle.variable giving errors at compile

Use the example for the variable and use to compile and work.
To make it simple I was just trying to set one to my variable:
Particle.variable(“humidity”, 1);
Now the Particle.variable gives "error: no matching function for call to ‘CloudClass::variable(const char [9], int)’"
I have to write this way to make it compile:
Particle.variable(“humidity”, (uint32_t*)1, INT);

Is this normal, it used to work like your example before. Or you rewrite your example or you help me to understand what is going on please.
Thank you

What system firmware are you targeting?

Just to understand your problem, why would you want to expose a constant as a Particle.variable()?

The thing is, you always needed a pointer to a “variable” to expose as Particle.variable() hence Particle.variable("humidity", (int*)1) would still build, but I doubt this has ever worked as “expected” :confused: ???
Unless you exect correctly to see the contents of the memory location 0x0001 as integer :sunglasses:

How exactly are you using Particle.variable()?
Reading this …

… I suspect you are not using Particle.variable() correctly.
That function does not set a variable, but it exposes a variable, which is done only once, and then you’d only ever set the value of the underlying variable but never call Particle.variable() for the same variable name (e.g. "humidity") again.

Thank you for the rapid reply.
I am using the online particle build, and using a Photon.
I used the variable as described on page (when you click at the “read more about this”)

Sinc I had problem to compile I did not want to use a variable and use a int value 1.
If I do this when I look at my variable I just have to see 1.
It is stupid but just to try why this does not compile.
In fact this does not compile unless I do it by inserting a cast and a third parameter. Pls read my first comment.

In the past this worked and compile and today I cannot compile anymore, something changed for sure.


Sorry Moor7, I do not understand your question, as mentioned above I ma programming for the Photon and use the Particle build environment.

BTW The compile with the value set to one compile but do not gives a value of one of course. Anyway if someone could use the on-line particle build and show me how to set a variable that compile I would be happy.

Go to the devices tab, click the little arrow at your device, and check which firmware it’s on.
If at all possible, set it to the highest version, since that should have the most improvements.

Using the Web IDE, and a Photon running 0.6.1, this worked:

Edit: this worked once, but then started behaving erratically, as is to be expected as per @ScruffR’s explanation. Just implement it properly, as per the docs, and it should work alright.

OK great thank you.
I never checked this. It says 0.4.5.
I select the 0.6.1 but now it says On the device 0.4.9 and shows a button ! SIGNAL
Sure this is not clear and confusing…
Is it possible to select the version 0.6.1 on-line?

If you flash a firmware with a higher (selected) version than what’s on the device, it will attempt to auto-update it. It will blink Magenta during the process, and will restart a couple of times. This can take a bit of time, so don’t freak out and start resetting it. Give it some time to do its thing, and it should return to breathing cyan when it’s done.

That said, please implement the variable call properly as mentioned by @ScruffR, since the way it’s done now is asking for problems.

1 Like

OK I tried on one of newer module with the 0.6.1 and yes it does work.
The version is the problem. Thanks.
Can I flash on-line? Well maybe I will find it on the manual. :slight_smile:

OK great it worked. I flash my code and before set the target to 0.6.1. I made it on-line since the device is not close to me.
As you said it flashed and took several time and colors :slight_smile: But it worked.
Great product really and thanks for your help.
Case closed, thank you again.


BTW I can see my real value as the example is on the doc.