# Cloud Variables issue

**URL:** <https://community.particle.io/t/cloud-variables-issue/60519>\
**Category:** Cloud\
**Created:** [June 10, 2021, 8:32am UTC](https://community.particle.io/t/cloud-variables-issue/60519 "2021-06-10T08:32:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasekj](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@vasekj](https://community.particle.io/u/vasekj)\
**Post date:** [June 10, 2021, 8:32am UTC](https://community.particle.io/t/cloud-variables-issue/60519/1 "2021-06-10T08:32:11Z")

</div>

Hi I would like to ask you for help with my Cloud variables issue. I have two projects with the same approach in how I am reading temperature from Dallas sensors and showing them as variables in the cloud. But it seems that it stops working and shows the only strange character as you can see in the picture.  
I tested various variable types and the only string somehow works. I have a specific problem with INT and Boolean. It might be an format or variable type definition problem. But when I am specifiing Variable type in Particle.variable(“Teplota 1”, temp1, INT); I got error msg during compilation.

…/wiring/inc/spark\_wiring\_cloud.h:81:39: call of overloaded ‘\_variable(const char [10], const int&, const CloudVariableTypeInt&)’ is ambiguous

 ![cloud](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/2/c/2c6a4f35c1dd3707596953aeda5944da2ba53e39.jpeg)

Thank you for any help  
Jaroslav

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 10, 2021, 8:44am UTC](https://community.particle.io/t/cloud-variables-issue/60519/2 "2021-06-10T08:44:34Z")

</div>

First you are using a deprecated syntax and that not correctly 😉

The correct way to write the deprecated syntax would be

```cpp
Particle.variable("Teplota1", &temp1, INT);

```

(no spaces in the variable name and an _ **ampersand** _ (address of operator) in front of the source variable)

However the better way to write it in a “modern” fashion would be

```cpp
Particle.variable("Teplota1", temp1);

```

BTW, since we cannot see your variable definitions and how you use `Particle.variable()` in your code I’ll just mention for completeness:  
The base variables must be global and `Particle.variable()` can only be called _ **once** _ per variable definition.

---

<div class="post-metadata">

**Author:** ![vasekj](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@vasekj](https://community.particle.io/u/vasekj)\
**Post date:** [June 11, 2021, 11:36am UTC](https://community.particle.io/t/cloud-variables-issue/60519/3 "2021-06-11T11:36:37Z")

</div>

Thank you ScruffR,  
I have test both syntax unfortunately with the same result. I am also attaching the code. This is basic pool management starting relay modules and reading temperatures. Functions and variables are initiated and ready by IFTTT.  
Do you have any idea where the problem could be?  
Thank you  
Jaroslav

```auto
#include "DS18B20_Pi.h"
#include <iostream>
#include <string>

int led1 = D1;
int led2 = D2;
int led3 = D3;
int led4 = D4;
int led5 = D5;
int led6 = D6;
int led7 = D7;
int led8 = D8;

char w1_address[15]; //temp akumulacka string
char w2_address[15]; //temp boiler string
char w3_address[15]; //temp boiler string

bool bublinky = false; // vririvka
bool filtrace = false; //aktivita filtrace
bool svetlo = false; //bazenove svetlo

int temp1=0;
int temp2=0;
int temp3=0;

 
void setup() {

   
   
   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);
   pinMode(led3, OUTPUT);
   pinMode(led4, OUTPUT);
   pinMode(led5, OUTPUT); //čistící robot
   pinMode(led6, OUTPUT); //bublinky vířivka
   pinMode(led7, OUTPUT); //Led světlo bazénu
   pinMode(led8, OUTPUT); //filtrace

   digitalWrite(led1, HIGH);
   digitalWrite(led2, HIGH);
   digitalWrite(led3, HIGH);
   digitalWrite(led4, HIGH);
   digitalWrite(led5, HIGH);
   digitalWrite(led6, HIGH);
   digitalWrite(led7, HIGH);
   digitalWrite(led8, HIGH);

   Particle.function("8CH_rele",ledToggle);
   Particle.variable("Bublinky", bublinky);
   Particle.variable("Svetlo", svetlo);
   Particle.variable("Filtrace", filtrace);
   Particle.variable("Teplota1", temp1);
   Particle.variable("Teplota 2", temp2);
   Particle.variable("Teplota 3", temp3);
   Particle.variable("Test", "led8");

   

}

void loop() 

   {
   
    
   strcpy(w1_address, "28-00000d2f9d04"); //cteni teploty
   strcpy(w2_address, "28-00000c4223e5"); //cteni teploty
   strcpy(w3_address, "28-00000d2fbcad"); //cteni teploty
   
    
    DS18B20 w1Device (w1_address); // prevod typu promene z text na int
    temp1 = w1Device.getTemp(); // prevod typu promene z text na int
    
    DS18B20 w2Device (w2_address); // prevod typu promene z text na int
    temp2 = w2Device.getTemp(); // prevod typu promene z text na int
    
    DS18B20 w3Device (w3_address); // prevod typu promene z text na int
    temp3 = w3Device.getTemp(); // prevod typu promene z text na int
    

    

      }

int ledToggle(String command) {

    if (command=="D1") {
        digitalWrite(led1,LOW);
        delay(1000); 
        digitalWrite(led1,HIGH);
       
        return 1;
    }
    else if (command=="D2") {
        digitalWrite(led2,LOW);
        delay(1000); 
        digitalWrite(led2,HIGH);

        return 2;
    }
    else if (command=="D3") {
        digitalWrite(led3,LOW);
        delay(1000); 
        digitalWrite(led3,HIGH);

        return 3;
    }
    else if (command=="D4") {
         digitalWrite(led4,LOW);
        delay(1000); 
        digitalWrite(led4,HIGH);

        return 4;
    }
     // Robot
    else if (command=="D5") {
        digitalWrite(led5,LOW);
        delay(1000); 
        digitalWrite(led5,HIGH);

        return 5;
    }
        else if (command=="D55") {
        digitalWrite(led5,LOW);
        delay(1000); 
        digitalWrite(led5,HIGH);
        delay(3000); 
        digitalWrite(led5,LOW);
        delay(1000); 
        digitalWrite(led5,HIGH);

        return 5;
    }
      // bublinky
    else if (command=="D6") {
        digitalWrite(led6,LOW);
        bublinky = true;
   

        return 6;
    }  
     else if (command=="D60") {
       
        digitalWrite(led6,HIGH);
          svetlo = false;
        return 60;
    
    }
          // světlo
  
    else if (command=="D7") {
        digitalWrite(led7,LOW);
           svetlo = true;
         return 7;
    }
       else if (command=="D70") {
       
        digitalWrite(led7,HIGH);
          svetlo = false;
        return 70;
    
    }
    else if (command=="D8") {
        digitalWrite(led6,LOW);
         bublinky = true;
        delay(30000); 
        digitalWrite(led6,HIGH);
         bublinky = false;
        digitalWrite(led8,LOW);
        filtrace = true;

        return 8;
        
    }
    else if (command=="D80") {
       
        digitalWrite(led8,HIGH);
          filtrace = false;
        
        

        return 80;
        
    }
    
  
    
    else {
        return -1;
    }
  
}

```

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [June 11, 2021, 12:27pm UTC](https://community.particle.io/t/cloud-variables-issue/60519/4 "2021-06-11T12:27:55Z")

</div>

> [@ScruffR](#):
>
> no spaces in the variable name

@vasekj, as @ScruffR said, no spaces in the variable names! You still have spaces in some names. Also, the length of your address strings are too short as you need to include room for a terminating NULL. So you need a size of 16 not 15.

Once set in `setup()` using `strcpy()` you don't modify the address anywhere in your code. You could, instead you could simply declare your addresses this way and not use `strycpy()` at all:

```auto
const char w1_address[] = "28-00000d2f9d04"; //temp akumulacka string
const char w2_address[] = "28-00000c4223e5"; //temp boiler string
const char w3_address[] = "28-00000d2fbcad"; //temp boiler string

```

Better yet, you could use arrays for both the addresses and the temperatures but I'm not sure you are ready for that.

Finally, the long delays in you `Particle.function()` are not good, especially those exceeding 10 seconds as the Particle Cloud expects an `int` value to be returned within 10 secs max. The ideal code design would use an FSM (Finite State Machine) in `loop()` which covers the different LED states and associated delays. In your `Particle.function()` you would then set the state of the FSM to the corresponding value to trigger the sequence of LEDs and delays() without delaying the `Particle.function()`.

@rickkas7 put together an Application Note for FSMs here:

[https://docs.particle.io/datasheets/app-notes/an010-finite-state-machines/](https://docs.particle.io/datasheets/app-notes/an010-finite-state-machines/)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [December 11, 2021, 12:27am UTC](https://community.particle.io/t/cloud-variables-issue/60519/5 "2021-12-11T00:27:59Z")

</div>

Closed on December 11, 2021, 12:27am UTC

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