Basic info on "digital in" ESP8266

New to Cayenne and the ESP8266 and having a very basic problem learning about “digital in” on a HUZZAH ESP8266. The following code is the only thing I could find. A display shows up on the dashboard but doesn’t reflect the actual status of the 8266 pin 5. Watched the videos, searched for hours but still having a hard time understanding the relationship of the virtual and physical pins on the 8266 and how to make it work. Any help clarifying whats going on here would be appreciated.

The usual login stuff here-----------------------------:

#define SENSOR_PIN 5 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL 3

void setup()
{
Serial.begin(9600);
Cayenne.begin(username, password, clientID);
}

void loop()
{
Cayenne.loop();
}

// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL)
{
Cayenne.virtualWrite(VIRTUAL_CHANNEL, digitalRead(SENSOR_PIN));
}

Cayenne.virtualWrite(VIRTUAL_CHANNEL, digitalRead(5), “digital_sensor”, “d”);

2 Likes

Thank You!! Now I have something working to learn from. Unfortunately triggers aren’t working. I’ve been reading the related posts. Bummer. I have a Uno here that is working great. Thought I could move over to the 8266.

1 Like

triggers are working fine but there is still a bug sometimes. try removing the device and adding the sensor widget again and add trigger.

2 Likes

shramiksalgaonkar thanks for the reply. But I still couldn’t make them work. Posting in the triggers thread my procedure.