Hello I am looking for some help I can not get a photoresistor values to show up on cayenne using a esp32. Here is the code I’m using:
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#define EspSerial Serial
#include <CayenneMQTTESP32.h>
#include <WiFi.h>
#include <ESP32Servo.h>
#include <analogWrite.h>
const char* ssid = “SLCPublic”;
const char* password = “”;
char ssidc = “SLCPulbic”;
char passwordc = “”;
char username = “9f2655e0-530e-11ec-bbfc-979c23804144”;
char wifipassword = “1d8266a0170ad3cc2bb68c6b63a8f28a97e90eea”;
char clientID = “06445880-530f-11ec-bbfc-979c23804144”;
int SENSORPIN = 34;
int sensorValue;
Servo servo1;#define SENSOR_PIN (39)
#define VIRTUAL_CHANNEL 3
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
servo1.attach(16);
Cayenne.begin(username, wifipassword, clientID, ssidc, passwordc);
}
void loop(){ {
// put your main code here, to run repeatedly:
Cayenne.loop();
}
sensorValue = analogRead(SENSORPIN);
sensorValue = map(sensorValue, 0, 4095, 0, 180);
servo1.write(sensorValue);
CAYENNE_OUT(VIRTUAL_CHANNEL);
Cayenne.virtualWrite(3, currentResistance);
}