You can chat about native SDK questions and issues here.

User avatar
By Alan-bc
#90767 I wrote some code for an ESP8266 to turn it into an access point and web server. Worked great.

One of the things you could do in the webserver was to write a number of choices from buttons on the website into EEPROM. I wanted the choices to survive a reboot.

Among the choices was the SSID; you could enter a new SSID into a text field and write that text into EEPROM as well.

So for testing, I used MY_ACCESS_POINT as the SSID of my ESP8266 access point.

Using my computer, I could connect to the access point, get an IP address and talk to the web server, sending clicks and receiving pages. The EEPROM write worked, and things came back after a reboot, including the SSID.

The key is that I saw MY_ACCESS_POINT in the list of things to connect to when the board was powered and did not see it when power was removed.

(Duh, you say. Fair enough. But read on.)

I later decided to try something else with the ESP8266; I wanted to send an email when a switch was closed. I started with some all new code that included the SSID and password of my home WiFi. It too worked great. Using some Serial.prints, I could see it connect, see the IP address delivered by the home router, see it sending emails.

Only, MY_ACCESS_POINT continued to show up on my phone, computer and tablet in the list of SSIDs to connect to.

Huh?

It got weirder. I could connect to it, could get an IP address, and could get a response to a ping. It's no longer a web server, that didn't work, but it really is an access point.

All this with no code saying "be an access point" and somehow reading the old SSID out of the middle of EEPROM memory.

I'm not done yet, it gets weirder still. The board is a Lolin D1 Mini. Thinking of nothing else to do, I picked a different Lolin board in the Arduino IDE, D1 Mini Pro. Compiled and uploaded the code.

It was STILL an access point, only the SSID was now ESP_A4CF12. But as before, I could still connect and get an address.

Back to Lolin D1 Mini and back to MY_ACCESS_POINT for an SSID.

I went so far as to delete everything in the Arduino output directory to assure myself I was starting from fresh. No change.

So I'm at a loss.

Here's the code. Absolute boilerplate. How is this an access point? And how does it know to read the 40th to 60th byte in EEPROM to learn its old SSID? ANY wild guesses appreciated.

(Man, I wish I was still a drinker, because then I'd have an explanation! Or wouldn't care, more likely.)

Alan
-----------------------------------------------------------------

#include <ESP8266WiFi.h>

const char* ssid = "TELUS";
const char* password = "12345678";

void setup() {

Serial.begin(115200);
Serial.print("Connecting To: ");
WiFi.begin(ssid, password);
Serial.println(ssid);

while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
Serial.println("WiFi Connected.");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}

void loop() {
}
User avatar
By QuickFix
#90778 Like schufti says: always put your ESP in the correct mode at setup():

Code: Select allsetup() {
  Serial.begin(115200);
  Serial.print("Connecting To: ");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  // Rest of script


BTW. This is a newbie topic, not an advanced users topic. :idea:
User avatar
By Alan-bc
#90785 [quote=
BTW. This is a newbie topic, not an advanced users topic. :idea:[/quote]

Fair enough .. I'd read somewhere early on in my 8266 experience that Station mode was the default and I never thought about it past that. My bad.

My real question is, why would a different access point name be chosen depending upon which board I selected in the IDE? The default, sure, I get that. But how did the code shown above (with one specific board) pullout the name MY_ACCESS_POINT, then not, then pull it out again. THAT'S what I don't get. I suppose it's documented somewhere, I just haven't found it yet.

But no worries, I'll repost this in the newbie section.

(In my own defense, I've spent over 50 years programming in assembly, where every op code was my own and every library, pretty much without fail, was written by me. If it broke, it was unquestionably my fault, and if things happened in a particular way, it's because _I_ instructed it to do so. Trusting to COMPILERS .. as opposed to assemblers .. and using LIBRARIES written by I don't know who updated automagically I don't know when .. this is all new to me. Very cool, but new, and taking some getting used to.)

Thanks to all for the time.