My code is working well and data are saved in real time in Cayenne.
How to save the same data on SD Card ?
I am using this code and its working.
How to save same data on SD Card ? Can yo help me, please ?
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include “DHT.h”
#define DHTPIN 12
#define DHTTYPE AM2301
DHT dht(DHTPIN, DHTTYPE);
// WiFi network info.
char ssid = “";
char wifiPassword[] = "**”;
char username = “";
char password[] = "";
char clientID[] = "*****************************************”;
unsigned long lastMillis = 0;
void setup() {
Serial.begin(115200);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
dht.begin();
}
void loop() {
Cayenne.loop();
if (millis() - lastMillis > 14400000) {
lastMillis = millis();
Cayenne.virtualWrite(0, lastMillis);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
Cayenne.celsiusWrite(1, temperature);
Cayenne.virtualWrite(2, humidity, "rel_hum", "p");
}
}
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”, request.channel, getValue.getId(), getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
}
this is the library you need to use to write data to SD data. https://www.arduino.cc/en/Tutorial/LibraryExamples/ReadWrite