I hope somebody can help me out here with a strange issue. (project: "soil moisture measurement")
The code below is working since quite some time on an old ESP8266.(ESP12 mod) It' still functional.
I've uploaded the same code to another new ESP8266. This doesn't work: Error "Disconnected from Adafruit IO" ??
I am sure The Wifi connection is online. ( IP address etc) but on this new similar device there is no Adafruit IO connection possible?
The right Adafruit login + key is written in the config file.
Somebody? I am really lost.
Code: Select all
// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"
/************************ Example Starts Here *******************************/
// vochtsensor pin
#define PULS_PIN 5 //D1
#define SENSOR_PIN A0
// photocell state
int current = 0;
int last = -1;
// set up the 'analog' feed
AdafruitIO_Feed *analog = io.feed("analog2");
void setup() {
// setup de vochtsensor pins
pinMode(PULS_PIN, OUTPUT);
digitalWrite(PULS_PIN, LOW);
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while(! Serial);
// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
io.connect();
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
}
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();
//lezen van de vochtsensor
digitalWrite(PULS_PIN, HIGH);
int meting = analogRead(SENSOR_PIN);
current = meting;
digitalWrite(PULS_PIN, LOW);
// return if the value hasn't changed
if(current == last)
return;
// save the current state to the analog feed
Serial.print("sending -> ");
Serial.println(current);
analog->save(current);
// store last photocell state
last = current;
// wait three seconds (1000 milliseconds == 1 second)
//
// because there are no active subscriptions, we can use delay()
// instead of tracking millis()
delay(30000);
}