roberttidey / espSignalGenerator

Browser controlled Signal generator using AD9833 and ESP8266
6 stars 2 forks source link

Unable to connect to wifi AP #1

Closed rokitski closed 3 years ago

rokitski commented 3 years ago

Trying to use the code with NodeMCU (ESP8266) and it doesn't connect to any of my WiFi networks. Without wifi connection I can't check if the rest of the code works. At first ESP reports, that it received IP address, however times out later on. In general, it would be better if I could connect to ESP as AP without additional router and set up pulse generator instead of wifi interface. I'm using Wifi manager and BaseConfig libraries from the links provided in the readme file.

WM: Connection result: WM: 3 WM: IP Address: WM: 192.168.100.163 Set up web server Set up complete Wifi connection timed out. Try to relink Set up managed Web WM: WM: AutoConnect WM: Connecting as wifi client... WM: Status: WM: 1 WM: Using last saved values, should be faster WM: Connection result: WM: 1 WM: WM: Configuring access point... WM: espclockgen98F4ABD08B13 WM: password WM: AP IP address: WM: 192.168.4.1 *WM: HTTP server started Wifi connection timed out. Try to relink Set up managed Web

roberttidey commented 3 years ago

The end of the log shows that WifiManager has set up its access point at 192.168.4.1 When you try to connect to this network from a wifi client (phone/tablet etc) you should get a request to enter the wifi password which is BaseConfig,h WHen connected and a browser accesses 192.168.4.1 you should get the interface to set up the router connection by selecting the network name and entering the password. There is an overall timeout of 180 seconds for this to be completed.

Is that happening for you?

One thing to check is the item in BaseConfig.h called FASTCONNECT. This default sto True but only works if you have the version of WifiManager that supports fast connection ( 1 second instead of normal 4 seconds). I suggest you set this to FALSE to check if that may be causing a problem.

If you are still getting nowhere you could try putting an explicit connection into your network bypassing WifiManager to see if you then get a stable connection. To do this you need to temporarily edit the BaseSupport.h library file.

Look for the linewifiConnect(0); (around line 357) comment it out and insert WiFi.begin(ssid, password); where ssid and password are your wifi network parameters

I had used a router connection to make it normally more convenient to use as the client would not have to be switched to a different network to use it. It would be possible to leave the ESP8266 in AP mode if that is wanted. TO do this one would need to change the BaseSupport.h in the same way as above when hard coding the ssid and password. You would need to replace the Wifi.begin call with something like WiFi.softAP(ssid, psk); where the parameters are the ssid and the WPA2 password key The default ip address of this network will be 192.168.4.1

rokitski commented 3 years ago

Thank you for the detailed reply! It seems to me that the issue may be due to wrong versions of the libraries. The sketch doesn't even compile for me unless I completely comment out the section of BaseConfig.h that defines FASTCONNECT. Setting it to false doesn't help as in BaseSupport.h there is the following section (lines 124-126) that fails as soon as FASTCONNECT is defined:

ifdef FASTCONNECT

wifiManager.setFastConnectMode(FASTCONNECT);

endif

I've been using WifiManager 0.15 and 0.16 and with both setFastConnectMode function is not defined. I think at first I've tried with your forked version of wifiManager (roberttidey/WiFiManager: ESP8266 WiFi Connection manager with web captive portal (github.com) https://github.com/roberttidey/WiFiManager) and it didn't compile either.

I've tried changing the part of BaseSupport.h at line 318 (BaseSupport/BaseSupport.h at master · roberttidey/BaseSupport (github.com) https://github.com/roberttidey/BaseSupport/blob/master/BaseSupport.h) by commenting that out and using either WiFi.begin(ssid, password); with my home network settings or with WiFi.softAP("espclockgen", "password"); Neither approach worked for some reason.

With WiFi.softAP("espclockgen", "password"); approach I was able to connect to the AP, however ESP didn't serve any web pages on 192.168.4.1 address, despite the fact that in the log it was showing that the server started

22:12:30.346 -> Wifi connection timed out. Try to relink 22:12:30.346 -> Set up managed Web 22:12:30.346 -> WM: 22:12:30.346 -> WM: AutoConnect 22:12:30.346 -> WM: Connecting as wifi client... 22:12:30.346 -> WM: Status: 22:12:30.346 -> WM: 0 22:12:30.346 -> WM: No saved credentials 22:12:30.346 -> WM: Connection result: 22:12:30.346 -> WM: 0 22:12:30.346 -> WM: 22:12:30.346 -> WM: Configuring access point... 22:12:30.346 -> WM: espclockgen 22:12:30.346 -> WM: password 22:12:30.861 -> WM: AP IP address: 22:12:30.861 -> WM: 192.168.4.1 22:12:30.861 -> *WM: HTTP server started

I'll try reading about the libraries over the weekend, but right now I'm at loss, where the issue is. A similar project for ESP32 (vdeschwb/esp32-signal-generator: Open-Source Signal Generator using the ESP32 uC (github.com) https://github.com/vdeschwb/esp32-signal-generator) compiled and worked out of the box, however it doesn't have pulse pattern generator functionality that I'm mostly interested in.

On Mon, Sep 13, 2021 at 1:49 AM roberttidey @.***> wrote:

The end of the log shows that WifiManager has set up its access point at 192.168.4.1 When you try to connect to this network from a wifi client (phone/tablet etc) you should get a request to enter the wifi password which is BaseConfig,h WHen connected and a browser accesses 192.168.4.1 you should get the interface to set up the router connection by selecting the network name and entering the password. There is an overall timeout of 180 seconds for this to be completed.

Is that happening for you?

One thing to check is the item in BaseConfig.h called FASTCONNECT. This default sto True but only works if you have the version of WifiManager that supports fast connection ( 1 second instead of normal 4 seconds). I suggest you set this to FALSE to check if that may be causing a problem.

If you are still getting nowhere you could try putting an explicit connection into your network bypassing WifiManager to see if you then get a stable connection. To do this you need to temporarily edit the BaseSupport.h library file.

Look for the linewifiConnect(0); (around line 357) comment it out and insert WiFi.begin(ssid, password); where ssid and password are your wifi network parameters

I had used a router connection to make it normally more convenient to use as the client would not have to be switched to a different network to use it. It would be possible to leave the ESP8266 in AP mode if that is wanted. TO do this one would need to change the BaseSupport.h in the same way as above when hard coding the ssid and password. You would need to replace the Wifi.begin call with something like WiFi.softAP(ssid, psk); where the parameters are the ssid and the WPA2 password key The default ip address of this network will be 192.168.4.1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roberttidey/espSignalGenerator/issues/1#issuecomment-917975751, or unsubscribe https://github.com/notifications/unsubscribe-auth/AULMAANISKVAVSTOYKL3DTLUBW3IZANCNFSM5D4T4EXA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

roberttidey commented 3 years ago

Sorry to hear you are still having difficulties.

It is true you have to comment out the #define FASTCONNECT when using it with a library that does not support it. The value False is used to disable fastconnect even with a library that supports it. The comment in the line above says to comment it out, but it maybe better if I comment it out by default.

When using the fastconnect the library to use is actually a branch on the tzapu WifiManager site called feature_fastconnect. My development fork hadn't been updated after making some changes with tzapu. I will do that. However that should not affect things if commenting out FASTCONNECT and using the normal master tzapu library.

What actually happened when you tried WiFi.begin(ssid, password);

Maybe try a longer version with some debug that checks when a connection is established like

WiFi.begin("network-name", "pass-to-network");

Serial.print("Connecting"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println();

Serial.print("Connected, IP address: "); Serial.println(WiFi.localIP());

When using the softAP method it would also be good to try configuring its IP networking explicitly rather than relying on the default 192.168.4.1 To do this you would add the lines in BaseSupport.h at the top e.g. around line 70

/ Put IP Address details / IPAddress local_ip(192,168,1,1); IPAddress gateway(192,168,1,1); IPAddress subnet(255,255,255,0);

Then add

WiFi.softAPConfig(local_ip, gateway, subnet);

after the softAP call

If you don't get web pages served, does it respond to ipaddress/upload as that should serve a page to allow the files from the Data folder to be uploaded.

It can be useful to turn on debug mode in your browser (F12) so you can see what happens.

rokitski commented 3 years ago

I narrowed down the issue to the calls in function setupEnd(): i2scInit(512, 1000000, -1, 0, 0); i2scSetMSArrayItem(0, 16, 16, 0); i2scBegin(); When I comment these lines out, wifi part of the app, including the web server works fine and stable. I noticed that the chip that I use is ESP-12E, while I think you are using ESP-12F. Can this be a reason for difference in behavior? Any changes I need to make in i2s bus configuration?

roberttidey commented 3 years ago

There is no significant difference between ESP-12E and ESP-12F. The latter has a slightly improved pcb antenna design.

However, I am confused by your setupEnd comment. Those lines don't exist in this project (espSignalGenerator). This generates sine, triangle square waves using the AD9833 chip.

They do exist in another project of mine (espi2sClockGenerator which generates clock pulses of selectable frequency and widths using the i2S serial interface and requires the i2sTXcircular library.

Which one are you trying to do?

rokitski commented 3 years ago

Indeed, you are right. This is embarassing, looks like I've posted it under wrong application. I might have gotten confused because under espSignalGenerator project readme file starts with espI2SClockGen in large font: https://github.com/roberttidey/espSignalGenerator. In any case I appreciate your help and need to move the issue to espI2SClockGen, where I'm challenged to make it work.