Skip to content

Issues #353/#3100 Continue. WiFi only works once after erasing flash #4345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mlbranchus opened this issue Feb 10, 2018 · 55 comments
Closed

Comments

@mlbranchus
Copy link

Please fill the info fields, it helps to get you faster support ;)

if you have a stack dump decode it:
https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/stack_dump.rst

for better debug messages:
https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/debugging.rst

----------------------------- Remove above -----------------------------

Basic Infos

Hardware

Hardware: ?ESP-12?
Core Version: ?2.1.0-rc2?

Description

Problem description WiFi only works once after erasing flash

Settings in IDE

Module: Huzzah ESP8266 Module
Flash Size: ?4MB/1MB?
CPU Frequency: 80Mhz
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: / SERIAL?
Reset Method: ?ck

Sketch

#include <Arduino.h>

// Adafruit IO Temperature & Humidity Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-temperature-and-humidity
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016-2017 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// 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 *******************************/
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_SSD1306.h>

// oled display
Adafruit_SSD1306 oled = Adafruit_SSD1306();

// pin connected to DH22 data line
#define DATA_PIN 2

// create DHT22 instance
DHT_Unified dht(DATA_PIN, DHT22);

// set up the 'temperature' and 'humidity' feeds
AdafruitIO_Feed *temperature = io.feed("temperature");
AdafruitIO_Feed *humidity = io.feed("humidity");

void setup() {
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
  oled.display();

  // start the serial connection
  Serial.begin(115200);

  // wait for serial monitor to open
  while(! Serial);

  // initialize dht22
  dht.begin();

  // 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());

  // text display tests
  oled.setTextSize(1);
  oled.setTextColor(WHITE);
}

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();

  sensors_event_t event;
  dht.temperature().getEvent(&event);

  float celsius = event.temperature;
  float fahrenheit = (celsius * 1.8) + 32;

  Serial.print("celsius: ");
  Serial.print(celsius);
  Serial.println("C");

  Serial.print("fahrenheit: ");
  Serial.print(fahrenheit);
  Serial.println("F");

  // save fahrenheit (or celsius) to Adafruit IO
  temperature->save(fahrenheit);

  dht.humidity().getEvent(&event);
   
  Serial.print("humidity: ");
  Serial.print(event.relative_humidity);
  Serial.println("%");

  // save humidity to Adafruit IO
  humidity->save(event.relative_humidity);

  // print it to the OLED
  oled.clearDisplay();
  oled.setCursor(0,0);
  oled.print("SSID: "); oled.println(WIFI_SSID);
  oled.print("IP: "); oled.println(WiFi.localIP());
  oled.print("Temp: "); oled.print(fahrenheit,0); oled.print(" *F ");
  oled.print("Hum: "); oled.print(event.relative_humidity,0); oled.println(" %");
  oled.print("IO Status: ");
  aio_status_t aio_status = io.status();
  Serial.print("Status: "); Serial.println(aio_status);
  switch (aio_status) {
     case AIO_IDLE:  oled.println("IDLE"); break;
     case AIO_DISCONNECTED:
     case AIO_NET_DISCONNECTED:  oled.println("DISCONNECT"); break;
     case AIO_NET_CONNECTED:
     case AIO_CONNECTED_INSECURE:
     case AIO_CONNECTED: oled.println("CONNECTED"); break;
  }
  oled.display();

  // wait 5 seconds (5000 milliseconds == 5 seconds)
  delay(2000);
}
void setup() {

}

void loop() {

}

Debug Messages

messages here
@tonton81
Copy link

i dont see you running WiFi.begin()?

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@tonton81
Copy link

it has to be in your setup()
WiFi.begin(“SSID”,”PASSWORD”);

@tonton81
Copy link

note the upper and lower case “WiFi”, must be exact

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@beicnet
Copy link

beicnet commented Feb 11, 2018

You also need to #include wifi libraries too! Like this #include "ESP8266WiFi.h"

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@beicnet
Copy link

beicnet commented Feb 11, 2018

As I wrote before above at the top of your code:
#include "ESP8266WiFi.h"

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@beicnet
Copy link

beicnet commented Feb 11, 2018

Did you include ESP8266 Arduino core to your references?

@mlbranchus
Copy link
Author

mlbranchus commented Feb 11, 2018 via email

@beicnet
Copy link

beicnet commented Feb 11, 2018

Open the Arduino IDE and go to:

File > Preferences > Additional Boards Manager URLs and then add this line:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

close the IDE, then reopen it.

After that go to the Tools > Board Manager, find ESP8266 Community and install it.

@mlbranchus
Copy link
Author

mlbranchus commented Feb 12, 2018 via email

@beicnet
Copy link

beicnet commented Feb 12, 2018

Ok, can you please post your current code again or update it above, and attach the screenshot of that error code?!

@mlbranchus
Copy link
Author

// Adafruit IO Temperature & Humidity Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-temperature-and-humidity
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016-2017 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// 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 *******************************/
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_SSD1306.h>
#include <ESP8266WiFi.h>

// oled display
Adafruit_SSD1306 oled = Adafruit_SSD1306();

// pin connected to DH22 data line
#define DATA_PIN 2

// create DHT22 instance
DHT_Unified dht(DATA_PIN, DHT22);

// set up the 'temperature' and 'humidity' feeds
AdafruitIO_Feed *temperature = io.feed("temperature");
AdafruitIO_Feed *humidity = io.feed("humidity");

void setup() {
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
oled.display();

WiFi.begin("annwyn","pirate9d"); //ENTRY HERE

// start the serial connection
Serial.begin(115200);

// wait for serial monitor to open
while(! Serial);

// initialize dht22
dht.begin();

// 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());

// text display tests
oled.setTextSize(1);
oled.setTextColor(WHITE);
}

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();

sensors_event_t event;
dht.temperature().getEvent(&event);

float celsius = event.temperature;
float fahrenheit = (celsius * 1.8) + 32;

Serial.print("celsius: ");
Serial.print(celsius);
Serial.println("C");

Serial.print("fahrenheit: ");
Serial.print(fahrenheit);
Serial.println("F");

// save fahrenheit (or celsius) to Adafruit IO
temperature->save(fahrenheit);

dht.humidity().getEvent(&event);

Serial.print("humidity: ");
Serial.print(event.relative_humidity);
Serial.println("%");

// save humidity to Adafruit IO
humidity->save(event.relative_humidity);

// print it to the OLED
oled.clearDisplay();
oled.setCursor(0,0);
oled.print("SSID: "); oled.println(WIFI_SSID);
oled.print("IP: "); oled.println(WiFi.localIP());
oled.print("Temp: "); oled.print(fahrenheit,0); oled.print(" *F ");
oled.print("Hum: "); oled.print(event.relative_humidity,0); oled.println(" %");
oled.print("IO Status: ");
aio_status_t aio_status = io.status();
Serial.print("Status: "); Serial.println(aio_status);
switch (aio_status) {
case AIO_IDLE: oled.println("IDLE"); break;
case AIO_DISCONNECTED:
case AIO_NET_DISCONNECTED: oled.println("DISCONNECT"); break;
case AIO_NET_CONNECTED:
case AIO_CONNECTED_INSECURE:
case AIO_CONNECTED: oled.println("CONNECTED"); break;
}
oled.display();

// wait 5 seconds (5000 milliseconds == 5 seconds)
delay(2000);
}

@beicnet
Copy link

beicnet commented Feb 12, 2018

I see, you need to remove that line in your code WiFi.begin("annwyn","pirate9d"); //ENTRY HERE , #include <ESP8266WiFi.h> and all configurations/settings has to be done in the config.h.

You just need to follow the Adafruit tutorial included at a top of your code.

@mlbranchus
Copy link
Author

TonTon told me to add that line of code.

@tonton81
Copy link

sorry i was not aware the library had a separate file for that, another reason i hate adafruit libraries

@mlbranchus
Copy link
Author

Ok, So all of that code belongs in config.h instead of .ino?

@beicnet
Copy link

beicnet commented Feb 12, 2018

No, there is two file one is .ino and the second is .h, your settings are located in the .h file, there you need to setup your credentials and connection type.

@mlbranchus
Copy link
Author

Yes I know that. All of my credentials and connection type are already in the .h file.

@mlbranchus
Copy link
Author

mlbranchus commented Feb 12, 2018 via email

@beicnet
Copy link

beicnet commented Feb 12, 2018

What line gives you the fault code? Can you post a screenshot?

@mlbranchus
Copy link
Author

mlbranchus commented Feb 12, 2018 via email

@beicnet
Copy link

beicnet commented Feb 12, 2018

Just that outputs? Nothing else?

@mlbranchus
Copy link
Author

mlbranchus commented Feb 12, 2018 via email

@beicnet
Copy link

beicnet commented Feb 12, 2018

Can you post a screenshot of it?

@mlbranchus
Copy link
Author

mlbranchus commented Feb 12, 2018 via email

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@beicnet
Copy link

beicnet commented Feb 13, 2018

I don't see / have any screenshots from you!

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@beicnet
Copy link

beicnet commented Feb 13, 2018

Screenshot is when you press the "Print Screen" button on your keyboard and then save it in mspaint as image and you attach that image to this post!

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@beicnet
Copy link

beicnet commented Feb 13, 2018

As you can see, there is no images present in this entire post!

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@mlbranchus
Copy link
Author

No it's not

@beicnet
Copy link

beicnet commented Feb 13, 2018

Just drag and drop your images here!

@tonton81
Copy link

jeebus, this “issue” is bigger than an average forum topic lol

@beicnet
Copy link

beicnet commented Feb 13, 2018

🤣

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@beicnet
Copy link

beicnet commented Feb 13, 2018

So, did you made already account on Adafruit IO, just a simple question

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@beicnet
Copy link

beicnet commented Feb 13, 2018

Github

@mlbranchus
Copy link
Author

So...how do I open the GitHub information?

@beicnet
Copy link

beicnet commented Feb 13, 2018

just upload the images to https://imgur.com/ and paste links here...

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@mlbranchus
Copy link
Author

mlbranchus commented Feb 13, 2018 via email

@beicnet
Copy link

beicnet commented Feb 13, 2018

Not a joke, if you don't know how to attach images here, then I can't help you, another thing, this is not a support forum, it's a core development branch, so, here you will not get any help regarding you sketch.

You basicaly need to ask your questions on your board manufacturer and code sample page.

And it's located here.

Regards

@vdeconinck
Copy link
Contributor

vdeconinck commented Feb 13, 2018

@tonton81 and @beicnet , I know how it feels, I'm always tempted to help users too, but I've been reminded in the past (and rightly so) that this is a tracker for issues in the ESP8266 core for Arduino IDE, not a forum for tracking user errors, and certainly not for teaching people how to attach an image to a comment.
Per https://github.com/esp8266/Arduino/blob/master/POLICY.md , I think the best is to move that discussion over to esp8266.com or stackoverflow and close this issue that is currently just generating spam.

@beicnet
Copy link

beicnet commented Feb 14, 2018

@vdeconinck Yes, thats the reason for my last comment to him and it's not that I wont help!

@devyte
Copy link
Collaborator

devyte commented Feb 16, 2018

Alright, enough.
@mlbranchus please request help at a community forum, and discuss there. If you reduce your problem to an issue in the core code hosted in this repo, please open a new issue and provide the requested details, including an mcve sketch. Keep in mind that issues with 3rd party libs such as Adafruit are NOT covered here.
Closing per issue POLICY doc.

@devyte devyte closed this as completed Feb 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants