Hello All, I am trying to get a Soil moisture sensor working. It is one of my first projects so if yyou would please help me out I would so appreciate it. I went to the cayenne dashboard, added a new custom gauge widget with data set to soil moisture and on channel 0 (not sure what channel 0 is…but thats not my question.) When I click the step:1 Code it returns the example below. This code on my arduino ide is returning an error of CayenneMQTTClient.h: No such file or directory although I have gone to sketch>manage libraries>cayennemqtt. I also saw this error when i searched google and someone helped figure it out https://community.mydevices.com/t/cayennemqttclient-h-no-such-file-or-directory/13136
/**
- @file SimplePublish.c
- Simplified example app for using the Cayenne MQTT C library to publish example data.
*/
#include “CayenneMQTTClient.h”
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char* username = “MQTT_USERNAME”;
char* password = “MQTT_PASSWORD”;
char* clientID = “CLIENT_ID”;
Network network;
CayenneMQTTClient mqttClient;
// Connect to the Cayenne server.
int connectClient(void)
{
// Connect to the server.
int error = 0;
printf(“Connecting to %s:%d\n”, CAYENNE_DOMAIN, CAYENNE_PORT);
if ((error = NetworkConnect(&network, CAYENNE_DOMAIN, CAYENNE_PORT)) != 0) {
return error;
}
if ((error = CayenneMQTTConnect(&mqttClient)) != MQTT_SUCCESS) {
NetworkDisconnect(&network);
return error;
}
printf(“Connected\n”);
// Send device info. Here we just send some example values for the system info. These should be changed to use actual system data, or removed if not needed.
CayenneMQTTPublishData(&mqttClient, NULL, SYS_VERSION_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, CAYENNE_VERSION);
CayenneMQTTPublishData(&mqttClient, NULL, SYS_MODEL_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, “Linux”);
return CAYENNE_SUCCESS;
}
// Main loop where MQTT code is run.
void loop(void)
{
while (1) {
// Yield to allow MQTT message processing.
CayenneMQTTYield(&mqttClient, 1000);
// Publish some example data every second. This should be changed to send your actual data to Cayenne.
CayenneMQTTPublishDataFloat(&mqttClient, NULL, DATA_TOPIC, 0, TYPE_TEMPERATURE, UNIT_CELSIUS, 30.5);
CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 1, TYPE_LUMINOSITY, UNIT_LUX, 1000);
}
}
// Main function.
int main(int argc, char** argv)
{
// Initialize the network.
NetworkInit(&network);
// Initialize the Cayenne client.
CayenneMQTTClientInit(&mqttClient, &network, username, password, clientID, NULL);
// Connect to Cayenne.
if (connectClient() == CAYENNE_SUCCESS) {
// Run main loop.
loop();
}
else {
printf(“Connection failed, exiting\n”);
}
return 0;
}