-->
Page 1 of 1

Chaotic misbehaviour with ESP8266WiFi.h and Arduino IDE

PostPosted: Sun Nov 12, 2017 5:13 pm
by gabriele.labanca
Hello there! I'm a newbie here, and concerning electronics in general, so please don't hesitate to tell me if I'm doing anything wrong. Also, I hope this is not a duplicate: I couldn't find any.

This said, I am working on Arduino IDE to connect to NodeMCU; my problem is about ESP8266WiFi.h, which I can get to work in #CODE1, but everything breaks out when I try even to comment an empty line! Sometimes I can't even get it back to working, by uncommenting.

I honestly can't figure out what's wrong, maybe some IDE-NodeMCU misunderstanding? Please tell me if some extra information is needed: as I said, I'm quite a newbie here...

Thanks a lot for your help! :)

#CODE1
Code: Select all// CONFIGURE WIFI
#include "ESP8266WiFi.h"
const char *ssid =   "xxxxxxx";     
const char *pass =  "xxxxxxx";

void setup()
{
  delay(1000);
  Serial.begin(9600);
  Serial.println("BEGIN CONNECTION");

  //SETUP WIFI
  Serial.println("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");
}

void loop()
{
}

Re: Chaotic misbehaviour with ESP8266WiFi.h and Arduino IDE

PostPosted: Mon Nov 13, 2017 1:56 pm
by Narfel
Can't see anything wrong with your code, except that you maybe should xxxx out your password.

Couple of ideas:
- What makes you think it is the header file that makes those problems? Can you run/comment out other libraries?

- Did you use http://arduino.esp8266.com/stable/packa ... index.json in the preferences?

- If it really is down to the head file you can try using brackets instead of quotes, although i think the Arduino IDE falls back on either.

Re: Chaotic misbehaviour with ESP8266WiFi.h and Arduino IDE

PostPosted: Tue Nov 14, 2017 4:37 pm
by gabriele.labanca
Thanks a lot, Narfel! Unfortunately, it wasn't any of your guesses...

Narfel wrote:Can't see anything wrong with your code, except that you maybe should xxxx out your password.

Right, I'll edit it :)

Narfel wrote:Couple of ideas:
- What makes you think it is the header file that makes those problems? Can you run/comment out other libraries?

I'm also using DHT.h and HX711.h, which seem not to give any problem...

Narfel wrote:- Did you use http://arduino.esp8266.com/stable/packa ... index.json in the preferences?

Actually, I was using http://arduino.esp8266.com/stable/packa ... index.json, but changing to your link doesn't seem to change anything :/

Narfel wrote:- If it really is down to the head file you can try using brackets instead of quotes, although i think the Arduino IDE falls back on either.

I had already tried it, but again, nothing changes.

Re: Chaotic misbehaviour with ESP8266WiFi.h and Arduino IDE

PostPosted: Mon Nov 20, 2017 12:48 pm
by gabriele.labanca
Can you post some actual error messages - "everything breaks out " and "CHAOTIC MISBEHAVIOUR" do not give any idea what the actual problem is.


You are right, but I didn't post anything simply because nothing happened, except from the fact that it didn't connect.
Anyways, I found a solution: instead of
Code: Select allWiFi.status() != WL_CONNECTED

I put
Code: Select allWiFi.localIP().toString() == "0.0.0.0"

and everything works well.
Another solution is proposed here: https://stackoverflow.com/questions/433 ... pot-with-c, but I am not sure it works the same.

Thanks everybody!