hola a todos, alguien podría ayudarme a saber cual es el problema en este código-. es para conectar a Cayenne un sensor de humedad.
#include <CayenneMQTTSerial.h>
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h> // Change this to use a different communication device. See Communications examples.
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "f7b9f830-xxxx35fab7fd0ac8";
char password[] = "7b0cf695xxxx9c4a27a86c6";
char clientID[] = "d9dadxxxxx2af62b";
#define VIRTUAL_CHANNEL 0
void setup()
{
//Baud rate can be specified by calling Cayenne.begin(username, password, clientID, 9600);
Cayenne.begin(username, password, clientID);
Serial.begin(9600);
Serial.println("Valor del sensor de humedad");
}
void loop() {
Cayenne.loop();
//Paso 2
int humidity = analogRead(A0);
Serial.print("Lectura:");
Serial.println(humidity);
//Paso 3
if(humidity >= 0 & humidity <= 300){
Serial.println("Sensor en suelo seco");
} else if(humidity > 301 & humidity <= 700){
Serial.println("Sensor en suelo húmedo");
}else if(humidity >= 701){
Serial.println("Sensor en agua");
}
delay(1000);
}
// DATOS DE ERROR//
// 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, humidity());
// 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()
{
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}
In file included from C:\Users\David Duque\Desktop\cayenne\cayenne.ino:3:0:
C:\Users\David Duque\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:21:0: warning: "INFO_CONNECTION" redefined
#define INFO_CONNECTION "W5100"
In file included from C:\Users\David Duque\Desktop\cayenne\cayenne.ino:1:0:
C:\Users\David Duque\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTSerial.h:21:0: note: this is the location of the previous definition
#define INFO_CONNECTION "Serial"
In file included from C:\Users\David Duque\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25:0,
from C:\Users\David Duque\Desktop\cayenne\cayenne.ino:3:
C:\Users\David Duque\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:119:27: error: conflicting declaration 'CayenneMQTTEthernetClient Cayenne'
CayenneMQTTEthernetClient Cayenne;
^~~~~~~
In file included from C:\Users\David Duque\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTSerial.h:25:0,
from C:\Users\David Duque\Desktop\cayenne\cayenne.ino:1:
C:\Users\David Duque\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTSerialClient.h:167:25: note: previous declaration as 'CayenneMQTTSerialClient Cayenne'
CayenneMQTTSerialClient Cayenne;
^~~~~~~
C:\Users\David Duque\Desktop\cayenne\cayenne.ino: In function 'void CayenneOutDefault()':
cayenne:42:27: error: 'humidity' was not declared in this scope
Cayenne.virtualWrite(0, humidity());
^~~~~~~~
exit status 1
'humidity' was not declared in this scope
Este informe podría contener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.