Problem sending Values

Hello guys, my program is not sending codes, sometimes it sends annoying codes and in most of times it doesn’t send…

The code is:

void loop()
{
Cayenne.run();
Temperatura();
}

void Temperatura()
{
float h = dht.readHumidity();
float temp = dht.readTemperature();
float hic = dht.computeHeatIndex(temp, h, false);
myNextion.setComponentText(“t0”, String(temp));
myNextion.setComponentText(“t2”, String(h));
delay(2000);
Cayenne.virtualWrite(V0,temp);
}

I also tried:

CAYENNE_OUT(V0)
{
Cayenne.virtualWrite(V0,temp);
delay(2000);
}

And also tried:

void loop()
{
Cayenne.run(); // (CAYENNE)
float temp = dht.readTemperature();
float hic = dht.computeHeatIndex(temp, h, false);
Cayenne.virtualWrite(V0,temp);
}

None of them sent any command, the virtual pin is correct (in that case 0), I checked the sensor in Cayenne and it’s ok… The problem probably is the code, but I don’t know what I’m doing wrong…
Cayenne is connecting normally…

Hi
Try it this way.

   include ......

    float h;
    float temp;
    float hic;

    void setup()
    {
    ........
    }

    void loop()
    {
    Cayenne.run();
    Temperatura();
    }

    void Temperatura()
    {
    h = dht.readHumidity();
    temp = dht.readTemperature();
    hic = dht.computeHeatIndex(temp, h, false);
    myNextion.setComponentText("t0", String(temp));
    myNextion.setComponentText("t2", String(h));
    delay(2000);
    }

    CAYENNE_OUT(V0)
    {
    Cayenne.virtualWrite(V0,temp);
    }
1 Like

It doesn’t work :frowning:

Are you getting any errors in the serial monitor?