esp8266 isn't reading or writing on the field
Afficher commentaires plus anciens
esp8266 keeps displaying 0 even though the field is 1, and it's not writing to it. it was working fine for months. and today out of the blue it's not working. checked the esp and it's working fine. tried writing and reading from the channel using an app and it's working fine. what could be the problem?
void loop() {
int A = ThingSpeak.readLongField(ChannelNumber, FieldNumber1, ReadAPIKey);
Serial.println(A);
if (A == 1 && !relayTriggered) { // only trigger the relay if it hasn't been triggered before
digitalWrite(relay, LOW);
delay(200);
digitalWrite(relay, HIGH);
ThingSpeak.writeField(ChannelNumber, FieldNumber1, 1, WriteAPIKey); // Write 0 back to FieldNumber1 using ThingSpeak API
relayTriggered = true; // set the flag to true after the relay has been triggered
} else if (A == 0) {
relayTriggered = false; // reset the flag when the field value changes to 0
}
ThingSpeak.writeField(ChannelNumber, FieldNumber1, 1, WriteAPIKey);
}

1 commentaire
Muhammad
le 5 Juin 2023
Réponse acceptée
Plus de réponses (0)
Communautés
Plus de réponses dans ThingSpeak Community
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



