Hi, I am working on a project with my Arduino Uno WiFi Rev2 to send data to Cayenne from a DHT22 sensor and a 200PSI Pressure Transducer, with a DHT22 sensor is ok, but with the pressure transducer I cannot send de variable “psi” to Cayenne Dashboard, the channel 5 is on the dashboard but with 0 value, on Serial Monitor I can get the values.
Here is my code:
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTUnoWifiRev2.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
char ssid = “mynetwork”;
char wifiPassword = “xxxxxxxxxxxxxxxxx”;
#define DHTPIN 8
#define DHTTYPE DHT22
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
char username = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
char password = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
char clientID = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
#define VIRTUAL_CHANNEL 2
#define ACTUATOR_PIN 2
int psi;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
dht.begin();
}
void loop() {
Cayenne.loop();
pinMode (ACTUATOR_PIN, OUTPUT);
float sensorVoltage = analogRead(0);
int psi = ((sensorVoltage-95)/204)*43.5;
Serial.println (“PSI”);
Serial.println (psi);
delay(1000);
}
CAYENNE_OUT_DEFAULT()
{
Cayenne.virtualWrite(0, millis());
sensors_event_t event;
dht.temperature().getEvent(&event);
Cayenne.celsiusWrite(1, event.temperature);
dht.humidity().getEvent(&event);
Cayenne.virtualWrite(3, event.relative_humidity, "rel_hum", "p");
Cayenne.virtualWrite(5, psi, "analog_sensor", "null");
}