i m a new comer to cayenne.firstly i thank cayenne staff and community members to share the knowledge with us and good feed back to provide the student such as us. i made the water level visualizer using node mcu and ultrasonic sensor.code also get from here.i need to save the water level in excel sheet or any document.and also i need to make the graph in that worksheet.when power down data not be loss.level shows as percentage. pls help me.and i apologize from you because i m not fluent in English.code is
// This example shows how to connect to Cayenne using an Ethernet W5100 shield and send/receive sample data.
//#define CAYENNE_DEBUG
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.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 = “############”;
unsigned long lastMillis = 0;
// defines pins numbers
const int trigPin = 2; //D4
const int echoPin = 0; //D3
// defines variables
long duration;
int distance;
int y;
void setup() {
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
void loop() {
Cayenne.loop();
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
y = map(distance, 95, 10, 0, 100);
y = constrain(y, 0, 100);
delay(500);
if (millis() - lastMillis > 10000) {
lastMillis = millis();
Cayenne.virtualWrite(10, distance);
Cayenne.virtualWrite(13, y, “t1”, “null”);
}
}