#include #include #define VIRTUAL_PIN1 V0 #define VIRTUAL_PIN2 V1 //#define CAYENNE_DEBUG // Uncomment to show debug messages #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space #include // Cayenne authentication token. This should be obtained from the Cayenne Dashboard. char token[] = "token"; // Your network name and password. char ssid[] = "ssid"; char password[] = "password"; #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); float sensorValue1; float sensorValue2; void setup() { Serial.begin(9600); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); Cayenne.begin(token, ssid, password); } void loop() { Cayenne.run(); int analogValue1 = analogRead(A1); // read the input on analog pin 0 int analogValue2 = analogRead(A2); // read the input on analog pin 1 float a = 5; //I am measuring 16,5V on sensor, 16,5V/3,3V=5 float b = 0.00322580645; //Voltage on 3,3V pin on arduino / 1023, My voltage is 3,3V > 3,3/1023=0.00322580645 sensorValue1 = analogValue1 * a * b; sensorValue2 = analogValue2 * a * b; Serial.println(sensorValue1); Serial.println(sensorValue2); delay(500); //measuring every 0.5s displaydata(); } void displaydata() { display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); display.setCursor(0, 0); //First Value display.println("1."); display.setCursor(15, 0); display.println(sensorValue1); display.setCursor(45, 0); display.println("V"); display.setCursor(0, 10); //Second Value display.println("2."); display.setCursor(15, 10); display.println(sensorValue2); display.setCursor(45, 10); display.println("V"); display.display(); } CAYENNE_OUT(VIRTUAL_PIN1) { Cayenne.virtualWrite(VIRTUAL_PIN1, sensorValue1); } CAYENNE_OUT(VIRTUAL_PIN2) { Cayenne.virtualWrite(VIRTUAL_PIN2, sensorValue2); }