Notifications
Clear all

[Solved] Need help configuring WiFi

Page 2 / 2

byron
(@byron)
Prominent Member
Joined: 3 years ago
Posts: 878
 
Posted by: @zander

I just ran a test and got tbe following. Keep in mind I entered the address and got an unreachable error. This is new and I don't understand.

What ip address did you enter.  Are you saying the ip addresses in your printout do not work? i.e the 192.168.0.123 'to connect' etc.?  

The printout suggests you are all set up, your mac (I presume) is connected to your 'RonsWiFi'  and that entering the address of 192.168.0.123:80 will connect your mac to the web server, it can stream info if connected to 192.168.123:81

Apart from connecting directly from you mac to the ESP32 in AP mode, it is also be possible to connect your ESP32 board to your home network (in station or STA mode), in which case it will probably be assigned an IP address by the home routers DCHP facility.  A lan scan app will find its assigned IP address on your home network.   I don't know if your ESP32 has been programmed allow connections to its web server program via this method.  However, on some similar boards containing web servers that I have used (not a camera board) the routine has been to access the ESP board via its access point, which then enables the home network SSID and PW to be entered to the ESP and upon a reboot the ESP boards web server is then accessed via the ip address your home router assigns.   They also provide a way of getting back to the AP mode should one wish to change the assigned home network.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
Topic starter  

@byron Yes on all counts,

Yes I entered the 192.168.0.123 and the web page was unreachable. I do not remember if I checked what my max was connected to, but I doubt it was anything other than the router so 192.168.0.xxx is my home lan and is normally reachable. I use it all the time. Very weird.

Yes, I tried a Lan Scan and it did NOT show up, so the serial output was lying???? More weird.

The mechanism you are describing at the end there sounds a lot like WiFiManager and is indeed what is wanted.

I am now rebuilding the V4 software after discovering ALL the WiFi stuff is inside one function/procedure. I am replacing it all with the wifimanager call to autoconnect. Strangely the code fails on a compile error in the library, but does not fail in the example sketch. I changed the order of some includes and that worked. So far still no connection, but now I am adding a reset so it starts from scratch each time. Will update as it moves along, but so far with lines 487 to 670 removed it at least compiles and NONE of the config settings are now used. Hopeful am I 🙂

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
Topic starter  

I think I am close.

0953.733 -> *wm:[1] resetSettings
0954.379 -> *wm:[1] SETTINGS ERASED
0954.379 -> *wm:[1] AutoConnect
0954.417 -> *wm:[2] ESP32 event handler enabled
0954.417 -> *wm:[2] Connecting as wifi client...
0954.417 -> *wm:[2] setSTAConfig static ip not set, skipping
0954.417 -> *wm:[1] No wifi saved, skipping
0954.417 -> *wm:[2] Connection result: WL_NO_SSID_AVAIL
0954.417 -> *wm:[1] AutoConnect: FAILED
0954.417 -> *wm:[2] Starting Config Portal
0954.417 -> *wm:[2] AccessPoint set password is VALID
0954.417 -> *wm:[2] Disabling STA
0954.417 -> *wm:[2] Enabling AP
0954.417 -> *wm:[1] StartAP with SSID: AutoConnectAP
0954.956 -> *wm:[1] AP IP address: 192.168.4.1
0954.956 -> *wm:[1] Starting Web Portal
0954.956 -> *wm:[2] HTTP server started
0954.956 -> *wm:[2] Config Portal Running, blocking, waiting for clients...
0909.453 -> *wm:[2] <- Request redirected to captive portal
0909.643 -> *wm:[2] <- HTTP Root
0921.988 -> *wm:[2] NUM CLIENTS: 1
0951.972 -> *wm:[2] NUM CLIENTS: 1
0955.482 -> *wm:[2] <- Request redirected to captive portal
0955.578 -> *wm:[2] <- HTTP Root
0955.578 -> *wm:[2] <- Request redirected to captive portal
0955.578 -> *wm:[2] <- HTTP Root
0957.486 -> *wm:[2] <- HTTP Wifi
0957.486 -> *wm:[2] WiFi Scan SYNC started
0902.635 -> *wm:[2] WiFi Scan ASYNC completed in 5122 ms
0902.635 -> *wm:[2] WiFi Scan ASYNC found: 5
0902.635 -> *wm:[2] WiFi Scan completed in 5122 ms
0902.635 -> *wm:[1] 5 networks found
0902.635 -> *wm:[2] AP: -55 RonsWiFi
0902.635 -> *wm:[2] AP: -79 TW2
0902.635 -> *wm:[2] AP: -79 TW6
0902.635 -> *wm:[2] AP: -85 TW4
0902.635 -> *wm:[2] AP: -92 TW1
0902.809 -> *wm:[2] <- Request redirected to captive portal
0902.809 -> *wm:[2] <- HTTP Root
0913.816 -> *wm:[2] <- HTTP WiFi save
0913.816 -> *wm:[2] processing save
0915.841 -> *wm:[2] Connecting as wifi client...
0915.841 -> *wm:[2] setSTAConfig static ip not set, skipping
0915.841 -> *wm:[1] Connecting to NEW AP: RonsWiFi
0915.922 -> *wm:[1] connectTimeout not set, ESP waitForConnectResult...
0919.591 -> *wm:[2] [EVENT] WIFI_REASON: 15
0915.876 -> *wm:[2] Connection result: WL_DISCONNECTED
0915.876 -> *wm:[0] [ERROR] Connect to new AP Failed
0915.876 -> *wm:[2] Processing - Disabling STA
0915.876 -> *wm:[2] NUM CLIENTS: 1
0915.876 -> *wm:[2] <- Request redirected to captive portal
0915.876 -> *wm:[2] <- Request redirected to captive portal
0916.092 -> *wm:[2] <- HTTP Root

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
Topic starter  

It says it is setup, but scan shows nothing and the 192.168.0.123 IP is not responsive

0926.952 -> *wm:[2] WiFi Scan SYNC started
0932.068 -> *wm:[2] WiFi Scan ASYNC completed in 5108 ms
0932.068 -> *wm:[2] WiFi Scan ASYNC found: 8
0932.068 -> *wm:[2] WiFi Scan completed in 5109 ms
0932.068 -> *wm:[1] 8 networks found
0932.068 -> *wm:[2] DUP AP: TW6
0932.068 -> *wm:[2] DUP AP: TW1
0932.068 -> *wm:[2] AP: -50 RonsWiFi
0932.068 -> *wm:[2] AP: -69 TW6
0932.068 -> *wm:[2] AP: -71 TW2
0932.068 -> *wm:[2] AP: -83 TW4
0932.068 -> *wm:[2] AP: -85 TW1
0932.068 -> *wm:[2] AP: -89 TW3
0932.150 -> *wm:[2] <- Request redirected to captive portal
0932.150 -> *wm:[2] <- HTTP Root
0939.379 -> *wm:[2] <- HTTP WiFi save
0939.379 -> *wm:[2] processing save
0941.387 -> *wm:[2] Connecting as wifi client...
0941.387 -> *wm:[2] setSTAConfig static ip not set, skipping
0941.387 -> *wm:[1] Connecting to NEW AP: RonsWiFi
0941.505 -> *wm:[1] connectTimeout not set, ESP waitForConnectResult...
0942.811 -> *wm:[2] Connection result: WL_CONNECTED
0942.811 -> *wm:[1] Connect to new AP [SUCCESS]
0942.811 -> *wm:[1] Got IP Address:
0942.811 -> *wm:[1] 192.168.0.123
0942.811 -> *wm:[2] shutdownConfigPortal
0942.811 -> *wm:[2] <- Request redirected to captive portal
0942.900 -> *wm:[2] restoring usermode STA
0943.833 -> *wm:[2] wifi status: WL_CONNECTED
0943.867 -> *wm:[2] wifi mode: STA
0943.867 -> *wm:[2] configportal closed
0943.867 -> *wm:[1] config portal exiting
0943.867 -> connected...yeey 🙂

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
Topic starter  

That last post was just the example sketch, here is the new camera sketch.

0931.507 -> *wm:[2] WiFi Scan ASYNC completed in 5121 ms
0931.507 -> *wm:[2] WiFi Scan ASYNC found: 5
0931.507 -> *wm:[2] WiFi Scan completed in 5122 ms
0931.507 -> *wm:[1] 5 networks found
0931.507 -> *wm:[2] AP: -59 RonsWiFi
0931.627 -> *wm:[2] AP: -72 TW2
0931.627 -> *wm:[2] AP: -78 TW6
0931.627 -> *wm:[2] AP: -89 TW4
0931.627 -> *wm:[2] AP: -92 TW3
0934.871 -> *wm:[2] NUM CLIENTS: 1
0936.535 -> *wm:[2] <- Request redirected to captive portal
0936.631 -> *wm:[2] <- Request redirected to captive portal
0939.585 -> *wm:[2] <- Request redirected to captive portal
0940.417 -> *wm:[2] <- HTTP WiFi save
0940.417 -> *wm:[2] processing save
0942.422 -> *wm:[2] Connecting as wifi client...
0942.422 -> *wm:[2] setSTAConfig static ip not set, skipping
0942.422 -> *wm:[1] Connecting to NEW AP: RonsWiFi
0942.545 -> *wm:[1] connectTimeout not set, ESP waitForConnectResult...
0943.747 -> *wm:[2] Connection result: WL_CONNECTED
0943.747 -> *wm:[1] Connect to new AP [SUCCESS]
0943.747 -> *wm:[1] Got IP Address:
0943.747 -> *wm:[1] 192.168.0.123
0943.747 -> *wm:[2] shutdownConfigPortal
0943.823 -> *wm:[2] restoring usermode STA
0944.798 -> *wm:[2] wifi status: WL_CONNECTED
0944.798 -> *wm:[2] wifi mode: STA
0944.798 -> *wm:[2] configportal closed
0944.798 -> *wm:[1] config portal exiting
0944.798 ->
0944.798 -> WiFi connected
0944.798 -> Camera Ready! Use 'http://192.168.0.123' to connect

 

BAZINGA!!!

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@zander

Posted by: @zander

Everything after this is noise, sorry.

Firstly, a router provides access to the internet via your ISP's allocated IP address, but a router also has a firewall, which in turn is most likely using NAT (Network Address Translation) internally/locally to direct traffic.

In an IP4 address, there are 4 octets making up a 32 bit address, for example:

image

...thus, we have 255 available addresses on a Class C network, 255 * 255 on a Class B network, etc.

so "192.168.0.(0-255)" is a Class C network, with 255 available IP addresses locally.

I suggest, determine the WiFi access mode (Access point / Station) that you need for your project, and lets work on getting that up and running first!

Do not worry about password management at this stage, you first need to lay the foundation and worry about those detail later, but before exposing your device live... there are also other ways, maybe even better than WiFi manager, such as creating your own WiFi manager system with encryption as well.

Baby steps...

Cheers

Hmm, not sure why you call it noise, Ron, as I was simply answering your question below:

Posted by: @zander

BTW, there is mention of a 192.168.4.1 as the login IP but I can't find that IP anywhere using text search against all my libraries. The .1 implies router, but 192.168.4 is what? My localnet as any I have ever seen is 192.168.0.

Cheers

[edit] - Just realised a typo... fixed above

 

This post was modified 3 days ago by frogandtoad

ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
Topic starter  

@frogandtoad Thanks, but I got the code working.

No idea where the 192.168.4.1 is coming from, I have attempted to search the library folders to see if I can find it but strangely a Mac computer does not have an easy way to do that. I think my search has been thorough, but not 100% sure.

When I got it working by creating an AP on the ESP32CAM I selected that SSID using my Mac WiFi control and sure enough up popped a little screen (on 192.168.4.1) that let me then select my router. After that the ESP32 was attached to my router at 192.168.0.123 or similar.

Strange how nobody on the forum seems to know how the 192.168.4.1 'captive portal' feature is created. I can find all kinds of references to it but can't find the code that creates that ip address. It's not that important, I was just curious. 

I am familiar with network classes etc, but that has little to do with how to modify the code to get it to work with WiFiManager or to work like WiFiManager. Maybe I was not specific enough in my help request. Sometimes I know what I mean, but others do not, and that is my fault that I need to work on.

I will write a detailed report of what I did later, there is still one small glitch that I hope to resolve today.

The pics show mentions of 'captive portal', and 192.168.4.1. The code is in the WiFiManager library, and the comments are in the sample.config file for the webserver. I call these clues and the wording implies to me at least that this is a well known 'standard' interface.

Searching for 'captive portal' does yield some information but it is tough sledding. Specifically there is a Wiki that leads to RFC6585 and that has an Appendix B to do with Captive Portals. Now at least we know they are 'official' and 'standard', although it does talk about common use which is weaker than standard soooooo?

Anyway, it's been an interesting journey and I still know squat about WiFi, but I think I will have a complete solution soon. I can access the camera, the only work to be done is to form the IP automatically instead of me entering it manually.

Sorry for the ramble, just want to make sure everyone is on-board.

Screen Shot 2022 06 24 at 06.37.38
Screen Shot 2022 06 24 at 06.38.01
Screen Shot 2022 06 24 at 06.20.21

 

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@zander

Posted by: @zander

@frogandtoad Thanks, but I got the code working.

No idea where the 192.168.4.1 is coming from, I have attempted to search the library folders to see if I can find it but strangely a Mac computer does not have an easy way to do that. I think my search has been thorough, but not 100% sure.

That address is coming from the ESP32 device itself in AP mode, and your image even confirms it:

image
Posted by: @zander

Strange how nobody on the forum seems to know how the 192.168.4.1 'captive portal' feature is created. I can find all kinds of references to it but can't find the code that creates that ip address. It's not that important, I was just curious. 

That 'captive portal' you speak of is simply an ESP32 AP network - All it means is that it is a local AP network.  That IP ('192.168.4.1') is hard coded somewhere as the default for the ESP32, but you can change it if you want.

Posted by: @zander

I am familiar with network classes etc, but that has little to do with how to modify the code to get it to work with WiFiManager or to work like WiFiManager. Maybe I was not specific enough in my help request. Sometimes I know what I mean, but others do not, and that is my fault that I need to work on.

Yes (and indeed), but that's what you asked for 😉

Posted by: @zander

Searching for 'captive portal' does yield some information but it is tough sledding. Specifically there is a Wiki that leads to RFC6585 and that has an Appendix B to do with Captive Portals. Now at least we know they are 'official' and 'standard', although it does talk about common use which is weaker than standard soooooo?

Indeed... searching / researching / troubleshooting / investigating is a skill, in and of itself!
Here's what I found, which I believe explains it pretty well:

Captive Portal Information

Posted by: @zander

Anyway, it's been an interesting journey and I still know squat about WiFi, but I think I will have a complete solution soon. I can access the camera, the only work to be done is to form the IP automatically instead of me entering it manually.

This has nothing to do with WiFi, per se... it has everything to do with you wanting understand a specific library.  Connecting your ESP32 to WiFi as an STA or AP has nothing to do with WiFi Manager, which is library, specifically dedicated to password management.

Posted by: @zander

Sorry for the ramble, just want to make sure everyone is on-board.

10:4 Rubber Ducky 😉


ReplyQuote
Page 2 / 2