Arduino MQTT lots of bugs


#1

After the update to MQTT on my arduino Mega with Ethernet shield w5100 i am only getting problems.
Buttons aren´t working, sliders don´t slide data is being processed wrong etc.

This is my 4th clean install in 2 days because nothing works anymore.

Problem 1, Widget doesn’t displays value although it is beeing received

For example my CO sensor:
//CO Channel 1 & Pin A0
CAYENNE_OUT(1)
{
gas_value=analogRead(A0);
Cayenne.virtualWrite(1, gas_value);
}

Works great, this is what cayenne receives:
Screenshot Data

What it displays:
Screenshot Widget Overview

Widget Settings:
Screenshot Widget Settings

How can it be so hard to display a number?

Problem 2, DHT11 Humidity:
when i use my dht11 script outside the cayenne_out function it works (when i apply a delay of 1sec because this old sensor only sends good data when using a delay). it gives me a INT of 44. but when i use it in CAYENNE_OUT (with or without delay) It displays -999.00 all the time. I think because of the interval time cayenne uses but i can’t change that.

Is there somebody who also uses DHT11 on cayenne who can explain me how to fix this?

//Humidity DHT11 Channel 1 & Pin 6
CAYENNE_OUT(1)
{
int chk = DHT.read11(6);
Cayenne.virtualWrite(1, DHT.humidity); <— This works in a void loop but not here!
}

Problem 3, can’t click button on mobile/android:
Now that i am using MQTT i rebuilded my widgets but on pc i can click them and they stay clicked but on my phone they don’t lock they just go on and off.

I fixed this earlier by using “Bring Your Own Thing” but i want to use Arduino instead od the API. so that isn’t a option for me.

Problem 4, slider that can’t slide:
Using a light slider on pc: Can’t slide at all.
Using slider on phone. Can slide but only between 0 and 1 while i set range of 0-255.
When i try to slide i get this error: “cannot remote to remote device” but sensor data is updating well.

So the only thing that works after MQTT is temperature… Great update i would say…hope to hear from somebody soon.


#2

seems like there are plenty of error with your coding.

change this:

to
Cayenne.virtualWrite(1, gas_value, "co2", "ppm");

change this:

to
Cayenne.virtualWrite(1, chk, "rel_hum", "p");

this is the solution but it is same as Arduino and not API. you will get the MQTT credential and add them in your previous code and follow the same procedure.


#3

already using MQTT credentials.

about those coding errors:
After reading documentaion the only thing i could find was Cayenne.virtualWrite.
Where did you find those other options?


#4

#5

get this from BYOT and add the device.


#6

I made a light switch widget (relay).
It works on PC know but not on my android device. (Clicking but goes on and off).

I am using Arduino instead of BYOT.


#7

try to add a new device using BYOT and then a custom button widget to turn on/off relay. this will work.


#8

i know i tried that already but i don´t understand why cayene made A Arduino option if this options doesn´t even work and every arduino user should use BYOT.

And with BYOT i can only use custom widgets and that takes more time.


#9

team is working on fixing all the bugs and require some time.

with BYOT device you can do all the things that the Arduino device can do. what problem are you facing using a BYOT device?


#10

lets start at the beginning. When selecting arduino device i am getting a example code wich works good.

i always have been using that type of code but when i use BYOT device i get a code that doesn´t work on my Arduino Mega.

So should i use the same code on BYOT as i am using now on arduino device?


#11

in your arduino ide examples you will find all the code for different device connection.

open the code you want. example for you it will Ethernet shield 5100 (my guess) and arduino mega.

in the code:

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "xxx";
char password[] = "xxx";
char clientID[] = "xxx";

this MQTT credential you will get from BYOT.


#12

yes i’m doing that right know. lets give it a fifth try :stuck_out_tongue:
Thanks for your help, that table for data types was what i needed.


#13

Solved Problem 1 & 3
Screenshot Widget Screen

Something that never worked is the humidity.
It works in a void loop and display in serial but when i execute the code in a CAYENNE_OUT cayenne displays -999. Do you have any knowledge of that?


#14

can you share the entire code you use to get reading from DTH11 sensor.


#15

sure,
The link and my project are using the same library

So i tested the sensor first on this way:
Testing Script

it prints out in serial: 27 degrees and 44% humitidy so it works.

This is how i use it in cayenne:
only the dht11 parts are coppied

#include <dht.h>
dht DHT;
        //Temp DHT11 Channel 0 & Pin 6
        CAYENNE_OUT(0)
        {
          int chk = DHT.read11(6);
          Cayenne.celsiusWrite(0, DHT.temperature);
        }

    //humidity Channel 3 Pin 6
    CAYENNE_OUT(3)
    {
      int chk = DHT.read11(6);
       Cayenne.virtualWrite(3, DHT.humidity, "rel_hum", "p");
    }

Humidity worked when i used a delay of 1000/2000 milliseconds. So i think it doesn’t work because of the cayenne interval time before executing script and sending data


#16

have a look at this code by @adam Battery Powered ESP8266 Temperature/Humidity Monitor with DHT11


#17

It’s because you are not checking the DHT results for errors. Use something like this:

do {
  WhileLoops++;
  //We can't go too long without calling Cayenne.loop() so exit this loop after 2 seconds and set an error flag
  if (WhileLoops >= 4){
    Serial.println("Sensor Read Error");
    ReadError = true;
    break;
  }
  //Read temperature as Fahrenheit
  t = dht.readTemperature(true);
  //Read humidity (percent)
  h = dht.readHumidity();
  //Read temperature as Fahrenheit
  t = dht.readTemperature(true);
  //Calculate Heat Index as Fahrenheit
  hif = dht.computeHeatIndex(t, h);

  delay(500);
} while  (isnan(t) || isnan(h));

Code from Battery Powered ESP8266 Temperature/Humidity Monitor with DHT11


#18

so as i already thougt. I need to run the code in loop and only sent it in cayenne_out, lets give it a try, thanks


#19

can you also explain why its working much slower after the update?

and no its not my internet :stuck_out_tongue:

Turning om my led strip on relay takes 2 seconds normally instant.

Changing led strip color takes over 8 seconds sometimes!

Is this normal now or is there a fix?


#20

can you post the code.