ESP8266 wificonnect

I’ve used the ESP8266 Thing Dev Board a bit as a webserver. I usually set it up with a static IP, in the ESP8266. (I’m not using it as an access point, just an entity on a LAN managed by my ordinary router/ switch/ modem.

In the past… very well behaved. (I use something only gently tweaked from the “Station (and mDNS) Web Server” starting point provided by the demo code at…

https://learn.sparkfun.com/tutorials/es … web-server

(… though I leave out the “#include <ESP8266mDNS.h>” and related code, because I’m setting the IP address “by hand”, in the code.

===

Recently I did something very like what I’d done before. On the present project though, almost every time I upload the code, and the device auto-boots after the upload is complete, I DON’T get a connection to the WiFi Lan. (I get “Connecting to:” (plus my WiFi SSID), and the LED winks… but the connection still isn’t there minutes later.)

But! If I simply use the power switch on the Thing to do a quick power cycle, it comes up AND connects to the WiFi without fuss.

Any general ideas about what might be going on? (I tried sprinkling "delay(400)"s liberally through the code!)

For the very generous forum reader, the (messy, rough edges) code is as follows. (I really don’t expect anyone to dig too deeply, but formum members often complain if code isn’t posted!) (Some more comment after the code.)

What I’ve done is add just a few bits of stuff, and now the webpage served includes readings from a Sparkfun Si7021 Humidity/ Temperature breakout. (SEN-13763)

#include "SparkFun_Si7021_Breakout_Library.h"
#include <Wire.h>

float humidity = 0;
float tempf = 0;

Weather sensor;

//---------------------------------------------------------------
void setup()
{
    Serial.begin(9600);

    //Initialize the I2C sensors and ping them
    sensor.begin();
}// End of setup()

//---------------------------------------------------------------
void loop()
{
    //Get readings from all sensors
    getWeather();
    printInfo();
    delay(1000);
}//End of loop()

//---------------------------------------------------------------
void getWeather()
{
  humidity = sensor.getRH();
  tempf = sensor.getTempF();
  // Temperature is measured every time RH is requested.
  // It is faster, therefore, to read it from previous RH
  // measurement with getTemp() instead with readTemp()
}//End of getWeather(), to he

//---------------------------------------------------------------
void printInfo()
{
//This function prints the weather data out to the default Serial Port

  Serial.print("Temp:");
  Serial.print(tempf);
  Serial.print("F, ");

  Serial.print("Humidity:");
  Serial.print(humidity);
  Serial.println("%");
}//End of printInfo()

I did something similar for the older SHT_15, and it seemed to work okay.

In both cases, I was working with Arduino 1.8.1, and libraries for the sensors from about mid Aug 18.

The SHT_15 project is published at…

http://sheepdogguides.com/arduino/aht5env-mon-ws.htm