logo elektroda
logo elektroda
X
logo elektroda

ESP8266MOD - lolin nodemcu v3: Problem reading SSID and password from EEPROM

BuildEver 3117 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16162332
    BuildEver
    Level 7  
    Hello everyone,
    i have the following problem.

    I have an ESP8266MOD board - lolin nodemcu v3. I am trying to implement the following functionality to it: writing and reading SSID oras Passwords of a particular Wi-Fi network from EEPROM, automatic linking to a saved Wi-Fi network. I want it to be possible to load this data from the EEPROM, because the end user is not familiar with programming and will not enter the Arduino IDE to connect to his network....

    Anyway, I've done the reading and writing, but when I want to connect to the Wi-Fi nothing happens :/ I don't know why. Manually entering the value works. But as I said before, this can't be!

    Everything is programmed in the IDE from Arduino:
    Here are the sutations:

    Module: ESP8622MOD - lolin nodemcu v3
    Flash Size: 4MB
    CPU Frequency: 80Mhz
    Upload Using: SERIAL
    Reset Method: nodemcu

    I wrote a small debugger, here are its results:

    Starting check
    Value of byte at address 1 =10

    Connecting to Wi-Fi
    Value of byte at adress 2 =7
    Readed ssid =MY SSID
    Value of byte at adress 3 =11
    Readed password =MY PASSWORD
    Connecting
    ............................... Could not connect

    Starting Access Point
    Value of byte at address 4 =8
    Read name =MRJW-ESP

    AP IP address: 192.168.4.1
    Port: 23
    Max users: 1
    New client connected - ID: 0
    Sending: Host: You are connected!

    Here the whole programme:

    Code: C / C++
    Log in, to see the code
  • ADVERTISEMENT
  • #2 16163046
    piotrva
    VIP Meritorious for electroda.pl
    Display the password and SSID values for yourself just before the WiFi.begin(ssid, password) instruction;
  • ADVERTISEMENT
  • #3 16163105
    BuildEver
    Level 7  
    I did it :/
    Everything is above...
  • #4 16163162
    piotrva
    VIP Meritorious for electroda.pl
    You do this somewhere in the code, not just before the call instruction.

    Added after 1 [minute]:

    This is about ssid

    Added after 2 [minutes]:

    Also, overall the code is terribly confusing. Why the strings? Why these global variables like eRead.
    I think the cause of the problem is that you are using pointers as ssid and password.
  • #5 16166085
    krzbor
    Level 28  
    Refer to WiFiManager . This library has several versions (branches). It is very easy to use. The idea is as follows: one makes an AP from a device with its own website and a fixed address, SIDD and password. The user connects to this website using a smartphone and enters the data of his WiFi network. After a reboot, everything already works normally.
  • ADVERTISEMENT
  • #6 16167468
    BuildEver
    Level 7  
    What helped me was to manually write a for loop every time I loaded a note from the EEPROM
  • ADVERTISEMENT
  • #7 16167807
    piotrva
    VIP Meritorious for electroda.pl
    So you've got something wrong and the problem is just getting around ;)
    On a collegial note, I will say that I would not want to be your customer :D
  • #8 16176931
    BuildEver
    Level 7  
    Generally I had it all done in methods at the beginning, just specify the address and length and you get char*. However, in general ESP under Arduino has a lot of problems with embracing such things.

    After searching the web for a while, I found a similar project. I noticed that when loading characters from the EEPROM the person used:

    Code: C / C++
    Log in, to see the code


    Instead of (i.e. as I had):

    Code: C / C++
    Log in, to see the code


    And that fixed everything. I'm pretty sure that the carriage return character (\r) was written to memory. And the command (char)EEPROM.read(address); couldn't handle it.
  • #9 16176964
    tronics
    Level 38  
    a \t is a tab, a CR is a \r, and a \n is a new line or line feed LF. The string probably ends with an end-of-string character, i.e. \0
  • #10 16176977
    BuildEver
    Level 7  
    Thank you for your attention. I had forgotten what the mark was :)

    Reading the data is via Telnet, and it reads everything into const char*. I ended the read in at the newline character. Forgetting the earlier carriage return character....
  • #11 16177384
    piotrva
    VIP Meritorious for electroda.pl
    And it still seems to me that you haven't quite made good use of the ;)
ADVERTISEMENT