Notifications
Clear all

[Solved] Need help configuring WiFi

Page 1 / 2

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

I am totally ignorant of WiFi and networking terminology and unable to learn it due to brain injury.

I am trying to get the new esp32cam webserver working but can not figure out the WiFi. I am including the relevant code snippets, but the entire project can be found on github Here

There is a sample config to be copied to myconfig.h, here is the relevant part with some while space removed for brevity. The rest of the file is about camera settings only.

/*
 *  Rename this example to 'myconfig.h' and fill in your details.
 *
 *  The local config is in the '.gitignore' file, which helps to keep details secret.
 */
/* Give the camera a name for the web interface */
#define CAM_NAME "ESP32 camera server"
/*
 * Give the network name
 * It will be used as the hostname in ST modes
 * This is the name the camera will advertise on the network (mdns) for services and OTA
 */
#define MDNS_NAME "esp32-cam"
/*
 *    WiFi Settings
 *
 *    For the simplest connection to an existing network
 *    just replace your ssid and password in the line below.
 */
struct station stationList[] = {{"my_ssid","my_password", true}};
/*
 * You can extend the stationList[] above with additional SSID+Password pairs

struct station stationList[] = {{"ssid1", "pass1", true},
                                {"ssid2", "pass2", true},
                                {"ssid3", "pass3", false}};
 * Note the use of nested braces '{' and '}' to group each entry, and commas ',' to separate them.
 *
 * The first entry (ssid1, above) in the stationList is special, if WIFI_AP_ENABLE has been uncommented (below)
 * it will be used for the AccessPoint ssid and password. See the comments there for more.
 *
 * The 'dhcp' setting controls whether the station uses DHCP or static IP settings; if in doubt leave 'true'
 *
 * You can also use a BSSID (eg: "2F6A", a colon separated mac address string) in place of
 * the ssid to force connections to specific networks even when the ssid's collide,
 */
/* Extended WiFi Settings */
/*
 * If defined: URL_HOSTNAME will be used in place of the IP address in internal URL's
 */
// #define URL_HOSTNAME "esp32-cam"
/*
 * Static network settings for client mode
 *
 * Note: The same settings will be applied to all client connections where the dhcp setting is 'false'
 * You must define all three: IP, Gateway and NetMask
 */
// warning - IP addresses must be separated with commas (,) and not decimals (.)
// #define ST_IP      192,168,0,123
// #define ST_GATEWAY 192,168,0,2
// #define ST_NETMASK 255,255,255,0
// One or two DNS servers can be supplied, only the NTP code currently uses them
// #define ST_DNS1 192,168,0,2
// #define ST_DNS2 8,8,8,8
/*
 *  AccessPoint;
 *
 *  Uncomment to enable AP mode;
 *
 */
// #define WIFI_AP_ENABLE

/*  AP Mode Notes:
 *
 *  Once enabled the AP ssid and password will be taken from the 1st entry in the stationList[] above.
 *
 *  If there are further entries listed they will be scanned at startup in the normal way and connected to
 *  if they are found. AP then works as a fallback mode for when there are no 'real' networks available.
 *
 *  Setting the 'dhcp' field to true for the AP enables a captive portal and attempts to send
 *  all visitors to the webcam page, with varying degrees of success depending on the visitors
 *  browser and other settings.
 */
// Optionally change the AccessPoint ip address (default = 192.168.4.1)
// warning - IP addresses must be separated with commas (,) and not decimals (.)
// #define AP_ADDRESS 192,168,4,1

// Uncomment this to force the AccessPoint channel number, default = 1
// #define AP_CHAN 1

/*
 *  Port numbers for WebUI and Stream, defaults to 80 and 81.
 *  Uncomment and edit as appropriate
 */
// #define HTTP_PORT 80
// #define STREAM_PORT 81

Also, here is a snippet of the .ino file that tells us a little about the operation.

// Primary config, or defaults.
#if __has_include("myconfig.h")
struct station {
  const char ssid[65];
  const char password[65];
  const bool dhcp;
};  // do no edit
#include "myconfig.h"
#else
#warning "Using Defaults: Copy myconfig.sample.h to myconfig.h and edit that to use your own settings"
#define WIFI_AP_ENABLE
#define CAMERA_MODEL_AI_THINKER
struct station {
  const char ssid[65];
  const char password[65];
  const bool dhcp;
}
stationList[] = {{"ESP32-CAM-CONNECT", "rcapass", true}};
#endif

I want it to work like WiFiManager (see Bill's video) but it doesn't have to be as fancy with saving the creds in EEPROM, nice feature but not mandatory.

What I am hoping to get is (in my non tech language)

1. From my laptop connected to the internet change my wifi ssid to the one on the esp32cam

2. I browse to some address (I don't know how I determine that address)

3. I then click a magic button and the esp32 establishes a connection to my local net at 192.168.0.xxx

4. I then resume my normal ssid so I can surf the net and still see the camera on 192.168.0.xxx

That is about how WiFiManager works and I changed about 3 lines of code in the original esp32cam to convert it to WiFiManager but have no clue how to convert the new version of the esp32cam-webserver.

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.

 

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


Quote
Inq
 Inq
(@inq)
Reputable Member
Joined: 3 months ago
Posts: 394
 

Obviously, I won't rehash what we already went over in multiple public and private posts, but I was wondering why the focus on WiFi Manager.  For most people that are making something for themselves, hard-coding the credentials is more than satisfactory.  The only reason, I can think of using WiFi Manager is if:

  1. You want to make a product to sell or give away to non-developers.
  2. For security reasons, you routinely change your home/RV's router password.  Having WiFiManager would keep you from having to re-compile it.  
  3. Just intellectual curiosity of how to do it.

I just can't see another practical use case.  Am I missing something?

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, Access Point Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


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

@inq That's too bad, I thought I was clear that I 'got' none of that, which is why I posted here in the hope that someone would help me since so far I have made no real progress.

The reason for the focus on wiFi Manager is I saw Bill's video and saw that it solved the hard coded creds issue.

Since I plan on building game cameras it is possible that somebody could find one and take it home. If it was a tech smart kid then he would have my creds.

I may give some away to friends.

Why would I change my router password?

At the moment, I can't connect to the new software other than by using my router creds.

 

 

 

 

 

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


ReplyQuote
Inq
 Inq
(@inq)
Reputable Member
Joined: 3 months ago
Posts: 394
 
Posted by: @zander

Since I plan on building game cameras it is possible that somebody could find one and take it home. If it was a tech smart kid then he would have my creds.

I may give some away to friends.

Why would I change my router password?

At the moment, I can't connect to the new software other than by using my router creds.

I'll work backwards...

  1. Changing passwords - Corporations require employees to change passwords routinely.  Banks suggest you do it also for your accounts.  Some do change their router's password for the same reasons.
  2. Give away and allow - That one certainly makes sense.  Hadn't heard you were doing anything beside in your coach. 
  3. Someone finding the camera in the wild - Not a good excuse.  Anyone capable of digging out the password hardcoded would find it easier in the EEPROM area.  In fact that would be the first place they look for it.  Losing one in the wild... would justify (1).

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, Access Point Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


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

When I worked for a corp, of course we changed passwords frequently. The problem is I have 230 passwords all unique and I don't know what they are, mostly 32 chars of 70 plus symbols. I have around 410 emails including mostly on my own domain but also includes gmail.com, yahoo.ca and icloud.com for a total of about a dozen PLUS the new private/hidden email ids that icloud and yahoo give me. So changing them is a nightmare. Since nobody can stop state sanctioned actors it's a waste of time to try, and I don't see amateurs cracking my 70^32 passwords. In addition, a lot of them are relays to another account, and my domain emails are cloaked per email exchange. Both I and my wife have had our Visa cards compromised, and it was caught by the bank. They called us to tell us and re-issued the cards. Mine was related to some phone purchases, I don't recall the details, and my wife's was connected to Bell as well from our previous location several years ago. It looks to me like both were inside jobs, but since we are Canadian, we suffered no loss (it's the law in Canada that the banks cover the loss) and only the inconvenience of switching cards.

As far as the wild loss, I was pulling your chain, of course I would either not bother at all, or use a throwaway like me@home.com/12345.

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

I am totally ignorant of WiFi and networking terminology and unable to learn it due to brain injury.

I am trying to get the new esp32cam webserver working but can not figure out the WiFi. I am including the relevant code snippets, but the entire project can be found on github Here

There is a sample config to be copied to myconfig.h, here is the relevant part with some while space removed for brevity. The rest of the file is about camera settings only.

[snipped code example]

It's always difficult to understand a custom library, if you're not into what they're trying to achieve, so it's hard to diagnose the code, other than any syntax/semantic errors, which I don't think is whats bothering you here.

Lets try to clarify some points first:

Point - 1)
Do you mean.. you want to connect to a different WiFi network from your laptop (i.e:- an ESP32 Network, AP / Station ?)

Point - 2)
Do you mean to go to the address of the ESP32 device web page? or some internet address web page?

Point - 3)
Click a button on an internet accessed web page to establish a local connection? (from which page, see above)

Point - 4)
Resume, meaning that you disconnect from the ESP32 to view normal internet? (we'll need to get back to this one especially, because if that's the case, it doesn't make any sense).

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.4.(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

This post was modified 4 days ago 4 times by frogandtoad

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

@zander

Posted by: @zander

I don't see amateurs cracking my 70^32 passwords.

How long does it take to type that out? 😀


ReplyQuote
byron
(@byron)
Prominent Member
Joined: 3 years ago
Posts: 878
 

@zander

stepping back from your delve into the library you may use think of your problem like this.  You can connect your mac (or whatever) to your router (an Access Point) or you can connect to the ESP32 access point.  But thats no good, you want to connect to two Access Points at once, so how to do this.  One network can connect to another by means of a network bridge.  Your router probably has the ability to bridge to another router or AP.    Now it may be possible to get your ESP AP to bridge to your Router you would need to research this, but it would surely be possible to connect your ESP AP to some old router you may have lurking in the depths of a cupboard and bridge that to your home router.

So maybe a bit of research into network bridging and a hunt into what may be lurking in your pile of old stuff bin will prove fruitful.  😎 

This post was modified 4 days ago by byron

Inst-Tech liked
ReplyQuote
Ron
 Ron
(@zander)
Noble Member
Joined: 2 years ago
Posts: 2262
Topic starter  
Posted by: @frogandtoad

@zander

Posted by: @zander

I am totally ignorant of WiFi and networking terminology and unable to learn it due to brain injury.

I am trying to get the new esp32cam webserver working but can not figure out the WiFi. I am including the relevant code snippets, but the entire project can be found on github Here

There is a sample config to be copied to myconfig.h, here is the relevant part with some while space removed for brevity. The rest of the file is about camera settings only.

[snipped code example]

It's always difficult to understand a custom library It's NOT a library, it's an app, if you're not into what they're trying to achieve, so it's hard to diagnose the code, other than any syntax/semantic errors, which I don't think is whats bothering you here.

Lets try to clarify some points first:

Point - 1)
Do you mean.. you want to connect to a different WiFi network from your laptop (i.e:- an ESP32 Network, AP / Station ?)

YES, I want one browser like I am in right now connected to DBWS for instance while another browser or window in same browser is connected to the camera. Bill did that in his video, I have done it with V1 of the camera app, I just need to understand how to make V4 do it.

Point - 2)
Do you mean to go to the address of the ESP32 device web page? or some internet address web page? Sorry I don't understand your question, other than YES, both.

Point - 3)
Click a button on an internet accessed web page to establish a local connection? (from which page, see above) ???????????

Point - 4)
Resume, meaning that you disconnect from the ESP32 to view normal internet? (we'll need to get back to this one especially, because if that's the case, it doesn't make any sense). Really, that's how I have seen it work, check Bill's WiFiManager video.

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.4.(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

 

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  
Posted by: @byron

@zander

stepping back from your delve into the library

What library, the esp32cam-webserver is an app, NOT a library. It uses the standard WiFi library, I just need to know which WiFi api call with what arguments in what order

you may use think of your problem like this.  You can connect your mac (or whatever) to your router (an Access Point) or you can connect to the ESP32 access point. 

HOW? and I mean look at the code and tell me what 'myconfig.h lines to change to what please

But thats no good, you want to connect to two Access Points at once, so how to do this.  One network can connect to another by means of a network bridge.  Your router probably has the ability to bridge to another router or AP.    Now it may be possible to get your ESP AP to bridge to your Router you would need to research this, but it would surely be possible to connect your ESP AP to some old router you may have lurking in the depths of a cupboard and bridge that to your home router.

So maybe a bit of research into network bridging and a hunt into what may be lurking in your pile of old stuff bin will prove fruitful.  😎 

That might be right, but Bill did it without the bridge, have you watched the video?

 

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


ReplyQuote
byron
(@byron)
Prominent Member
Joined: 3 years ago
Posts: 878
 

@zander 

OK your code was not a library, its a app.  So what.  Read the words "stepping back from your delve... " That means sod your current approach how about thinking differently.  It was not aimed at giving you any hints on changing your myconfig.h file. You surely don't need any instructions on connecting to the ESP32 as an access point, if its not in Bill video there lots of other examples.  And you are free to say sod thinking differently, I'm going to continue to think along my current path. (And I think thats exactly what you just said 😎)  

Goodbye. 


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

The attached pic is from Bill's blog re the WiFiManager. The reason I posted this is sometimes the V4 server will tell me to connect to that same 192.168.4.1 address BUT I cannot connect. Apparently it is some sort of standard, notice Bill did nothing to make that address. I have Bill's code, and know how to run the broken esp32cam-webserver sketch. Since I have run it before, it's 'remembering' the ip to use so I will try to see if I can un-remember it in order to get an audit trail on Serial for the known working example of what I want. Maybe then we will have a common language because at this point I am still clueless.

Further down in Bill's blog I saw this

After connecting, open a web browser and go to 192.168.4.1. On many phones and tablets, you will be automatically directed there.

Again, 'automatically' because why? This is further reinforcement of the concept that 192.168.4.1 is a 'special' address hard coded into ????

I am going to run the WiFiManager simple demo and grab the serial output to post here so someone can tell me the equivalent manual settings to cause the same results 

Screen Shot 2022 06 23 at 05.55.48

 

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  
Posted by: @byron

@zander 

OK your code was not a library, its a app.  So what.  Read the words "stepping back from your delve... " That means sod your current approach how about thinking differently.  It was not aimed at giving you any hints on changing your myconfig.h file. You surely don't need any instructions on connecting to the ESP32 as an access point, if its not in Bill video there lots of other examples.  And you are free to say sod thinking differently, I'm going to continue to think along my current path. (And I think thats exactly what you just said 😎)  

Goodbye. 

I don't understand what you are saying.

I am asking for help to make the required modifications to the V4 of esp32cam-webserver myconfig.h file. It has lot's of comments but I don't understand why my choices don't work and what they should be. You said

You surely don't need any instructions on connecting to the ESP32 as an access point,

BUT yes I do. Remember I am autistic and sometimes I can't 'get it'. I was told you are an expert, so was hoping you would look at the wifi config settings in the myconfig.h file to tell me what to change to what, every combination I try does not work. The serial out tells me to connect to an IP aften it's 192.168.4.1 (which apparently is 'special') but I can't connect. Other times depending on what I have changed it says 192.168.0.xxx but again nothing happens.

If somewhere there is an example showing the WiFi API calls in the order to call them and with what arguments then I might have a chance, but now I am guessing based on the comments in the code I posted in the OP.

 

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


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

I was told you are an expert,

By whom I wonder, you are making things up I think.  

But to connect to an access point you need to know its SSID (or network name).  Your ESP32 in AP mode should be broadcasting a SSID, (although it can be made not to, but it should still have a SSID.  So goto your wifi settings and choose 'other networks' to hopefully find the ESP32's SSID on the list. If its not showing (and presuming you know the SSID of your ESP32) choose 'other' (on the mac) and enter the network name manually.  Of course you will also need to input the networks password.  Having selected  that network (and of course you will no longer be connected to your home network) then you should be able to connect to it with the network address that the ESP32 has assigned itself to. (presumably the 192.168.4.1 you mention).

So thats just a comment from a retired hobby dabbler.  You will have to look elsewhere for your expert. I hope you get it all sorted.


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

@byron I am learning, but so far a snail is beating me. I am trying very hard to go step by step and captuying the serial output. I just started over at step 1 again since I forgot to make a notr if it worked or not. I think I am making progress, and if attempts failed counts I am 99.99999% of the way there.

I saw one very strange result, the AP name in the main sketch is ESP32-CAM-CONNECT when NO config is suplied, but what I saw was what I think is called a chip AP. Apparently every ESP32 has a unique ID and they use that. I see the utility of that, but the sketch comments are wrong. Just exactly why I normally delete or otherwise ignore comments in code.

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.

0759.632 -> Starting WiFi
0759.632 -> Known external SSIDs: 'RonsWiFi'
0759.632 -> MAC address: 0C1C
0759.632 -> Scanning local Wifi Networks
0704.482 -> 4 networks found
0704.482 -> 1 : [E8EF] RonsWiFi (-50) - Known!
0704.482 -> 2 : [44DB] TW2 (-68)
0704.482 -> 3 : [1848] TW4 (-73)
0704.482 -> 4 : [445B] TW6 (-82)
0704.482 -> Connecting to Wifi Network 1: [E8EF] RonsWiFi
0705.014 -> ..Client connection succeeded
0705.503 -> IP address: 192.168.0.123
0705.503 -> Netmask : 255.255.255.0
0705.503 -> Gateway : 192.168.0.1
0705.503 -> Setting httpURL
0707.506 -> Setting up OTA
0707.506 ->
0707.506 -> No OTA password has been set! (insecure)
0707.506 ->
0707.541 -> Added HTTP service to MDNS server
0707.541 -> Time functions disabled
0708.260 -> Lamp: 0%, pwm = 0
0708.260 -> Starting web server on port: '80'
0708.260 -> Starting stream server on port: '81'
0708.260 ->
0708.260 -> Camera Ready!
0708.260 -> Use 'http://192.168.0.123/' to connect
0708.260 -> Stream viewer available at 'http://192.168.0.123:81/view'
0708.301 -> Raw stream URL is 'http://192.168.0.123:81/'

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


ReplyQuote
Page 1 / 2