As the title says... Chat on...

User avatar
By rsabin
#51622 Hello, I don't know if this is the right place to post but I didn't find any help/support topic.


Follow this journey of a new ESP user and help me find what is wrong. I will post a TL;DR version and a long version with more information. Anyone willing to help will be appreciated. Sorry if something is obvious. My friend just gave me this boards and I really trying to make it work. On the other hand, I am a very skilled programmer (C#, C++, Lua (I play world of warcraft), Java, etc).


Short Version:
Well, I tried many things and I cant make the ESP-01 connect on my wifi network. It just keep returning STA_CONNECTING.
Using ESP-01 and basic FTDI.


Long Version:
This is my setup: http://i.imgur.com/vb9ITD0.jpg
ESP-01 and FTDI. I also have a power supply, but the results are the same.
This is the setup using a power supply: http://i.imgur.com/WSHxVQC.jpg

I used this setup to Flash NodeMCU
Code: Select allESP     FTDI
------|------------
TX    | RX
RX    | TX
VCC   | VCC (3.3v)
GND   | GND
CH_PD | VCC (3.3v)
GPIO0 | GND (removed after flash)


I successfully uploaded a custom build from NodeMCU. I can just imagine it is working because the Flasher didn't show any errors and I can use normal commands like setphymode() or getap(). This commands are not working before the flash.
My build is a master build (not dev) integer with default libraries (wifi, http, file, etc).

After the flash, I removed the GPIO0 from GND.
Is this correct?

Well, when I connect with ESPlorer, this message appears on the screen: http://i.imgur.com/qnjoKIk.jpg
Besides, you can see that node.heap() and other things are working (???).


I uploaded this lua program to the ESP:
Code: Select allwifi.setmode(wifi.STATION)
wifi.setphymode(wifi.PHYMODE_G)
print("Mode is "..wifi.getmode())
print("PhyMode is "..wifi.getphymode())
wifi.sta.config("xxxxxxxx", "**********")
ssid, password, bssid_set, bssid=wifi.sta.getconfig()
print("\nCurrent Station configuration:\nSSID : "..ssid
.."\nPassword  : "..password
.."\nBSSID_set  : "..bssid_set
.."\nBSSID: "..bssid.."\n")
ssid, password, bssid_set, bssid=nil, nil, nil, nil
cont=1
tmr.alarm(1,2000, 1, function()
   if wifi.sta.getip()==nil then
      print("Wait for IP "..cont.."--> "..wifi.sta.status())
      cont=cont+1
      if cont>20 then tmr.stop(1) end
   else
      print("New IP address is "..wifi.sta.getip())
      tmr.stop(1)
   end
end)

Result: http://i.imgur.com/vNacYEH.jpg


As you can see, it appears to be working, it just can't connect by some reason.
SSID and Password are okay.
The getap() command also work because I can list all my neighborhood wifi names.

I dont know what more to say. This forum is my last try.
Thank you in advance. Appreciate any answer.
User avatar
By marcelstoer
#51629 Your whole setup seems fine. Otherwise you wouldn't have been able to flash and boot. When you say "custom build from NodeMCU" do you mean from nodemcu-build.com or built by yourself?

I'm sure you tried lots of different options for your wifi.sta.config(). How about going really basic and just set SSID and password? This one is from http://nodemcu.readthedocs.io/en/latest ... d/#initlua:

Code: Select allprint("Connecting to WiFi access point...")
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID, PASSWORD)
tmr.alarm(1, 1000, 1, function()
    if wifi.sta.getip() == nil then
        print("Waiting for IP address...")
    else
        tmr.stop(1)
        print("WiFi connection established, IP address: " .. wifi.sta.getip())
    end
end)


Also, do the values returned by wifi.sta.getconfig() look ok? Could it be you have untrimmed spaces to either SSID or password? Or non-printable characters? You are within read of the access point, aren't you? Can you disclose your SSID? There were previous support requests from users whose AP uses invalid (i.e. not according to spec) SSIDs which the firmware, the underlying Espressif SDK actually, rejects.
However, if either of this were the culprit you shouldn't be getting status 1 but 2 or 3 instead.

Final but obvious question: is AP rejecting your device for some reason e.g. because it's got a MAC address white-/black-list?
User avatar
By rsabin
#51640 Hi Marcel, thanks for your patience.


Answering your questions:


Build:
Yes, my “custom build” is made using the nodemcu-build.com.
I just selected the default modules (the ones that came selected) and received the link by mail.
And used the “integer” build.


The code:
The code you posted is exactly the same that I posted. We got from same place.
The only significant diference is the setphymode() command that was me trying to figure out the problem.
(My AP Works with 802.11G + 802.11N).
Others diferences are just prints() and a counter to stop after 20 loops.


getconfig() return:
The getconfig() looks ok.
My SSID only user letters and my password have one special character “(“. Zero spaces in both.
If this sound important: When I put some inexistent ssid, the return change to “4: STA_FAIL” after some time.



My AP:
As far I know, my AP is not rejecting anything.
I have mani wifi devices in my home and everything connect just with ssid and password.
I am using WPA2_PSK security.


Thanks