Temperature measurement

I add a second sensor and add 0 channel widget, but now, channel 2 is working, show measurements all the time, but channel 1 stop showing after a several seconds

i did not understand the above. is it working as you need it or is there still an issue.

I add a second sensor and add 0 channel widget, but now, channel 2 is working, show measurements all the time, but channel 1 stop showing after a several seconds

can you share the code you are using.

/*
This sketch connects to the Cayenne server using an ESP8266 WiFi module as a shield connected via a hardware serial to an Arduino.

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. Install the ESP8266SerialLibrary.zip library via the Arduino IDE (Sketch->Include Library->Add .ZIP Library) from the Cayenne extras/libraries
   folder (e.g. My Documents\Arduino\libraries\CayenneMQTT\extras\libraries) to compile this example.
2. Connect the ESP8266 as a shield to your Arduino. This example uses the Serial1 hardware serial pins available on the Mega. You can also try 
   using a software serial, though it may be less stable.
3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
4. Set the network name and password.
5. Compile and upload the sketch.
6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.

NOTE: This code requires ESP8266 firmware version 1.0.0 (AT v0.22) or later.
*/

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

// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";

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

// Set ESP8266 Serial object. In this example we use the Serial1 hardware serial which is available on boards like the Arduino Mega.
#define EspSerial Serial
#define SENSOR_PIN1 A0
#define VIRTUAL_CHANNEL1 1
#define SENSOR_PIN2 A2
#define VIRTUAL_CHANNEL2 2

ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(9600);
  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  delay(10);

  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
}

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

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());
Cayenne.virtualWrite(VIRTUAL_CHANNEL1, analogRead(SENSOR_PIN1));

Cayenne.virtualWrite(VIRTUAL_CHANNEL2, analogRead(SENSOR_PIN2));
}

// 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");
}

the code looks okay. can you share the serial monitor output.

⸮a⸮⸮⸮⸮Ո$⸮⸮⸮⸮AT
ATE0
AT+CIPMUX=1
[1551] Failed to enable MUX
AT+CWMODE?
AT+CWJAP=“BEIREL 6354”,“75288437kh”
[4585] Connected to WiFi
[4585] Connecting to mqtt.mydevices.com:1883
AT+CIPSTART=1,“TCP”,“mqtt.mydevices.com”,1883
AT+CIPSEND=1,40
⸮MQIsdp⸮<$d06efc20-6116-11e9-9dd7AT+CIPSEND=1,40
-93e53f1934d3$291ec810-488a-11e8-bf56-dAT+CIPSEND=1,40
b14f0c2b326(0e737ffa31e6de40bdc7958fd08AT+CIPSEND=1,13
2af113f3c1a4f[5504] Connected
AT+CIPSEND=1,40
⸮^Yv1/291ec810-488a-11e8-bf56-db14f0cAT+CIPSEND=1,40
2b326/things/d06efc20-6116-11e9-9dd7-93eAT+CIPSEND=1,16
53f1934d3/cmd/+[6082] Publish: topic 4, channel 65534, value Arduino Uno, subkey , key
AT+CIPSEND=1,40
1j]v1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,28
f1934d3/sys/modelArduino Uno[6606] Publish: topic 6, channel 65534, value ATmega328P, subkey , key
AT+CIPSEND=1,40
1mav1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,31
f1934d3/sys/cpu/modelATmega328P[7088] Publish: topic 7, channel 65534, value 16000000, subkey , key
AT+CIPSEND=1,40
1kav1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,29
f1934d3/sys/cpu/speed16000000[7565] Publish: topic 5, channel 65534, value 1.3.0, subkey , key
AT+CIPSEND=1,40
1f_v1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,24
f1934d3/sys/version1.3.0[8060] Publish: topic 8, channel 65534, value ESP8266Shield, subkey , key
[8128] Publish: topic 1, channel 0, value 8128, subkey , key
AT+CIPSEND=1,40
1`Zv1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,18
f1934d3/data/08128[8604] Publish: topic 1, channel 1, value 599, subkey , key
AT+CIPSEND=1,40
1_Zv1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,17
f1934d3/data/1599[9080] Publish: topic 1, channel 2, value 593, subkey , key
AT+CIPSEND=1,40
1_Zv1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,17
f1934d3/data/2593[18108] Connection ok
[23140] Publish: topic 1, channel 0, value 23140, subkey , key
AT+CIPSEND=1,40
1aZv1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,19
f1934d3/data/023140[23882] Publish: topic 1, channel 1, value 598, subkey , key
AT+CIPSEND=1,40
1_Zv1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,17
f1934d3/data/1598[24554] Publish: topic 1, channel 2, value 593, subkey , key
AT+CIPSEND=1,40
1_Zv1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
326/things/d06efc20-6116-11e9-9dd7-93e53AT+CIPSEND=1,17
f1934d3/data/2593[28130] Connection ok

check here all channel 0,1 and 2 are sending data. I would suggest deleting all the widgets and let them repopulate automatically. then click on + to add them.

ok I will try

Great! everything is fine now.
what is Channel 0? could I delete it?
Cayenne.virtualWrite(0, millis());
is it this one? its just counting milliseconds

you can remove it. it uploads the uptime in millis()

Ok thanks.
how could I adjust the refreshing time?

have a look at this topic Sending MQTT messages within rate limits

Thank you so much!

Hi. This pictograms on my phone are “soil moisture”. Do you know when will be an update of the app to solve this problem? Thanks

what do you mean by this? can you share a screenshot.

Oh, sorry, I forget to upload a photo.

the icon is not yet supported on mobile app. you can select other icon which is supported on both platform.

Ok. Thanks. Have a good day

Hi. Again, I have a problem with disconnecting, it goes offline every time.
code:

#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266Shield.h>
#include <DHT.h>
// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";

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

// Set ESP8266 Serial object. In this example we use the Serial1 hardware serial which is available on boards like the Arduino Mega.
#define EspSerial Serial
#define SENSOR_PIN1 A0
#define VIRTUAL_CHANNEL1 1
#define SENSOR_PIN2 A1
#define VIRTUAL_CHANNEL2 2
#define SENSOR_PIN3 A2
#define VIRTUAL_CHANNEL3 3
#define SENSOR_PIN4 A3
#define VIRTUAL_CHANNEL4 4
#define SENSOR_PIN5 A4
#define VIRTUAL_CHANNEL5 5
#define SENSOR_PIN6 A5
#define VIRTUAL_CHANNEL6 6
#define DHTPIN 2

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

#define TEMPERATURE_VIRTUAL_CHANNEL 7
#define HUMIDITY_VIRTUAL_CHANNEL 8

DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor.

ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(9600);
  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  delay(10);

  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
  dht.begin();
}

void loop()
{
Cayenne.loop();
 
}
CAYENNE_OUT(TEMPERATURE_VIRTUAL_CHANNEL)
{
  Cayenne.virtualWrite(TEMPERATURE_VIRTUAL_CHANNEL, dht.readTemperature(), "temp", "c");
}

// This function is called at intervals to send humidity sensor data to Cayenne.
CAYENNE_OUT(HUMIDITY_VIRTUAL_CHANNEL)
{
  Cayenne.virtualWrite(HUMIDITY_VIRTUAL_CHANNEL, dht.readHumidity(), "rel_hum", "p");
}
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(VIRTUAL_CHANNEL1, analogRead(SENSOR_PIN1));

Cayenne.virtualWrite(VIRTUAL_CHANNEL2, analogRead(SENSOR_PIN2));

Cayenne.virtualWrite(VIRTUAL_CHANNEL3, analogRead(SENSOR_PIN3));

Cayenne.virtualWrite(VIRTUAL_CHANNEL4, analogRead(SENSOR_PIN4));

Cayenne.virtualWrite(VIRTUAL_CHANNEL5, analogRead(SENSOR_PIN5));

Cayenne.virtualWrite(VIRTUAL_CHANNEL6, analogRead(SENSOR_PIN6));

}

// 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");
}

and com port monitor:

AT
[1530] ESP is not responding
AT
ATE0
AT+CIPMUX=1
AT+CWMODE?
AT+CWJAP="Nikolskaia33_2GEXT","89859248161"
[8095] Connected to WiFi
[8095] Connecting to mqtt.mydevices.com:1883
AT+CIPSTART=1,"TCP","mqtt.mydevices.com",1883
AT+CIPSEND=1,40
⸮MQIsdp⸮<$7d254820-7256-11e9-beb3AT+CIPSEND=1,40
-736c9e4bf7d0$291ec810-488a-11e8-bf56-dAT+CIPSEND=1,40
b14f0c2b326(0e737ffa31e6de40bdc7958fd08AT+CIPSEND=1,13
2af113f3c1a4f[8973] Connected
AT+CIPSEND=1,40
⸮^Yv1/291ec810-488a-11e8-bf56-db14f0cAT+CIPSEND=1,40
2b326/things/7d254820-7256-11e9-beb3-736AT+CIPSEND=1,16
c9e4bf7d0/cmd/+[9548] Publish: topic 4, channel 65534, value Arduino Uno, subkey , key 
AT+CIPSEND=1,40
1j]v1/291ec810-488a-11e8-bf56-db14f0c2b[19577] Publish: topic 6, channel 65534, value ATmega328P, subkey , key 
AT+CIPSEND=1,40
1mav1/291ec810-488a-11e8-bf56-db14f0c2b[29607] Publish: topic 7, channel 65534, value 16000000, subkey , key 
AT+CIPSEND=1,40
1kav1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
[34970] Publish: topic 5, channel 65534, value 1.3.0, subkey , key 
AT+CIPSEND=1,40
[39987] Publish: topic 8, channel 65534, value ESP8266Shield, subkey , key 
[40057] Publish: topic 1, channel 7, value 24.600, subkey c, key temp
AT+CIPSEND=1,40
[45078] Publish: topic 1, channel 8, value 42.500, subkey p, key rel_hum
AT+CIPSEND=1,40
[50096] Publish: topic 1, channel 1, value 0, subkey , key 
AT+CIPSEND=1,40
[55112] Publish: topic 1, channel 2, value 0, subkey , key 
AT+CIPSEND=1,40
[60128] Publish: topic 1, channel 3, value 161, subkey , key 
AT+CIPSEND=1,40
[65144] Publish: topic 1, channel 4, value 296, subkey , key 
AT+CIPSEND=1,40
[70160] Publish: topic 1, channel 5, value 360, subkey , key 
AT+CIPSEND=1,40
[75176] Publish: topic 1, channel 6, value 363, subkey , key 
AT+CIPSEND=1,40
[80193] Connection ok
AT+CIPSEND=1,2
[85239] Publish: topic 1, channel 7, value 24.600, subkey c, key temp
[85241] Publish: topic 1, channel 8, value 42.400, subkey p, key rel_hum
[85246] Publish: topic 1, channel 1, value 0, subkey , key 
[85252] Publish: topic 1, channel 2, value 0, subkey , key 
[85258] Publish: topic 1, channel 3, value 162, subkey , key 
[85263] Publish: topic 1, channel 4, value 219, subkey , key 
[85268] Publish: topic 1, channel 5, value 309, subkey , key 
[85273] Publish: topic 1, channel 6, value 318, subkey , key 
AT+CIPSEND=1,2
AT+CIPCLOSE=1
[95305] Disconnected
[95305] Connecting to mqtt.mydevices.com:1883
AT+CIPSTART=1,"TCP","mqtt.mydevices.com",1883
AT+CIPSEND=1,40
⸮MQIsdp⸮<$7d254820-7256-11e9-beb3AT+CIPSEND=1,40
-736c9e4bf7d0$291ec810-488a-11e8-bf56-dAT+CIPSEND=1,40
b14f0c2b326(0e737ffa31e6de40bdc7958fd08AT+CIPSEND=1,13
2af113f3c1a4f[96369] Connected
AT+CIPSEND=1,40
⸮^Yv1/291ec810-488a-11e8-bf56-db14f0cAT+CIPSEND=1,40
2b326/things/7d254820-7256-11e9-beb3-736AT+CIPSEND=1,16
c9e4bf7d0/cmd/+[97074] Publish: topic 4, channel 65534, value Arduino Uno, subkey , key 
AT+CIPSEND=1,40
1j]v1/291ec810-488a-11e8-bf56-db14f0c2b[107103] Publish: topic 6, channel 65534, value ATmega328P, subkey , key 
AT+CIPSEND=1,40
1mav1/291ec810-488a-11e8-bf56-db14f0c2b[117132] Publish: topic 7, channel 65534, value 16000000, subkey , key 
AT+CIPSEND=1,40
1kav1/291ec810-488a-11e8-bf56-db14f0c2bAT+CIPSEND=1,40
[122413] Publish: topic 5, channel 65534, value 1.3.0, subkey , key 
AT+CIPSEND=1,40
[127430] Publish: topic 8, channel 65534, value ESP8266Shield, subkey , key 
[127470] Publish: topic 1, channel 7, value 24.600, subkey c, key temp
AT+CIPSEND=1,40
[132491] Publish: topic 1, channel 8, value 43.000, subkey p, key rel_hum
AT+CIPSEND=1,40
[137509] Publish: topic 1, channel 1, value 0, subkey , key 
AT+CIPSEND=1,40
[142526] Publish: topic 1, channel 2, value 0, subkey , key 
AT+CIPSEND=1,40
[147542] Publish: topic 1, channel 3, value 162, subkey , key 
AT+CIPSEND=1,40
[152558] Publish: topic 1, channel 4, value 297, subkey , key 
AT+CIPSEND=1,40
[157574] Publish: topic 1, channel 5, value 357, subkey , key 
AT+CIPSEND=1,40
[162590] Publish: topic 1, channel 6, value 357, subkey , key 
AT+CIPSEND=1,40
[167606] Connection ok
AT+CIPSEND=1,2
[172652] Publish: topic 1, channel 7, value 24.600, subkey c, key temp
[172654] Publish: topic 1, channel 8, value 42.800, subkey p, key rel_hum
[172660] Publish: topic 1, channel 1, value 0, subkey , key 
[172665] Publish: topic 1, channel 2, value 0, subkey , key 
[172670] Publish: topic 1, channel 3, value 161, subkey , key 
[172676] Publish: topic 1, channel 4, value 220, subkey , key 
[172681] Publish: topic 1, channel 5, value 311, subkey , key 
[172687] Publish: topic 1, channel 6, value 311, subkey , key 
AT+CIPSEND=1,2
AT+CIPCLOSE=1
[182719] Disconnected
[182719] Connecting to mqtt.mydevices.com:1883
AT+CIPSTART=1,"TCP","mqtt.mydevices.com",1883
AT+CIPSEND=1,40
⸮MQIsdp⸮<$7d254820-7256-11e9-beb3AT+CIPSEND=1,40
-736c9e4bf7d0$291ec810-488a-11e8-bf56-dAT+CIPSEND=1,40
b14f0c2b326(0e737ffa31e6de40bdc7958fd08AT+CIPSEND=1,13
2af113f3c1a4f[184016] Connected
AT+CIPSEND=1,40
⸮^Yv1/291ec810-488a-11e8-bf56-db14f0cAT+CIPSEND=1,40
2b326/things/7d254820-7256-11e9-beb3-736AT+CIPSEND=1,16
c9e4bf7d0/cmd/+[184589] Publish: topic 4, channel 65534, value Arduino Uno, subkey , key 
AT+CIPSEND=1,40
1j]v1/291ec810-488a-11e8-bf56-db14f0c2b

and I didn’t add any widget, but nothing pops up no Chanels at all. Waiting for your help. Thanks.