I am subscribing to one of the feeds on an esp8266-12e and I am getting the correct values when they are updated.
My problem is that I want to activate a pin on the 12e when the value of the feed is 50.
I have tried this but I am not getting the pin to activate.
- Code: Select all | TOGGLE FULL SIZE
Adafruit_MQTT_Subscribe trip2 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/trip");
Adafruit_MQTT_Subscribe errors = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/errors");
Adafruit_MQTT_Subscribe throttle = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/throttle");
Adafruit_MQTT_Subscribe *subscription;
while ((subscription = mqtt.readSubscription(5000))) {
if (subscription == &trip2) {
Serial.print(F("Got onoff: "));
Serial.println((char *)trip2.lastread);
if ((char *)trip2.lastread == 50) {
digitalWrite(D5, HIGH);
}
} else if(subscription == &errors) {
Serial.print(F("ERROR: "));
Serial.println((char *)errors.lastread);
} else if(subscription == &throttle) {
Serial.println((char *)throttle.lastread);
}
}
If I just put
- Code: Select all | TOGGLE FULL SIZE
if (subscription == &trip2) {
Serial.print(F("Got onoff: "));
Serial.println((char *)trip2.lastread);
digitalWrite(D5, HIGH);
}
the pin is activated and an LED comes on but not with the condition.
What am I doing wrong?
Please HELP.