Notifications
Clear all

[Solved] Need help configuring WiFi

25 Posts
4 Users
2 Likes
1,571 Views
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 
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)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6957
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 🙂

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6957
Topic starter  

I think I am close.

09:33:53.733 -> *wm:[1] resetSettings
09:33:54.379 -> *wm:[1] SETTINGS ERASED
09:33:54.379 -> *wm:[1] AutoConnect
09:33:54.417 -> *wm:[2] ESP32 event handler enabled
09:33:54.417 -> *wm:[2] Connecting as wifi client...
09:33:54.417 -> *wm:[2] setSTAConfig static ip not set, skipping
09:33:54.417 -> *wm:[1] No wifi saved, skipping
09:33:54.417 -> *wm:[2] Connection result: WL_NO_SSID_AVAIL
09:33:54.417 -> *wm:[1] AutoConnect: FAILED
09:33:54.417 -> *wm:[2] Starting Config Portal
09:33:54.417 -> *wm:[2] AccessPoint set password is VALID
09:33:54.417 -> *wm:[2] Disabling STA
09:33:54.417 -> *wm:[2] Enabling AP
09:33:54.417 -> *wm:[1] StartAP with SSID: AutoConnectAP
09:33:54.956 -> *wm:[1] AP IP address: 192.168.4.1
09:33:54.956 -> *wm:[1] Starting Web Portal
09:33:54.956 -> *wm:[2] HTTP server started
09:33:54.956 -> *wm:[2] Config Portal Running, blocking, waiting for clients...
09:34:09.453 -> *wm:[2] <- Request redirected to captive portal
09:34:09.643 -> *wm:[2] <- HTTP Root
09:34:21.988 -> *wm:[2] NUM CLIENTS: 1
09:34:51.972 -> *wm:[2] NUM CLIENTS: 1
09:34:55.482 -> *wm:[2] <- Request redirected to captive portal
09:34:55.578 -> *wm:[2] <- HTTP Root
09:34:55.578 -> *wm:[2] <- Request redirected to captive portal
09:34:55.578 -> *wm:[2] <- HTTP Root
09:34:57.486 -> *wm:[2] <- HTTP Wifi
09:34:57.486 -> *wm:[2] WiFi Scan SYNC started
09:35:02.635 -> *wm:[2] WiFi Scan ASYNC completed in 5122 ms
09:35:02.635 -> *wm:[2] WiFi Scan ASYNC found: 5
09:35:02.635 -> *wm:[2] WiFi Scan completed in 5122 ms
09:35:02.635 -> *wm:[1] 5 networks found
09:35:02.635 -> *wm:[2] AP: -55 RonsWiFi
09:35:02.635 -> *wm:[2] AP: -79 TW2
09:35:02.635 -> *wm:[2] AP: -79 TW6
09:35:02.635 -> *wm:[2] AP: -85 TW4
09:35:02.635 -> *wm:[2] AP: -92 TW1
09:35:02.809 -> *wm:[2] <- Request redirected to captive portal
09:35:02.809 -> *wm:[2] <- HTTP Root
09:35:13.816 -> *wm:[2] <- HTTP WiFi save
09:35:13.816 -> *wm:[2] processing save
09:35:15.841 -> *wm:[2] Connecting as wifi client...
09:35:15.841 -> *wm:[2] setSTAConfig static ip not set, skipping
09:35:15.841 -> *wm:[1] Connecting to NEW AP: RonsWiFi
09:35:15.922 -> *wm:[1] connectTimeout not set, ESP waitForConnectResult...
09:35:19.591 -> *wm:[2] [EVENT] WIFI_REASON: 15
09:36:15.876 -> *wm:[2] Connection result: WL_DISCONNECTED
09:36:15.876 -> *wm:[0] [ERROR] Connect to new AP Failed
09:36:15.876 -> *wm:[2] Processing - Disabling STA
09:36:15.876 -> *wm:[2] NUM CLIENTS: 1
09:36:15.876 -> *wm:[2] <- Request redirected to captive portal
09:36:15.876 -> *wm:[2] <- Request redirected to captive portal
09:36:16.092 -> *wm:[2] <- HTTP Root

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6957
Topic starter  

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

09:44:26.952 -> *wm:[2] WiFi Scan SYNC started
09:44:32.068 -> *wm:[2] WiFi Scan ASYNC completed in 5108 ms
09:44:32.068 -> *wm:[2] WiFi Scan ASYNC found: 8
09:44:32.068 -> *wm:[2] WiFi Scan completed in 5109 ms
09:44:32.068 -> *wm:[1] 8 networks found
09:44:32.068 -> *wm:[2] DUP AP: TW6
09:44:32.068 -> *wm:[2] DUP AP: TW1
09:44:32.068 -> *wm:[2] AP: -50 RonsWiFi
09:44:32.068 -> *wm:[2] AP: -69 TW6
09:44:32.068 -> *wm:[2] AP: -71 TW2
09:44:32.068 -> *wm:[2] AP: -83 TW4
09:44:32.068 -> *wm:[2] AP: -85 TW1
09:44:32.068 -> *wm:[2] AP: -89 TW3
09:44:32.150 -> *wm:[2] <- Request redirected to captive portal
09:44:32.150 -> *wm:[2] <- HTTP Root
09:44:39.379 -> *wm:[2] <- HTTP WiFi save
09:44:39.379 -> *wm:[2] processing save
09:44:41.387 -> *wm:[2] Connecting as wifi client...
09:44:41.387 -> *wm:[2] setSTAConfig static ip not set, skipping
09:44:41.387 -> *wm:[1] Connecting to NEW AP: RonsWiFi
09:44:41.505 -> *wm:[1] connectTimeout not set, ESP waitForConnectResult...
09:44:42.811 -> *wm:[2] Connection result: WL_CONNECTED
09:44:42.811 -> *wm:[1] Connect to new AP [SUCCESS]
09:44:42.811 -> *wm:[1] Got IP Address:
09:44:42.811 -> *wm:[1] 192.168.0.123
09:44:42.811 -> *wm:[2] shutdownConfigPortal
09:44:42.811 -> *wm:[2] <- Request redirected to captive portal
09:44:42.900 -> *wm:[2] restoring usermode STA
09:44:43.833 -> *wm:[2] wifi status: WL_CONNECTED
09:44:43.867 -> *wm:[2] wifi mode: STA
09:44:43.867 -> *wm:[2] configportal closed
09:44:43.867 -> *wm:[1] config portal exiting
09:44:43.867 -> connected...yeey 🙂

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6957
Topic starter  

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

09:56:31.507 -> *wm:[2] WiFi Scan ASYNC completed in 5121 ms
09:56:31.507 -> *wm:[2] WiFi Scan ASYNC found: 5
09:56:31.507 -> *wm:[2] WiFi Scan completed in 5122 ms
09:56:31.507 -> *wm:[1] 5 networks found
09:56:31.507 -> *wm:[2] AP: -59 RonsWiFi
09:56:31.627 -> *wm:[2] AP: -72 TW2
09:56:31.627 -> *wm:[2] AP: -78 TW6
09:56:31.627 -> *wm:[2] AP: -89 TW4
09:56:31.627 -> *wm:[2] AP: -92 TW3
09:56:34.871 -> *wm:[2] NUM CLIENTS: 1
09:56:36.535 -> *wm:[2] <- Request redirected to captive portal
09:56:36.631 -> *wm:[2] <- Request redirected to captive portal
09:56:39.585 -> *wm:[2] <- Request redirected to captive portal
09:56:40.417 -> *wm:[2] <- HTTP WiFi save
09:56:40.417 -> *wm:[2] processing save
09:56:42.422 -> *wm:[2] Connecting as wifi client...
09:56:42.422 -> *wm:[2] setSTAConfig static ip not set, skipping
09:56:42.422 -> *wm:[1] Connecting to NEW AP: RonsWiFi
09:56:42.545 -> *wm:[1] connectTimeout not set, ESP waitForConnectResult...
09:56:43.747 -> *wm:[2] Connection result: WL_CONNECTED
09:56:43.747 -> *wm:[1] Connect to new AP [SUCCESS]
09:56:43.747 -> *wm:[1] Got IP Address:
09:56:43.747 -> *wm:[1] 192.168.0.123
09:56:43.747 -> *wm:[2] shutdownConfigPortal
09:56:43.823 -> *wm:[2] restoring usermode STA
09:56:44.798 -> *wm:[2] wifi status: WL_CONNECTED
09:56:44.798 -> *wm:[2] wifi mode: STA
09:56:44.798 -> *wm:[2] configportal closed
09:56:44.798 -> *wm:[1] config portal exiting
09:56:44.798 ->
09:56:44.798 -> WiFi connected
09:56:44.798 -> Camera Ready! Use 'http://192.168.0.123' to connect

 

BAZINGA!!!

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@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

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6957
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

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@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
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6957
Topic starter  

@frogandtoad @Inq @byron I just wanted to do a quick follow up. 

I was searching for a WiFi related thing and stumbled across the well known randomnerds website. I know them for their projects, but did not know they have an excellent tutorial on WiFi written for real noobies like me. Now I have something to get my teeth in.

I finally got the sketch in question I started with working by removing 200 lines of code and replacing with a half dozen plus a few misc adjustments in a few other modules. Obviously I am using a library and it does all the work and I suspect more of the couple hundred lines I removed. Thanks for your patience, it was a trip!

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
frogandtoad reacted
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad @Inq @byron I just wanted to do a quick follow up. 

I was searching for a WiFi related thing and stumbled across the well known randomnerds website. I know them for their projects, but did not know they have an excellent tutorial on WiFi written for real noobies like me. Now I have something to get my teeth in.

I finally got the sketch in question I started with working by removing 200 lines of code and replacing with a half dozen plus a few misc adjustments in a few other modules. Obviously I am using a library and it does all the work and I suspect more of the couple hundred lines I removed. Thanks for your patience, it was a trip!

Great to hear, Ron!
There are many great tutorials on that site, and it's a great resource for anyone interested in the ESP* devices.

Cheers


   
ReplyQuote
Page 2 / 2