2 dht22

hello everyone, I am very very beginner. Please can you tell me if you can view in the dashboard cayenne two sensors dht22 connected to arduino?
Thanks so much

Ilario

You can have a look at this Double Temperature, rain, humidity on LCD with ESP8266

@shramik_salgaonkar that looks like the blynk library.

You can use my project as a base. Swap out the libraries for esp with your board/shield and then duplicate code to read another dht11 sensor. Let me know if you have any problems. Post your code and I’ll see if I can help.

1 Like

Many thanks! I’ll still ask for help to remove the part related to the display and add the code to connect the board to Cayenne.

thank you very much, let’s see if I understand something. Surely I will still need your help.

1 Like

@adam i shared the above link for using two DHT22.
@ilario.quinson as adam stated you have to use the new MQTT library which can be found in adam’s project.

1 Like

Hello everyone, I modified the sketch of shramiksalgaonka. First problem I can not find the CayennEthernet.h library in the Arduino IDE libraries.

where am I wrong? thank you so much


#include <DHT.h>                              //senzor
#define DHTPIN 2
#define DHTPINB 3
#define DHTTYPE DHT22 
DHT dht(DHTPIN, DHTTYPE);    
DHT dhtb(DHTPINB, DHTTYPE);  
      
float hum, temp;
float humB, tempB;

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneEthernet.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "AuthenticationToken";

void setup()
{
  Serial.begin(9600);
  dht.begin();   
  Cayenne.begin(token, ssid, password);       //Cayenne 
}

void loop(){
  Cayenne.run();
  
// display.command( PCD8544_FUNCTIONSET | PCD8544_POWERDOWN);
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  humB = dhtb.readHumidity();
  tempB = dhtb.readTemperature();
  

 }
 
CAYENNE_OUT(V0)
{
  Cayenne.virtualWrite(V0, dht.readTemperature(true));
}
CAYENNE_OUT(V1)
{
  Cayenne.virtualWrite(V1, dht.readHumidity());
}
CAYENNE_OUT(V2)
{
  Cayenne.virtualWrite(V2, dhtb.readTemperature(true));
}
CAYENNE_OUT(V3)
{
  Cayenne.virtualWrite(V3, dhtb.readHumidity());
}

you need to use new cayenne MQTT library. GitHub - myDevicesIoT/Cayenne-MQTT-Arduino: Cayenne MQTT Arduino Library

Thanks!

Do I have to include libraries Cayenne-MQTT-Arduino even if I do not use wifi but shield ethernet?

depending on the connection you have to include the appropriate library. here you will see the different support connection Cayenne-MQTT-Arduino/examples/Connections at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub

Many thanks!

Hi everyone, I just can not configure anything. Let’s try to make a path step by step.
I log in to my account, I choose arduino uno, the shield 5100. the portal generates a sketch that I copy and paste into the IDE of arduino, shortly after the portal should recognize my board.
I install the Cayenne LPP and CayenneMQTT libraries.
First problem compiling the sketch brings me many errors, load the same sketch and nothing seems to happen, except that I get the email from cayenne that a new device has been added.
Any suggestion?

thanks

can you share the code, screenshot of dashboard and error from the serial monitor.

1 Like

n file included from /home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTEthernetClient.h:21:0,
from /home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTEthernet.h:25,
from /home/pi/Arduino/sketch_jul15c/sketch_jul15c.ino:14:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneArduinoMQTTClient.h: In member function ‘void CayenneArduinoMQTTClient::connect()’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneArduinoMQTTClient.h:58:63: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
if (!NetworkConnect(&_network, CAYENNE_DOMAIN, CAYENNE_PORT)) {
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c: In function ‘CayenneMQTTPublishDataInt’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c:135:2: warning: implicit declaration of function ‘itoa’ [-Wimplicit-function-declaration]
itoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c: In function ‘CayenneMQTTPublishDataUInt’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c:158:2: warning: implicit declaration of function ‘utoa’ [-Wimplicit-function-declaration]
utoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c: In function ‘CayenneMQTTPublishDataLong’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c:181:2: warning: implicit declaration of function ‘ltoa’ [-Wimplicit-function-declaration]
ltoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c: In function ‘CayenneMQTTPublishDataULong’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c:204:2: warning: implicit declaration of function ‘ultoa’ [-Wimplicit-function-declaration]
ultoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c: In function ‘CayenneMQTTPublishDataDouble’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneMQTTClient/CayenneMQTTClient.c:227:2: warning: implicit declaration of function ‘dtostrf’ [-Wimplicit-function-declaration]
dtostrf(value, 5, 3, str);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c: In function ‘CayenneDataArrayAddInt’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c:87:2: warning: implicit declaration of function ‘itoa’ [-Wimplicit-function-declaration]
itoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c: In function ‘CayenneDataArrayAddUInt’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c:105:2: warning: implicit declaration of function ‘utoa’ [-Wimplicit-function-declaration]
utoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c: In function ‘CayenneDataArrayAddLong’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c:123:2: warning: implicit declaration of function ‘ltoa’ [-Wimplicit-function-declaration]
ltoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c: In function ‘CayenneDataArrayAddULong’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c:141:2: warning: implicit declaration of function ‘ultoa’ [-Wimplicit-function-declaration]
ultoa(value, str, 10);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c: In function ‘CayenneDataArrayAddDouble’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneDataArray.c:159:2: warning: implicit declaration of function ‘dtostrf’ [-Wimplicit-function-declaration]
dtostrf(value, 5, 3, str);
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c: In function ‘buildSuffix’:
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:88:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = COMMAND_STRING;
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:91:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = DATA_STRING;
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:94:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = RESPONSE_STRING;
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:97:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = SYS_MODEL_STRING;
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:100:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = SYS_VERSION_STRING;
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:103:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = SYS_CPU_MODEL_STRING;
^
/home/pi/Arduino/libraries/CayenneMQTT/src/CayenneUtils/CayenneUtils.c:106:15: warning: assignment discards ‘const’ qualifier from pointer target type
topicString = SYS_CPU_SPEED_STRING;

/*
This example shows how to connect to Cayenne using an Ethernet W5100 shield and send/receive sample data.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. Set the Cayenne authentication info to match the authentication info from the Dashboard.
2. Compile and upload the sketch.
3. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/

//#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>

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

void setup() {
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
}

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

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
  // Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
  Cayenne.virtualWrite(0, millis());
  // Some examples of other functions you can use to send data.
  //Cayenne.celsiusWrite(1, 22.0);
  //Cayenne.luxWrite(2, 700);
  //Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
  CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  //Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

I am delete device from cayenne site and try with new configuration.

is this the entire serial monitor output?

The first post is the error message that returns IDE at the time of compilation

Below is the text that appears in the serial monitor

[0] 168.0.7
[1464] Connecting to mqtt.mydevices.com:1883
[1762] Connected
[0] MAC: FE-31-AE-F-3F-9F
[513] IP: 192.168.0.7
[514] Connecting to mqtt.mydevices.com:1883
[834] Connected

this means you have successfully connected to cayenne server. Add #define CAYENNE_DEBUG to see the entire output.