Hello everyone, I need help I can from issuing of general analog sensor to a virtual pin cayenne who I can give an example
pultroppo the sensor that I have to use not in the of cayenne
the AD8232 sensor code and very simple ache or read the documentation but but anything on the code and why or executed
//#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneEthernet.h>
#define VIRTUAL_PIN V1;
#define VIRTUAL_PIN 1
#define VIRTUAL_PIN1 V3
#define RELAY_DIGITAL_PIN 31
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "//////////";
float sensorValue1;
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
pinMode(RELAY_DIGITAL_PIN, OUTPUT);
pinMode(9, INPUT); // Setup for leads off detection LO +
pinMode(6, INPUT); // Setup for leads off detection LO -
}
CAYENNE_IN(VIRTUAL_PIN)
{
// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 1
// assuming you wire your relay as normally open
if (currentValue == 0) {
digitalWrite(RELAY_DIGITAL_PIN, HIGH);
} else {
digitalWrite(RELAY_DIGITAL_PIN, LOW);
}
}
void loop()
{
Cayenne.run();
int analogValue1 = analogRead(A0); // read the input on analog pin 0
if((digitalRead(6) == 1)||(digitalRead(9) == 1)){
Serial.println(0);
delay(500);
}
else
{
// send the value of analog input 0:
Serial.println(analogRead(A0));
delay(500);
}
}
CAYENNE_OUT(VIRTUAL_PIN1)
{
Cayenne.virtualWrite(VIRTUAL_PIN1, sensorValue1);
delay(500);
}
Solved the problem so it works, thanks for the advice
/*
Cayenne Ethernet Example
This sketch connects to the Cayenne server using an Arduino Ethernet Shield W5100
and runs the main communication loop.
The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
Steps:
Set the token variable to match the Arduino token from the Dashboard.
Compile and upload this sketch.
For Cayenne Dashboard widgets using digital or analog pins this sketch will automatically
send data on those pins to the Cayenne server. If the widgets use Virtual Pins, data
should be sent to those pins using virtualWrites. Examples for sending and receiving
Virtual Pin data are under the Basics folder.
*/
//#define CAYENNE_DEBUG // Uncomment to show debug messages #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space #include <CayenneEthernet.h> #define VIRTUAL_PIN V1;
int sensore1 = A1;
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “xxxxxxx”;
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
pinMode(9, INPUT); // Setup for leads off detection LO +
pinMode(6, INPUT); // Setup for leads off detection LO -