[GH-ISSUE #243] Access SSID and Password #203

Closed
opened 2026-02-28 01:24:02 +03:00 by kerem · 29 comments
Owner

Originally created by @dudesky71 on GitHub (Nov 11, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/243

Hello,

I'm trying to use WiFi Manager with ADAFRUIT IO with an ESP8266.

Your code works fine by itself. My problem is passing the saved WiFi SSID and PW to Adafruit's SSID and PW code. It defines it as a constant string.

Is there an easy way to do this?

Thanks!

Originally created by @dudesky71 on GitHub (Nov 11, 2016). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/243 Hello, I'm trying to use WiFi Manager with ADAFRUIT IO with an ESP8266. Your code works fine by itself. My problem is passing the saved WiFi SSID and PW to Adafruit's SSID and PW code. It defines it as a constant string. Is there an easy way to do this? Thanks!
kerem closed this issue 2026-02-28 01:24:03 +03:00
Author
Owner

@tzapu commented on GitHub (Nov 11, 2016):

hi,

fetch it from WiFi.SSID() and WIFI.psk() after the setup is done

cheers
alex

On 11 Nov 2016, at 16:14, dudesky71 notifications@github.com wrote:

Hello,

I'm trying to use WiFi Manager with ADAFRUIT IO with an ESP8266.

Your code works fine by itself. My problem is passing the saved WiFi SSID and PW to Adafruit's SSID and PW code. It defines it as a constant string.

Is there an easy way to do this?

Thanks!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/tzapu/WiFiManager/issues/243, or mute the thread https://github.com/notifications/unsubscribe-auth/AC2FkLUZXrcMeZSAAOie1wLHoHg0Vjr5ks5q9HgygaJpZM4KvyKI.

<!-- gh-comment-id:259965984 --> @tzapu commented on GitHub (Nov 11, 2016): hi, fetch it from WiFi.SSID() and WIFI.psk() after the setup is done cheers alex > On 11 Nov 2016, at 16:14, dudesky71 notifications@github.com wrote: > > Hello, > > I'm trying to use WiFi Manager with ADAFRUIT IO with an ESP8266. > > Your code works fine by itself. My problem is passing the saved WiFi SSID and PW to Adafruit's SSID and PW code. It defines it as a constant string. > > Is there an easy way to do this? > > Thanks! > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub https://github.com/tzapu/WiFiManager/issues/243, or mute the thread https://github.com/notifications/unsubscribe-auth/AC2FkLUZXrcMeZSAAOie1wLHoHg0Vjr5ks5q9HgygaJpZM4KvyKI.
Author
Owner

@dudesky71 commented on GitHub (Nov 11, 2016):

Sorry, don't mean to be a bonehead but their code does this...

#define WIFI_SSID "SSID goes here"
#define WIFI_PASS "PW goes here"

These sit in a config.h file

If I remove the quotes and insert WiFi.SSID() and WIFI.psk() It tells me they are not declared in the scope. I'm sure i'm doing it wrong... Any ideas? Much appreciated :)

<!-- gh-comment-id:259969081 --> @dudesky71 commented on GitHub (Nov 11, 2016): Sorry, don't mean to be a bonehead but their code does this... #define WIFI_SSID "SSID goes here" #define WIFI_PASS "PW goes here" These sit in a config.h file If I remove the quotes and insert WiFi.SSID() and WIFI.psk() It tells me they are not declared in the scope. I'm sure i'm doing it wrong... Any ideas? Much appreciated :)
Author
Owner

@tablatronix commented on GitHub (Nov 11, 2016):

You should be able to just remove adafruit connection code and just use wifimanager autoconenct

<!-- gh-comment-id:260011626 --> @tablatronix commented on GitHub (Nov 11, 2016): You should be able to just remove adafruit connection code and just use wifimanager autoconenct
Author
Owner

@dudesky71 commented on GitHub (Nov 14, 2016):

I got this to work but it seems to not play nicely with Adafruit.IO
When WiFimanager is in the code, it randomly locks up the esp8266 when sending sensor data to Adafruit.IO. If I remove WiFimanager from the startup, it works fine. Everything is running latest. Any ideas?
@tzapu

<!-- gh-comment-id:260380537 --> @dudesky71 commented on GitHub (Nov 14, 2016): I got this to work but it seems to not play nicely with Adafruit.IO When WiFimanager is in the code, it randomly locks up the esp8266 when sending sensor data to Adafruit.IO. If I remove WiFimanager from the startup, it works fine. Everything is running latest. Any ideas? @tzapu
Author
Owner

@tablatronix commented on GitHub (Nov 14, 2016):

basic sketch example ?

<!-- gh-comment-id:260381119 --> @tablatronix commented on GitHub (Nov 14, 2016): basic sketch example ?
Author
Owner

@dudesky71 commented on GitHub (Nov 14, 2016):

ok sorry... What's the secret to pasting code so it all shows up? The forum is stripping some things out :/

<!-- gh-comment-id:260389455 --> @dudesky71 commented on GitHub (Nov 14, 2016): ok sorry... What's the secret to pasting code so it all shows up? The forum is stripping some things out :/
Author
Owner

@tzapu commented on GitHub (Nov 14, 2016):

add three backticks ` before and three after the code

<!-- gh-comment-id:260389940 --> @tzapu commented on GitHub (Nov 14, 2016): add three backticks ` before and three after the code
Author
Owner

@tablatronix commented on GitHub (Nov 14, 2016):

single tick is for inline code, triple ticks for blocks

<!-- gh-comment-id:260396058 --> @tablatronix commented on GitHub (Nov 14, 2016): single tick is for inline code, triple ticks for blocks
Author
Owner

@dudesky71 commented on GitHub (Nov 14, 2016):

#include <DHT.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <WiFiManager.h>
#include "AdafruitIO_WiFi.h"
/************************ Example Starts Here *******************************/
#define IO_USERNAME    "xxxxxx"
#define IO_KEY         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#define WIFI_SSID      ""
#define WIFI_PASS      ""
#define DHTPIN 4     // what digital pin we're connected to. Mapped to pin D2 on WeMOS
#define DHTTYPE DHT11   // DHT 11
//#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#define ANALOG_PIN A0  // analog pin 0
// Initialize DHT sensor.
DHT dht(DHTPIN, DHTTYPE);
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
// analog state
int currentwetness = 0;
int lastwetness = -1;
int tempint = 0;
int humint = 0;
unsigned long previousMillis = 0;
const long interval = 10000;
// set up the 'analog' feed
AdafruitIO_Feed *wetnessfeed = io.feed("wetness");
// set up the 'DHT' feed float
AdafruitIO_Feed *tempfeed = io.feed("temp");
AdafruitIO_Feed *humfeed = io.feed("hum");
// set up the 'DHT' feed integer
AdafruitIO_Feed *tempfeedint = io.feed("tempint");
AdafruitIO_Feed *humfeedint = io.feed("humint");
void setup() {
  // start the serial connection
  Serial.begin(9600);
    Serial.println("");
    Serial.println(WiFi.SSID());
    Serial.println(WiFi.psk());
// put your setup code here, to run once:
    //WiFiManager
    //Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wifiManager;
    //reset saved settings
    //wifiManager.resetSettings();
    
    //set custom ip for portal
    //wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
    //fetches ssid and pass from eeprom and tries to connect
    //if it does not connect it starts an access point with the specified name
    //here  "AutoConnectAP"
    //and goes into a blocking loop awaiting configuration
    //wifiManager.autoConnect("Test-DongleAP");
    //or use this for auto generated name ESP + ChipID
    wifiManager.autoConnect();
    
    //if you get here you have connected to the WiFi
    Serial.println("Connected to WiFi Network...");
  dht.begin();
  delay(100);
  // wait for serial monitor to open
  while(! Serial);
  // connect to io.adafruit.com
  Serial.println("");
  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());
  pinMode(2, OUTPUT);           // set blue led pin to output
    // Show Connection Status and IP Address
  Serial.println("");
  Serial.println("WiFi connected");  
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
  // Blink the blue LED three times for WiFi connection confirmation
  digitalWrite(2, LOW);   // sets the LED on
  delay(50);
  digitalWrite(2, HIGH);   // sets the LED off
  delay(200);
  digitalWrite(2, LOW);   // sets the LED on
  delay(50);
  digitalWrite(2, HIGH);   // sets the LED off
  delay(200);
  digitalWrite(2, LOW);   // sets the LED on
  delay(50);
  digitalWrite(2, HIGH);   // sets the LED off
  Serial.println("");
}
void loop() {
  io.run();
  // 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.
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis; 
  
  // grab the current state of the photocell
  currentwetness = analogRead(ANALOG_PIN);
  // return if the value hasn't changed
  Serial.println("Reading ADC...");
  //if(currentwetness == lastwetness)
  //  return;
  // store last analog state
  lastwetness = currentwetness;
    // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    Serial.println("Reading DHT...");
  float hum = dht.readHumidity();
  humint = hum;
    // wait half second (1000 milliseconds == 1 second)
  delay(500);
  // Read temperature as Celsius (the default)
  // float temp = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float temp = dht.readTemperature(true);
  tempint = temp;
  // float f = dht.readTemperature(true);
  // wait half second (1000 milliseconds == 1 second)
  delay(500);
  // Check if any reads failed and exit early (to try again).
  //  if (isnan(hum) || isnan(temp) || isnan(f)) {
  if (isnan(hum) || isnan(temp)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // Compute heat index in Fahrenheit (the default)
  // float hif = dht.computeHeatIndex(f, hum);
  // Compute heat index in Celsius (isFahreheit = false)
  // float hic = dht.computeHeatIndex(temp, hum, false);
  Serial.print("Humidity: ");
  Serial.print(hum);
  Serial.println(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temp);
  Serial.println(" *F ");
  //Serial.print(f);
  //Serial.print(" *F\t");
  //Serial.print("Heat index: ");
  //Serial.print(hic);
  //Serial.print(" *C ");
  //Serial.print(hif);
  //Serial.println(" *F");
  
  // save the current state to the analog feed
  Serial.print("Sending -> ");
  if (currentwetness <= 10)currentwetness = 0;
  Serial.println(currentwetness);
  wetnessfeed->save(currentwetness);
  delay(1000);
   Serial.print("Sending -> ");
   Serial.println(temp);
  String tempstring = String(temp);
  tempfeed->save(temp);
  delay(1000);
  tempfeedint->save(tempint);
    Serial.print("Sending -> ");
    delay(1000);
  Serial.println(hum);
   humfeed->save(hum);
   delay(1000);
   humfeedint->save(humint);
    Serial.println("Sent...");
    Serial.println("");
  // Blink the blue LED once for data sent confirmation
  digitalWrite(2, LOW);   // sets the LED on
  delay(100);
  digitalWrite(2, HIGH);   // sets the LED off
    // wait ten seconds (10000 milliseconds == 10 seconds)
    Serial.println("Pausing 10 Seconds...");
   }
  }
<!-- gh-comment-id:260399448 --> @dudesky71 commented on GitHub (Nov 14, 2016): <pre> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><font color="#000000">DHT</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><b><font color="#d35400">SPI</font></b><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><font color="#000000">ESP8266WiFi</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><font color="#000000">DNSServer</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><font color="#000000">WiFiManager</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#include</font> <font color="#005c5f">"AdafruitIO_WiFi.h"</font> <font color="#95a5a6">/************************ Example Starts Here *******************************/</font> <font color="#5e6d03">#define</font> <font color="#000000">IO_USERNAME</font> &nbsp;&nbsp;&nbsp;<font color="#005c5f">"xxxxxx"</font> <font color="#5e6d03">#define</font> <font color="#000000">IO_KEY</font> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#005c5f">"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"</font> <font color="#5e6d03">#define</font> <font color="#000000">WIFI_SSID</font> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#005c5f">""</font> <font color="#5e6d03">#define</font> <font color="#000000">WIFI_PASS</font> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#005c5f">""</font> <font color="#5e6d03">#define</font> <font color="#000000">DHTPIN</font> <font color="#000000">4</font> &nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">// what digital pin we're connected to. Mapped to pin D2 on WeMOS</font> <font color="#5e6d03">#define</font> <font color="#000000">DHTTYPE</font> <font color="#000000">DHT11</font> &nbsp;&nbsp;<font color="#434f54">// DHT 11</font> <font color="#434f54">//#define BLYNK_PRINT Serial &nbsp;&nbsp;&nbsp;// Comment this out to disable prints and save space</font> <font color="#5e6d03">#define</font> <font color="#000000">ANALOG_PIN</font> <font color="#000000">A0</font> &nbsp;<font color="#434f54">// analog pin 0</font> <font color="#434f54">// Initialize DHT sensor.</font> <font color="#000000">DHT</font> <font color="#000000">dht</font><font color="#000000">(</font><font color="#000000">DHTPIN</font><font color="#434f54">,</font> <font color="#000000">DHTTYPE</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#000000">AdafruitIO_WiFi</font> <font color="#000000">io</font><font color="#000000">(</font><font color="#000000">IO_USERNAME</font><font color="#434f54">,</font> <font color="#000000">IO_KEY</font><font color="#434f54">,</font> <font color="#000000">WIFI_SSID</font><font color="#434f54">,</font> <font color="#000000">WIFI_PASS</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#434f54">// analog state</font> <font color="#00979c">int</font> <font color="#000000">currentwetness</font> <font color="#434f54">=</font> <font color="#000000">0</font><font color="#000000">;</font> <font color="#00979c">int</font> <font color="#000000">lastwetness</font> <font color="#434f54">=</font> <font color="#434f54">-</font><font color="#000000">1</font><font color="#000000">;</font> <font color="#00979c">int</font> <font color="#000000">tempint</font> <font color="#434f54">=</font> <font color="#000000">0</font><font color="#000000">;</font> <font color="#00979c">int</font> <font color="#000000">humint</font> <font color="#434f54">=</font> <font color="#000000">0</font><font color="#000000">;</font> <font color="#00979c">unsigned</font> <font color="#00979c">long</font> <font color="#000000">previousMillis</font> <font color="#434f54">=</font> <font color="#000000">0</font><font color="#000000">;</font> <font color="#00979c">const</font> <font color="#00979c">long</font> <font color="#000000">interval</font> <font color="#434f54">=</font> <font color="#000000">10000</font><font color="#000000">;</font> <font color="#434f54">// set up the 'analog' feed</font> <font color="#000000">AdafruitIO_Feed</font> <font color="#434f54">*</font><font color="#000000">wetnessfeed</font> <font color="#434f54">=</font> <font color="#000000">io</font><font color="#434f54">.</font><font color="#000000">feed</font><font color="#000000">(</font><font color="#005c5f">"wetness"</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#434f54">// set up the 'DHT' feed float</font> <font color="#000000">AdafruitIO_Feed</font> <font color="#434f54">*</font><font color="#000000">tempfeed</font> <font color="#434f54">=</font> <font color="#000000">io</font><font color="#434f54">.</font><font color="#000000">feed</font><font color="#000000">(</font><font color="#005c5f">"temp"</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#000000">AdafruitIO_Feed</font> <font color="#434f54">*</font><font color="#000000">humfeed</font> <font color="#434f54">=</font> <font color="#000000">io</font><font color="#434f54">.</font><font color="#000000">feed</font><font color="#000000">(</font><font color="#005c5f">"hum"</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#434f54">// set up the 'DHT' feed integer</font> <font color="#000000">AdafruitIO_Feed</font> <font color="#434f54">*</font><font color="#000000">tempfeedint</font> <font color="#434f54">=</font> <font color="#000000">io</font><font color="#434f54">.</font><font color="#000000">feed</font><font color="#000000">(</font><font color="#005c5f">"tempint"</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#000000">AdafruitIO_Feed</font> <font color="#434f54">*</font><font color="#000000">humfeedint</font> <font color="#434f54">=</font> <font color="#000000">io</font><font color="#434f54">.</font><font color="#000000">feed</font><font color="#000000">(</font><font color="#005c5f">"humint"</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#00979c">void</font> <font color="#5e6d03">setup</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;<font color="#434f54">// start the serial connection</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">begin</font><font color="#000000">(</font><font color="#000000">9600</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">""</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><b><font color="#d35400">WiFi</font></b><font color="#434f54">.</font><font color="#d35400">SSID</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><b><font color="#d35400">WiFi</font></b><font color="#434f54">.</font><font color="#000000">psk</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#434f54">// put your setup code here, to run once:</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//WiFiManager</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//Local intialization. Once its business is done, there is no need to keep it around</font> &nbsp;&nbsp;&nbsp;<font color="#000000">WiFiManager</font> <font color="#000000">wifiManager</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//reset saved settings</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//wifiManager.resetSettings();</font> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#434f54">//set custom ip for portal</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//fetches ssid and pass from eeprom and tries to connect</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//if it does not connect it starts an access point with the specified name</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//here &nbsp;"AutoConnectAP"</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//and goes into a blocking loop awaiting configuration</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//wifiManager.autoConnect("Test-DongleAP");</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">//or use this for auto generated name ESP + ChipID</font> &nbsp;&nbsp;&nbsp;<font color="#000000">wifiManager</font><font color="#434f54">.</font><font color="#000000">autoConnect</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#434f54">//if you get here you have connected to the WiFi</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"Connected to WiFi Network..."</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">dht</font><font color="#434f54">.</font><font color="#d35400">begin</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">100</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// wait for serial monitor to open</font> &nbsp;<font color="#5e6d03">while</font><font color="#000000">(</font><font color="#434f54">!</font> <b><font color="#d35400">Serial</font></b><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// connect to io.adafruit.com</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">""</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"Connecting to Adafruit IO"</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">io</font><font color="#434f54">.</font><font color="#d35400">connect</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// wait for a connection</font> &nbsp;<font color="#5e6d03">while</font><font color="#000000">(</font><font color="#000000">io</font><font color="#434f54">.</font><font color="#d35400">status</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#434f54">&lt;</font> <font color="#000000">AIO_CONNECTED</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"."</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">500</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">}</font> &nbsp;<font color="#434f54">// we are connected</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#000000">io</font><font color="#434f54">.</font><font color="#000000">statusText</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">pinMode</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">OUTPUT</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#434f54">// set blue led pin to output</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">// Show Connection Status and IP Address</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">""</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"WiFi connected"</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp; &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"IP address: "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><b><font color="#d35400">WiFi</font></b><font color="#434f54">.</font><font color="#d35400">localIP</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp; &nbsp;<font color="#434f54">// Blink the blue LED three times for WiFi connection confirmation</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">LOW</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED on</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">50</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED off</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">200</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">LOW</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED on</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">50</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED off</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">200</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">LOW</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED on</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">50</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED off</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">""</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#000000">}</font> <font color="#00979c">void</font> <font color="#5e6d03">loop</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;<font color="#000000">io</font><font color="#434f54">.</font><font color="#d35400">run</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// io.run(); is required for all sketches.</font> &nbsp;<font color="#434f54">// it should always be present at the top of your loop</font> &nbsp;<font color="#434f54">// function. it keeps the client connected to</font> &nbsp;<font color="#434f54">// io.adafruit.com, and processes any incoming data.</font> &nbsp;<font color="#00979c">unsigned</font> <font color="#00979c">long</font> <font color="#000000">currentMillis</font> <font color="#434f54">=</font> <font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#5e6d03">if</font><font color="#000000">(</font><font color="#000000">currentMillis</font> <font color="#434f54">-</font> <font color="#000000">previousMillis</font> <font color="#434f54">&gt;=</font> <font color="#000000">interval</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;&nbsp;&nbsp;<font color="#000000">previousMillis</font> <font color="#434f54">=</font> <font color="#000000">currentMillis</font><font color="#000000">;</font> &nbsp; &nbsp;<font color="#434f54">// grab the current state of the photocell</font> &nbsp;<font color="#000000">currentwetness</font> <font color="#434f54">=</font> <font color="#d35400">analogRead</font><font color="#000000">(</font><font color="#000000">ANALOG_PIN</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// return if the value hasn't changed</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"Reading ADC..."</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">//if(currentwetness == lastwetness)</font> &nbsp;<font color="#434f54">// &nbsp;return;</font> &nbsp;<font color="#434f54">// store last analog state</font> &nbsp;<font color="#000000">lastwetness</font> <font color="#434f54">=</font> <font color="#000000">currentwetness</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">// Reading temperature or humidity takes about 250 milliseconds!</font> &nbsp;<font color="#434f54">// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"Reading DHT..."</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#00979c">float</font> <font color="#000000">hum</font> <font color="#434f54">=</font> <font color="#000000">dht</font><font color="#434f54">.</font><font color="#000000">readHumidity</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">humint</font> <font color="#434f54">=</font> <font color="#000000">hum</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">// wait half second (1000 milliseconds == 1 second)</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">500</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// Read temperature as Celsius (the default)</font> &nbsp;<font color="#434f54">// float temp = dht.readTemperature();</font> &nbsp;<font color="#434f54">// Read temperature as Fahrenheit (isFahrenheit = true)</font> &nbsp;<font color="#00979c">float</font> <font color="#000000">temp</font> <font color="#434f54">=</font> <font color="#000000">dht</font><font color="#434f54">.</font><font color="#d35400">readTemperature</font><font color="#000000">(</font><font color="#00979c">true</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">tempint</font> <font color="#434f54">=</font> <font color="#000000">temp</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// float f = dht.readTemperature(true);</font> &nbsp;<font color="#434f54">// wait half second (1000 milliseconds == 1 second)</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">500</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// Check if any reads failed and exit early (to try again).</font> &nbsp;<font color="#434f54">// &nbsp;if (isnan(hum) || isnan(temp) || isnan(f)) {</font> &nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">isnan</font><font color="#000000">(</font><font color="#000000">hum</font><font color="#000000">)</font> <font color="#434f54">||</font> <font color="#000000">isnan</font><font color="#000000">(</font><font color="#000000">temp</font><font color="#000000">)</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"Failed to read from DHT sensor!"</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<font color="#5e6d03">return</font><font color="#000000">;</font> &nbsp;<font color="#000000">}</font> &nbsp;<font color="#434f54">// Compute heat index in Fahrenheit (the default)</font> &nbsp;<font color="#434f54">// float hif = dht.computeHeatIndex(f, hum);</font> &nbsp;<font color="#434f54">// Compute heat index in Celsius (isFahreheit = false)</font> &nbsp;<font color="#434f54">// float hic = dht.computeHeatIndex(temp, hum, false);</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"Humidity: "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#000000">hum</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">" %\t"</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"Temperature: "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#000000">temp</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">" *F "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">//Serial.print(f);</font> &nbsp;<font color="#434f54">//Serial.print(" *F\t");</font> &nbsp;<font color="#434f54">//Serial.print("Heat index: ");</font> &nbsp;<font color="#434f54">//Serial.print(hic);</font> &nbsp;<font color="#434f54">//Serial.print(" *C ");</font> &nbsp;<font color="#434f54">//Serial.print(hif);</font> &nbsp;<font color="#434f54">//Serial.println(" *F");</font> &nbsp; &nbsp;<font color="#434f54">// save the current state to the analog feed</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"Sending -&gt; "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#5e6d03">if</font> <font color="#000000">(</font><font color="#000000">currentwetness</font> <font color="#434f54">&lt;=</font> <font color="#000000">10</font><font color="#000000">)</font><font color="#000000">currentwetness</font> <font color="#434f54">=</font> <font color="#000000">0</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#000000">currentwetness</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">wetnessfeed</font><font color="#434f54">-</font><font color="#434f54">&gt;</font><font color="#000000">save</font><font color="#000000">(</font><font color="#000000">currentwetness</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">1000</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"Sending -&gt; "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#000000">temp</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#00979c">String</font> <font color="#000000">tempstring</font> <font color="#434f54">=</font> <font color="#00979c">String</font><font color="#000000">(</font><font color="#000000">temp</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">tempfeed</font><font color="#434f54">-</font><font color="#434f54">&gt;</font><font color="#000000">save</font><font color="#000000">(</font><font color="#000000">temp</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">1000</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">tempfeedint</font><font color="#434f54">-</font><font color="#434f54">&gt;</font><font color="#000000">save</font><font color="#000000">(</font><font color="#000000">tempint</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">print</font><font color="#000000">(</font><font color="#005c5f">"Sending -&gt; "</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">1000</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#000000">hum</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#000000">humfeed</font><font color="#434f54">-</font><font color="#434f54">&gt;</font><font color="#000000">save</font><font color="#000000">(</font><font color="#000000">hum</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">1000</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#000000">humfeedint</font><font color="#434f54">-</font><font color="#434f54">&gt;</font><font color="#000000">save</font><font color="#000000">(</font><font color="#000000">humint</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"Sent..."</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">""</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// Blink the blue LED once for data sent confirmation</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">LOW</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED on</font> &nbsp;<font color="#d35400">delay</font><font color="#000000">(</font><font color="#000000">100</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#d35400">digitalWrite</font><font color="#000000">(</font><font color="#000000">2</font><font color="#434f54">,</font> <font color="#00979c">HIGH</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#434f54">// sets the LED off</font> &nbsp;&nbsp;&nbsp;<font color="#434f54">// wait ten seconds (10000 milliseconds == 10 seconds)</font> &nbsp;&nbsp;&nbsp;<b><font color="#d35400">Serial</font></b><font color="#434f54">.</font><font color="#d35400">println</font><font color="#000000">(</font><font color="#005c5f">"Pausing 10 Seconds..."</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;&nbsp;<font color="#000000">}</font> &nbsp;<font color="#000000">}</font> </pre>
Author
Owner

@dudesky71 commented on GitHub (Nov 14, 2016):

any ideas @tzapu ?
Thank You for looking.

<!-- gh-comment-id:260413545 --> @dudesky71 commented on GitHub (Nov 14, 2016): any ideas @tzapu ? Thank You for looking.
Author
Owner

@tablatronix commented on GitHub (Nov 14, 2016):

I would suggest reducing this to a minimum amount of code to reproduce, there is just too much going on, it makes for a bad test. Start pulling everything out but the 2 things being tested

<!-- gh-comment-id:260432779 --> @tablatronix commented on GitHub (Nov 14, 2016): I would suggest reducing this to a minimum amount of code to reproduce, there is just too much going on, it makes for a bad test. Start pulling everything out but the 2 things being tested
Author
Owner

@dudesky71 commented on GitHub (Nov 14, 2016):

this is a super simple sketch. There is hardly anything going on as-is. There are 3 data pushes to Adafruit's server. That is all. Anything less in the code and it will not be doing anything... There are alot of comments but it explains what is going on. Again, it runs fine without WiFi manager.

<!-- gh-comment-id:260437154 --> @dudesky71 commented on GitHub (Nov 14, 2016): this is a super simple sketch. There is hardly anything going on as-is. There are 3 data pushes to Adafruit's server. That is all. Anything less in the code and it will not be doing anything... There are alot of comments but it explains what is going on. Again, it runs fine without WiFi manager.
Author
Owner

@tablatronix commented on GitHub (Nov 14, 2016):

well no
This would be a simple sketch, minimal code required
or use the examples and add to them, you have spi dht libraries etc.

#include <ESP8266WiFi.h>
#include <WiFiManager.h>
#include "AdafruitIO_WiFi.h"

/************************ Example Starts Here *******************************/

#define IO_USERNAME    "xxxxxx"
#define IO_KEY         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

#define WIFI_SSID      ""
#define WIFI_PASS      ""

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

AdafruitIO_Feed *testfeed = io.feed("test");

void setup() {
  Serial.begin(115200);
  Serial.println("");

  WiFiManager wifiManager;
  wifiManager.autoConnect();

  WiFi.printDiag(Serial);

  // connect to io.adafruit.com
  Serial.println("");
  Serial.print("Connecting to Adafruit IO");
  io.connect();

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  Serial.print("adafruit io connected");
  Serial.println(io.statusText());
}

void loop() {
  io.run();
  testfeed->save(millis());
  delay(2000);
}

Either way i doubt this is going to work with wifimanager, since this library handles wifi for you, you might have to use the adafruit mqtt library directly.

<!-- gh-comment-id:260446424 --> @tablatronix commented on GitHub (Nov 14, 2016): well no This would be a simple sketch, minimal code required or use the examples and add to them, you have spi dht libraries etc. ``` #include <ESP8266WiFi.h> #include <WiFiManager.h> #include "AdafruitIO_WiFi.h" /************************ Example Starts Here *******************************/ #define IO_USERNAME "xxxxxx" #define IO_KEY "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #define WIFI_SSID "" #define WIFI_PASS "" AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS); AdafruitIO_Feed *testfeed = io.feed("test"); void setup() { Serial.begin(115200); Serial.println(""); WiFiManager wifiManager; wifiManager.autoConnect(); WiFi.printDiag(Serial); // connect to io.adafruit.com Serial.println(""); Serial.print("Connecting to Adafruit IO"); io.connect(); // wait for a connection while(io.status() < AIO_CONNECTED) { Serial.print("."); delay(500); } Serial.print("adafruit io connected"); Serial.println(io.statusText()); } void loop() { io.run(); testfeed->save(millis()); delay(2000); } ``` Either way i doubt this is going to work with wifimanager, since this library handles wifi for you, you might have to use the adafruit mqtt library directly.
Author
Owner

@dudesky71 commented on GitHub (Nov 14, 2016):

ok thank you

<!-- gh-comment-id:260449493 --> @dudesky71 commented on GitHub (Nov 14, 2016): ok thank you
Author
Owner

@dudesky71 commented on GitHub (Nov 16, 2016):

I just tried another WeMos module. I've tried a HUZZAH. I've tried the basic MQTT client and they all lock up or reset the module within minutes of running. Please see the log and dump below... Can you help with this? @tzapu @tablatronix

Thank You

Sending counter val 248...OK!

Sending counter val 249...OK!

Sending counter val 250...OK!

Sending counter val 251...OK!

Sending counter val 252...OK!

Sending counter val 253...OK!

Sending counter val 254...OK!

Sending counter val 255...OK!

Sending counter val 256...OK!

Sending counter val 257...OK!

Sending counter val 258...Failed
Connecting to MQTT... Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...

MQTT Connected!

Sending counter val 259...OK!

Sending counter val 260...Failed
Connecting to MQTT...
MQTT Connected!

Sending counter val 261...Failed
Connecting to MQTT...
MQTT Connected!

Sending counter val 262...Failed
Connecting to MQTT... Connection failed
Retrying MQTT connection in 5 seconds...

MQTT Connected!

Sending counter val 263...OK!

Sending counter val 264...OK!
Connecting to MQTT... Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...
Connection failed
Retrying MQTT connection in 5 seconds...

Soft WDT reset

ctx: cont
sp: 3ffef710 end: 3ffef900 offset: 01b0

stack>>>
3ffef8c0: 00000001 3ffee638 3ffee814 40201e32
3ffef8d0: 3fffdad0 00000000 3ffee8c8 40201e88
3ffef8e0: 3fffdad0 00000000 3ffee8c8 40203844
3ffef8f0: feefeffe feefeffe 3ffee8e0 40100718
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(1,7)

ets Jan 8 2013,rst cause:4, boot mode:(1,7)

wdt reset

<!-- gh-comment-id:260967960 --> @dudesky71 commented on GitHub (Nov 16, 2016): I just tried another WeMos module. I've tried a HUZZAH. I've tried the basic MQTT client and they all lock up or reset the module within minutes of running. Please see the log and dump below... Can you help with this? @tzapu @tablatronix Thank You Sending counter val 248...OK! Sending counter val 249...OK! Sending counter val 250...OK! Sending counter val 251...OK! Sending counter val 252...OK! Sending counter val 253...OK! Sending counter val 254...OK! Sending counter val 255...OK! Sending counter val 256...OK! Sending counter val 257...OK! Sending counter val 258...Failed Connecting to MQTT... Connection failed Retrying MQTT connection in 5 seconds... Connection failed Retrying MQTT connection in 5 seconds... MQTT Connected! Sending counter val 259...OK! Sending counter val 260...Failed Connecting to MQTT... MQTT Connected! Sending counter val 261...Failed Connecting to MQTT... MQTT Connected! Sending counter val 262...Failed Connecting to MQTT... Connection failed Retrying MQTT connection in 5 seconds... MQTT Connected! Sending counter val 263...OK! Sending counter val 264...OK! Connecting to MQTT... Connection failed Retrying MQTT connection in 5 seconds... Connection failed Retrying MQTT connection in 5 seconds... Connection failed Retrying MQTT connection in 5 seconds... Soft WDT reset ctx: cont sp: 3ffef710 end: 3ffef900 offset: 01b0 > > > stack>>> > > > 3ffef8c0: 00000001 3ffee638 3ffee814 40201e32 > > > 3ffef8d0: 3fffdad0 00000000 3ffee8c8 40201e88 > > > 3ffef8e0: 3fffdad0 00000000 3ffee8c8 40203844 > > > 3ffef8f0: feefeffe feefeffe 3ffee8e0 40100718 > > > <<<stack<<< ets Jan 8 2013,rst cause:2, boot mode:(1,7) ets Jan 8 2013,rst cause:4, boot mode:(1,7) wdt reset
Author
Owner

@tzapu commented on GitHub (Nov 16, 2016):

that looks more like an error related to mqtt
there is an esp8266 exception decoder floating around somehwre you can install and see exactly where the error came from
good luck

<!-- gh-comment-id:260993817 --> @tzapu commented on GitHub (Nov 16, 2016): that looks more like an error related to mqtt there is an esp8266 exception decoder floating around somehwre you can install and see exactly where the error came from good luck
Author
Owner

@tablatronix commented on GitHub (Nov 16, 2016):

not sure, i am using the adafruit mqtt anon_time example , it works fine.

Its not an exception, soft wdt reset usually means something is restarting it

<!-- gh-comment-id:261003701 --> @tablatronix commented on GitHub (Nov 16, 2016): not sure, i am using the adafruit mqtt anon_time example , it works fine. Its not an exception, soft wdt reset usually means something is restarting it
Author
Owner

@tablatronix commented on GitHub (Nov 16, 2016):

usually a infinite loop tripping the watchdog. check for rogue while loops without a delay or yield()

<!-- gh-comment-id:261016508 --> @tablatronix commented on GitHub (Nov 16, 2016): usually a infinite loop tripping the `watchdog`. check for rogue while loops without a delay or yield()
Author
Owner

@dudesky71 commented on GitHub (Nov 16, 2016):

here is the basic sketch...
`include "ESP8266WiFi.h"
include "Adafruit_MQTT.h"
include "Adafruit_MQTT_Client.h"

/************************* WiFi Access Point *********************************/

#define WLAN_SSID "...your SSID..."
#define WLAN_PASS "...your password..."

/************************* Adafruit.io Setup *********************************/

#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883 // use 8883 for SSL
#define AIO_USERNAME "...your AIO username (see https://accounts.adafruit.com)..."
#define AIO_KEY "...your AIO key..."

/************ Global State (you don't need to change this!) ******************/

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
// or... use WiFiFlientSecure for SSL
//WiFiClientSecure client;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);

/****************************** Feeds ***************************************/

// Setup a feed called 'photocell' for publishing.
// Notice MQTT paths for AIO follow the form: /feeds/
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/photocell");

// Setup a feed called 'onoff' for subscribing to changes.
Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/onoff");

/*************************** Sketch Code ************************************/

// Bug workaround for Arduino 1.6.6, it seems to need a function declaration
// for some reason (only affects ESP8266, likely an arduino-builder bug).
void MQTT_connect();

void setup() {
Serial.begin(115200);
delay(10);

Serial.println(F("Adafruit MQTT demo"));

// Connect to WiFi access point.
Serial.println(); Serial.println();
Serial.print("Connecting to ");
Serial.println(WLAN_SSID);

WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();

Serial.println("WiFi connected");
Serial.println("IP address: "); Serial.println(WiFi.localIP());

// Setup MQTT subscription for onoff feed.
mqtt.subscribe(&onoffbutton);
}

uint32_t x=0;

void loop() {
// Ensure the connection to the MQTT server is alive (this will make the first
// connection and automatically reconnect when disconnected). See the MQTT_connect
// function definition further below.
MQTT_connect();

// this is our 'wait for incoming subscription packets' busy subloop
// try to spend your time here

Adafruit_MQTT_Subscribe *subscription;
while ((subscription = mqtt.readSubscription(5000))) {
if (subscription == &onoffbutton) {
Serial.print(F("Got: "));
Serial.println((char *)onoffbutton.lastread);
}
}

// Now we can publish stuff!
Serial.print(F("\nSending photocell val "));
Serial.print(x);
Serial.print("...");
if (! photocell.publish(x++)) {
Serial.println(F("Failed"));
} else {
Serial.println(F("OK!"));
}

// ping the server to keep the mqtt connection alive
// NOT required if you are publishing once every KEEPALIVE seconds
/*
if(! mqtt.ping()) {
mqtt.disconnect();
}
*/
}

// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {
int8_t ret;

// Stop if already connected.
if (mqtt.connected()) {
return;
}

Serial.print("Connecting to MQTT... ");

uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
Serial.println(mqtt.connectErrorString(ret));
Serial.println("Retrying MQTT connection in 5 seconds...");
mqtt.disconnect();
delay(5000); // wait 5 seconds
retries--;
if (retries == 0) {
// basically die and wait for WDT to reset me
while (1);
}
}
Serial.println("MQTT Connected!");`

<!-- gh-comment-id:261017913 --> @dudesky71 commented on GitHub (Nov 16, 2016): here is the basic sketch... `include "ESP8266WiFi.h" include "Adafruit_MQTT.h" include "Adafruit_MQTT_Client.h" /************************\* WiFi Access Point *********************************/ #define WLAN_SSID "...your SSID..." #define WLAN_PASS "...your password..." /************************\* Adafruit.io Setup *********************************/ #define AIO_SERVER "io.adafruit.com" #define AIO_SERVERPORT 1883 // use 8883 for SSL #define AIO_USERNAME "...your AIO username (see https://accounts.adafruit.com)..." #define AIO_KEY "...your AIO key..." /***********\* Global State (you don't need to change this!) ******************/ // Create an ESP8266 WiFiClient class to connect to the MQTT server. WiFiClient client; // or... use WiFiFlientSecure for SSL //WiFiClientSecure client; // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); /*****************************\* Feeds ***************************************/ // Setup a feed called 'photocell' for publishing. // Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname> Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/photocell"); // Setup a feed called 'onoff' for subscribing to changes. Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/onoff"); /**************************\* Sketch Code ************************************/ // Bug workaround for Arduino 1.6.6, it seems to need a function declaration // for some reason (only affects ESP8266, likely an arduino-builder bug). void MQTT_connect(); void setup() { Serial.begin(115200); delay(10); Serial.println(F("Adafruit MQTT demo")); // Connect to WiFi access point. Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(WLAN_SSID); WiFi.begin(WLAN_SSID, WLAN_PASS); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); // Setup MQTT subscription for onoff feed. mqtt.subscribe(&onoffbutton); } uint32_t x=0; void loop() { // Ensure the connection to the MQTT server is alive (this will make the first // connection and automatically reconnect when disconnected). See the MQTT_connect // function definition further below. MQTT_connect(); // this is our 'wait for incoming subscription packets' busy subloop // try to spend your time here Adafruit_MQTT_Subscribe *subscription; while ((subscription = mqtt.readSubscription(5000))) { if (subscription == &onoffbutton) { Serial.print(F("Got: ")); Serial.println((char *)onoffbutton.lastread); } } // Now we can publish stuff! Serial.print(F("\nSending photocell val ")); Serial.print(x); Serial.print("..."); if (! photocell.publish(x++)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } // ping the server to keep the mqtt connection alive // NOT required if you are publishing once every KEEPALIVE seconds /* if(! mqtt.ping()) { mqtt.disconnect(); } */ } // Function to connect and reconnect as necessary to the MQTT server. // Should be called in the loop function and it will take care if connecting. void MQTT_connect() { int8_t ret; // Stop if already connected. if (mqtt.connected()) { return; } Serial.print("Connecting to MQTT... "); uint8_t retries = 3; while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected Serial.println(mqtt.connectErrorString(ret)); Serial.println("Retrying MQTT connection in 5 seconds..."); mqtt.disconnect(); delay(5000); // wait 5 seconds retries--; if (retries == 0) { // basically die and wait for WDT to reset me while (1); } } Serial.println("MQTT Connected!");`
Author
Owner

@tzapu commented on GitHub (Nov 16, 2016):

this

Soft WDT reset

ctx: cont 
sp: 3ffef710 end: 3ffef900 offset: 01b0

stack>>>
3ffef8c0: 00000001 3ffee638 3ffee814 40201e32

3ffef8d0: 3fffdad0 00000000 3ffee8c8 40201e88

3ffef8e0: 3fffdad0 00000000 3ffee8c8 40203844

3ffef8f0: feefeffe feefeffe 3ffee8e0 40100718

<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(1,7)

ets Jan 8 2013,rst cause:4, boot mode:(1,7)

wdt reset

looks like an watchdog triggered reset, so there is a problem, not just a reset

<!-- gh-comment-id:261025090 --> @tzapu commented on GitHub (Nov 16, 2016): this ``` Soft WDT reset ctx: cont sp: 3ffef710 end: 3ffef900 offset: 01b0 stack>>> 3ffef8c0: 00000001 3ffee638 3ffee814 40201e32 3ffef8d0: 3fffdad0 00000000 3ffee8c8 40201e88 3ffef8e0: 3fffdad0 00000000 3ffee8c8 40203844 3ffef8f0: feefeffe feefeffe 3ffee8e0 40100718 <<<stack<<< ets Jan 8 2013,rst cause:2, boot mode:(1,7) ets Jan 8 2013,rst cause:4, boot mode:(1,7) wdt reset ``` looks like an watchdog triggered reset, so there is a problem, not just a reset
Author
Owner

@tablatronix commented on GitHub (Nov 16, 2016):

I am gonna guess this
So your mqtt is timing out or failing and this is resetting your board.

       if (retries == 0) {
         // basically die and wait for WDT to reset me
        Serial.println("MQTT retry FAIL, rebooting."); // <--- add this to debug
         while (1);
       }

Try increasing that retry count, or find out why your connection is dropping out

<!-- gh-comment-id:261037108 --> @tablatronix commented on GitHub (Nov 16, 2016): I am gonna guess this So your mqtt is timing out or failing and this is resetting your board. ``` if (retries == 0) { // basically die and wait for WDT to reset me Serial.println("MQTT retry FAIL, rebooting."); // <--- add this to debug while (1); } ``` Try increasing that retry count, or find out why your connection is dropping out
Author
Owner

@dudesky71 commented on GitHub (Nov 16, 2016):

I just changed over to a completely different communication method used by thinger.io

Here is the example sketch. It is super simple. It still locks up the 8266 modules. Seems like its a core 8266 problem...?

#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>
#define USERNAME "your_user_name"
#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"
#define SSID "your_wifi_ssid"
#define SSID_PASSWORD "your_wifi_ssid_password"
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
  pinMode(BUILTIN_LED, OUTPUT);
  thing.add_wifi(SSID, SSID_PASSWORD);
  // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
  thing["led"] << digitalPin(BUILTIN_LED);
  // resource output example (i.e. reading a sensor value)
  thing["millis"] >> outputValue(millis());
  // more details at http://docs.thinger.io/arduino/
}
void loop() {
  thing.handle();
}
<!-- gh-comment-id:261063962 --> @dudesky71 commented on GitHub (Nov 16, 2016): I just changed over to a completely different communication method used by thinger.io Here is the example sketch. It is super simple. It still locks up the 8266 modules. Seems like its a core 8266 problem...? <pre> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><font color="#000000">ESP8266WiFi</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#include</font> <font color="#434f54">&lt;</font><font color="#000000">ThingerESP8266</font><font color="#434f54">.</font><font color="#000000">h</font><font color="#434f54">&gt;</font> <font color="#5e6d03">#define</font> <font color="#000000">USERNAME</font> <font color="#005c5f">"your_user_name"</font> <font color="#5e6d03">#define</font> <font color="#000000">DEVICE_ID</font> <font color="#005c5f">"your_device_id"</font> <font color="#5e6d03">#define</font> <font color="#000000">DEVICE_CREDENTIAL</font> <font color="#005c5f">"your_device_credential"</font> <font color="#5e6d03">#define</font> <font color="#d35400">SSID</font> <font color="#005c5f">"your_wifi_ssid"</font> <font color="#5e6d03">#define</font> <font color="#000000">SSID_PASSWORD</font> <font color="#005c5f">"your_wifi_ssid_password"</font> <font color="#000000">ThingerESP8266</font> <font color="#000000">thing</font><font color="#000000">(</font><font color="#000000">USERNAME</font><font color="#434f54">,</font> <font color="#000000">DEVICE_ID</font><font color="#434f54">,</font> <font color="#000000">DEVICE_CREDENTIAL</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#00979c">void</font> <font color="#5e6d03">setup</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;<font color="#d35400">pinMode</font><font color="#000000">(</font><font color="#000000">BUILTIN_LED</font><font color="#434f54">,</font> <font color="#00979c">OUTPUT</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#000000">thing</font><font color="#434f54">.</font><font color="#000000">add_wifi</font><font color="#000000">(</font><font color="#d35400">SSID</font><font color="#434f54">,</font> <font color="#000000">SSID_PASSWORD</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)</font> &nbsp;<font color="#000000">thing</font><font color="#000000">[</font><font color="#005c5f">"led"</font><font color="#000000">]</font> <font color="#434f54">&lt;&lt;</font> <font color="#000000">digitalPin</font><font color="#000000">(</font><font color="#000000">BUILTIN_LED</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// resource output example (i.e. reading a sensor value)</font> &nbsp;<font color="#000000">thing</font><font color="#000000">[</font><font color="#005c5f">"millis"</font><font color="#000000">]</font> <font color="#434f54">&gt;&gt;</font> <font color="#000000">outputValue</font><font color="#000000">(</font><font color="#d35400">millis</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">)</font><font color="#000000">;</font> &nbsp;<font color="#434f54">// more details at </font><u><font color="#434f54">http://docs.thinger.io/arduino/</font></u><font color="#434f54"></font> <font color="#000000">}</font> <font color="#00979c">void</font> <font color="#5e6d03">loop</font><font color="#000000">(</font><font color="#000000">)</font> <font color="#000000">{</font> &nbsp;<font color="#000000">thing</font><font color="#434f54">.</font><font color="#000000">handle</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">;</font> <font color="#000000">}</font> </pre>
Author
Owner

@tablatronix commented on GitHub (Nov 16, 2016):

Are you running wifimanager all the time ?

<!-- gh-comment-id:261071729 --> @tablatronix commented on GitHub (Nov 16, 2016): Are you running wifimanager all the time ?
Author
Owner

@dudesky71 commented on GitHub (Nov 16, 2016):

Yes. Is there a way to shut it down after the credentials get saved?

<!-- gh-comment-id:261073262 --> @dudesky71 commented on GitHub (Nov 16, 2016): Yes. Is there a way to shut it down after the credentials get saved?
Author
Owner

@tablatronix commented on GitHub (Nov 16, 2016):

I was testing with this

/***************************************************
  Adafruit MQTT Library ESP8266 Adafruit IO Anonymous Time Query

  Must use the latest version of ESP8266 Arduino from:
    https://github.com/esp8266/Arduino

  Works great with Adafruit's Huzzah ESP board & Feather
  ----> https://www.adafruit.com/product/2471
  ----> https://www.adafruit.com/products/2821

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/
#include <ESP8266WiFi.h>
#include <WiFiManager.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"

/************************* WiFi Access Point *********************************/
#define WLAN_SSID       "wlanmtsu"
#define WLAN_PASS       ""

/************************* Adafruit.io Setup *********************************/
#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  8883

WiFiClientSecure client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT);

Adafruit_MQTT_Subscribe timefeed = Adafruit_MQTT_Subscribe(&mqtt, "time/seconds");

// set timezone offset from UTC
int timeZone = -5; // UTC - 4 eastern daylight time (nyc)
int interval = 4; // trigger every X hours

int last_min = -1;

void timecallback(uint32_t current) {
  // adjust to local time zone
  current += (timeZone * 60 * 60);
  int curr_hour = (current / 60 / 60) % 24;
  int curr_min  = (current / 60 ) % 60;
  int curr_sec  = (current) % 60;

  Serial.print("Time: "); 
  Serial.print(curr_hour); Serial.print(':'); 
  Serial.print(curr_min); Serial.print(':'); 
  Serial.println(curr_sec);

  // only trigger on minute change
  if(curr_min != last_min) {
    last_min = curr_min;

    Serial.println("This will print out every minute!");
    digitalWrite(BUILTIN_LED, LOW);
    delay(500);
    digitalWrite(BUILTIN_LED, HIGH);    
  }
}

void setup() {

  pinMode(BUILTIN_LED,OUTPUT);

  Serial.begin(115200);
  delay(10);
  Serial.println("");
  Serial.print(F("\nAdafruit IO anonymous Time Demo"));

  WiFi.printDiag(Serial);

    WiFiManager wifiManager;
    wifiManager.autoConnect();

  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println(F(" WiFi connected."));

  timefeed.setCallback(timecallback);
  mqtt.subscribe(&timefeed);

}

void loop() {

  // Ensure the connection to the MQTT server is alive (this will make the first
  // connection and automatically reconnect when disconnected).  See the MQTT_connect
  // function definition further below.
  MQTT_connect();

  // wait 10 seconds for subscription messages
  // since we have no other tasks in this example.
  mqtt.processPackets(10000);

  // keep the connection alive
  mqtt.ping();

}

// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {
  int8_t ret;

  // Stop if already connected.
  if (mqtt.connected()) {
    return;
  }

  Serial.print("Connecting to MQTT... ");

  uint8_t retries = 3;
  while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
       Serial.println(mqtt.connectErrorString(ret));
       Serial.println("Retrying MQTT connection in 5 seconds...");
       mqtt.disconnect();
       delay(5000);  // wait 5 seconds
       retries--;
       if (retries == 0) {
         // basically die and wait for WDT to reset me
        Serial.println("MQTT out of retries, restating ESP");
         while (1);
       }
  }

  Serial.println("MQTT Connected!");
}

I did have an SSID check but i just removed it, cause I was using the ken taylor branch, i have switched back to stable, so that is not necessary. I have a feeling it is something else causing too much work maybe dropping your connection, not sure thought. I was thinking maybe your esp was stuck in STA+AP mode and causing issues

<!-- gh-comment-id:261076266 --> @tablatronix commented on GitHub (Nov 16, 2016): I was testing with this ``` /*************************************************** Adafruit MQTT Library ESP8266 Adafruit IO Anonymous Time Query Must use the latest version of ESP8266 Arduino from: https://github.com/esp8266/Arduino Works great with Adafruit's Huzzah ESP board & Feather ----> https://www.adafruit.com/product/2471 ----> https://www.adafruit.com/products/2821 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Adafruit Industries. MIT license, all text above must be included in any redistribution ****************************************************/ #include <ESP8266WiFi.h> #include <WiFiManager.h> #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" /************************* WiFi Access Point *********************************/ #define WLAN_SSID "wlanmtsu" #define WLAN_PASS "" /************************* Adafruit.io Setup *********************************/ #define AIO_SERVER "io.adafruit.com" #define AIO_SERVERPORT 8883 WiFiClientSecure client; Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT); Adafruit_MQTT_Subscribe timefeed = Adafruit_MQTT_Subscribe(&mqtt, "time/seconds"); // set timezone offset from UTC int timeZone = -5; // UTC - 4 eastern daylight time (nyc) int interval = 4; // trigger every X hours int last_min = -1; void timecallback(uint32_t current) { // adjust to local time zone current += (timeZone * 60 * 60); int curr_hour = (current / 60 / 60) % 24; int curr_min = (current / 60 ) % 60; int curr_sec = (current) % 60; Serial.print("Time: "); Serial.print(curr_hour); Serial.print(':'); Serial.print(curr_min); Serial.print(':'); Serial.println(curr_sec); // only trigger on minute change if(curr_min != last_min) { last_min = curr_min; Serial.println("This will print out every minute!"); digitalWrite(BUILTIN_LED, LOW); delay(500); digitalWrite(BUILTIN_LED, HIGH); } } void setup() { pinMode(BUILTIN_LED,OUTPUT); Serial.begin(115200); delay(10); Serial.println(""); Serial.print(F("\nAdafruit IO anonymous Time Demo")); WiFi.printDiag(Serial); WiFiManager wifiManager; wifiManager.autoConnect(); while (WiFi.waitForConnectResult() != WL_CONNECTED) { delay(500); Serial.print(F(".")); } Serial.println(F(" WiFi connected.")); timefeed.setCallback(timecallback); mqtt.subscribe(&timefeed); } void loop() { // Ensure the connection to the MQTT server is alive (this will make the first // connection and automatically reconnect when disconnected). See the MQTT_connect // function definition further below. MQTT_connect(); // wait 10 seconds for subscription messages // since we have no other tasks in this example. mqtt.processPackets(10000); // keep the connection alive mqtt.ping(); } // Function to connect and reconnect as necessary to the MQTT server. // Should be called in the loop function and it will take care if connecting. void MQTT_connect() { int8_t ret; // Stop if already connected. if (mqtt.connected()) { return; } Serial.print("Connecting to MQTT... "); uint8_t retries = 3; while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected Serial.println(mqtt.connectErrorString(ret)); Serial.println("Retrying MQTT connection in 5 seconds..."); mqtt.disconnect(); delay(5000); // wait 5 seconds retries--; if (retries == 0) { // basically die and wait for WDT to reset me Serial.println("MQTT out of retries, restating ESP"); while (1); } } Serial.println("MQTT Connected!"); } ``` I did have an SSID check but i just removed it, cause I was using the ken taylor branch, i have switched back to stable, so that is not necessary. I have a feeling it is something else causing too much work maybe dropping your connection, not sure thought. I was thinking maybe your esp was stuck in STA+AP mode and causing issues
Author
Owner

@dudesky71 commented on GitHub (Nov 17, 2016):

I can see the AP drop offline so I don't think it is that.

<!-- gh-comment-id:261246122 --> @dudesky71 commented on GitHub (Nov 17, 2016): I can see the AP drop offline so I don't think it is that.
Author
Owner

@wyojustin commented on GitHub (Feb 12, 2018):

I had the same question using the 8266 Feather HUZZAH. I finally just bit the bullet and hacked the AdafruitIO_ESP8266.cpp code. One small change makes the code work.

  1. Include WiFi Mananger header file near the top of "AdafruitIO_ESP8266.cpp"
    `
    #ifdef ESP8266
    #include "AdafruitIO_ESP8266.h"
    #include <WiFiManager.h> // TJS: Hacked in for Mac's Klok

  2. Change _connect to read as below

void AdafruitIO_ESP8266::_connect()
{
   // TJS: Use WiFi Manager hack
  // ### hacked in for Mac's kock... and it worked!!!
  WiFiManager wifiManager;
  //wifiManager.resetSettings();// uncomment to forget previous wifi manager settings
  wifiManager.autoConnect("KLOK");
  Serial.println("yay connected");
/* // original code
  delay(100);
  WiFi.begin(_ssid, _pass);
  delay(100);
  _status = AIO_NET_DISCONNECTED;
*/
}
<!-- gh-comment-id:364804188 --> @wyojustin commented on GitHub (Feb 12, 2018): I had the same question using the 8266 Feather HUZZAH. I finally just bit the bullet and hacked the AdafruitIO_ESP8266.cpp code. One small change makes the code work. 1. Include WiFi Mananger header file near the top of "AdafruitIO_ESP8266.cpp" ` #ifdef ESP8266 #include "AdafruitIO_ESP8266.h" #include <WiFiManager.h> // TJS: Hacked in for Mac's Klok 2. Change _connect to read as below ``` void AdafruitIO_ESP8266::_connect() { // TJS: Use WiFi Manager hack // ### hacked in for Mac's kock... and it worked!!! WiFiManager wifiManager; //wifiManager.resetSettings();// uncomment to forget previous wifi manager settings wifiManager.autoConnect("KLOK"); Serial.println("yay connected"); /* // original code delay(100); WiFi.begin(_ssid, _pass); delay(100); _status = AIO_NET_DISCONNECTED; */ } ```
Author
Owner

@elanozturk commented on GitHub (Jun 13, 2018):

i find out the way,thank you.

  Serial.println(WiFi.SSID());
  Serial.println(WiFi.psk());
<!-- gh-comment-id:397025475 --> @elanozturk commented on GitHub (Jun 13, 2018): i find out the way,thank you. ``` Serial.println(WiFi.SSID()); Serial.println(WiFi.psk()); ```
Author
Owner

@gabi68 commented on GitHub (Nov 6, 2019):

Also,
Serial.printf("BSSID: %s\n", WiFi.BSSIDstr().c_str());
Good luck!!!

<!-- gh-comment-id:550294502 --> @gabi68 commented on GitHub (Nov 6, 2019): Also, Serial.printf("BSSID: %s\n", WiFi.BSSIDstr().c_str()); Good luck!!!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#203
No description provided.