Introduction to ESP...
 
Notifications
Clear all

Introduction to ESP32 - Getting Started

35 Posts
11 Users
8 Likes
4,770 Views
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad Ok, well I am certainly aware of networks that exist outside the internet, but somehow I never noticed the term soft-ap and never saw the softap method used. I am probably overthinking this or somehow confusing myself. Thanks for taking the trouble to point me in the right direction. I have used the RandomNerds both for education and to point newbies to, I think I need to go back and read some and pay attention a little more. Slowly but surely I learn especially with the help of understanding patient friends.

I'm still learning a lot about the ESP32's myself, and the best way to learn is to read along and practice with the tutorials, and then ask questions when stuck - Practice makes perfect as they say.

Time for some sleep!

Cheers


   
Ron reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @tedbear

I've watched Bills excellent tutorial about getting started with the ESP32.  I thought I understood the two different Wi-Fi approaches, Station and Soft Access Point.  I gathered that Station requires Internet Access and the ESP32 board and my phone or computer use the Internet to communicate back/forth.  I tried the examples and they seem to work.

I also gathered that Soft Access Point means that the Internet is not needed or used.  The communication between my ESP32 board and say my phone is done directly.  The advantage being that internet access is not needed.  The disadvantage can be limited range.

I have been successful in using an ESP32 Dev board in Soft Access Point to communicate with my iPhone.  I have noticed that when the connection app is active, the ESP32 shows as a possible connection on my iPad.  However the app will not work with it as long as the phone is working with it.  I can see that this would be good especially in my situation.  Is this always the case that in Soft Point Access Mode that the ESP32 can only work with one other device at a given time?

Now I read about Access Points being "hotspots".  I thought "hotspots" referred to using another device for the WiFi Internet connection.  For example, I don't have a cellular plan for my iPad so in the house it can use my WiFi network there.  In an area without Internet Access the iPad can use my iPhone as a hotspot via its cellular connection.

Are Soft Access Point and Access Pont two different things?  Most things I read seem to assume that internet access is available and that one will be using it.  This is not always the case down on the farm. 

@zander - My ears are burning.  😉  - I'll take a stab at explaining this.  This stuff is not trivial and if it's your first blush using an ESP8266 or ESP32, some concepts are strange to what you may have experience before.  I'll bulletize it so you can ask for clarification easily if I fail to explain it for good enough for you.

  1. I'll start with the definition of a router.  This is a common device with anyone getting Internet service.   Most ISP's provide one with their service.  In its most basic definition, a router simply connects computers together so they can transfer data/files with each other.  The ones that ISP's provide also allow your computers at home to connect to computers on the Internet.
  2. When you browse to a URL (www.Google.com) your browser is requesting a file/data from some other computer on the Internet.
  3. Most routers can connect computers together with Ethernet (wires) and/or WiFi.
  4. If ISP's service goes down (mine does every day) your computers and other devices connected to your router can still transfer data to each other.  They just can't go to the Internet and get files from those computers.
  5. ESP8266 or ESP32 MPU's support two connection modes:  Soft Access Point or Station Access Point.  The hardware supports using them independently or both at the same time.  It all depends on the library you might be using OR if you code it yourself.
  6. Soft AP - Is where your ESP8266/ESP32 acts just like your home router.  One or more computers/devices can connect to it.  For an ESP8266, the maximum number of devices is eight.  ESP32 is more, but still finite.  Since the ESP does not have a way to connect to your ISP, you can not access Internet resources.
  7. Station AP - This is where your ESP is acting like a computer and is merely connecting to your router.  If that router is also connected to the Internet, the ESP can get data from the Internet.  It your router is not also connected to the Internet, all the other computers connected to your router can still communicate with your ESP.  Again... its acting like another peer computer on your network.
  8. Web Server - Again, it depends on the library you're using or if you write it yourself to expose some kind of web server.  This resides on your ESP and fundamentally, it is the same  as the web servers that expose web pages on the Internet.  This software allows a totally different kind of connection than the ones discussed above.  These are momentary type connections made by your browser.  Let's call them HTTP's to distinguish them from the AC type connections.
  9. When your Browser requests a page, it makes a HTTP requesting a file.  The Web Server delivers the file to your browser and disconnects.  You browser displays it to you.  The browser is just a program... like Microsoft Word when it displays a doc file.  
  10. If your Web Server AND AP Connections Server is written a certain way, you can retrieve web pages just like those coming from the Internet.  There is fundamentally no difference.  Any thing you have seen on the Internet can reside on your ESP and be served up just like it was an Internet web site.  With the limitation of the size of the "hard disk" available on an ESP... 3 MB is typical... 15 MB on a ESP8266 Wemos D1 Mini Pro.  
  11. All your other browsing devices whether they are connected to Soft AP directly or through your own home router via the Station AP... will receive those files and display them.  Depending on you web pages are designed (HTML, CSS, JavaScript files) you can connect at hundreds of browsers to it.  I've abused my server library with 8 different devices connected directly via the Soft AP, each with a browser retrieving the web pages from the ESP's web server while simultaneously connecting 60 browsers instances on a couple of desktop computers connected to my home router that the ESP was also connected using the Station AP mode.  It was slow as mud, but it worked!

Hope this helps.  Let me know if you need clarification on any of this.

VBR,

Inq

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi 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
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @zander

@frogandtoad In your picture re ESP32 WiFi modes I don't see 'Soft AP'. I also don't see in that definition where the internet connects. This is why I get confused by all these terms. In fact upon reading it again, the definitions are circular. Stations connect to AP that connect to stations. Did terminology change at some point and I didn't notice? It gets super confusing when I see @Inq with his SEE PIC attached one line of code and both a SoftSSID and a RouterSSID. I am 100% sure I am missing a key point somewhere and would really like to get myself educated.

Screen Shot 2022 06 07 at 06.59.32

 

The snippet you showed... is one way of many to initialize the InqPortal server.  In this example, it is:

  1. Creating a Soft Access Point (acting like a router) so you can connect devices directly to it.  The name is MySoftSSID.  It has no password (NULL) so anyone can connect to it without knowing the password.  
  2. It it also attempting to connect to your home router expecting it's name/password to be myRouterSSID / myRouterPassword to form the Station AP.
  3. The web server would then be able to serve web pages to any device connected directly or through your home router.

All those values can be left NULL or blank and defaults will be used.  You can connect to the default Soft AP and browse to an Administration page built-in to every InqPortal project... and configure the Station AP to your router... just like WiFiManager does.  That way you don't have to hard-code the credentials into the INO file.

 

Edit - Oh!  I should mention since we're in the ESP32 thread, my library does not work with ESP32.  It only works with ESP8266.

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi 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


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

@inq I will need to read this a few more times to burn the knowledge into my brain, but at first read it is starting to make sense now. Between @frogandtoad and you I think I will finally today have a better understanding. Thanks for taking the time for such a detailed explanation.

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

@inq I will need to read this a few more times to burn the knowledge into my brain, but at first read it is starting to make sense now. Between @frogandtoad and you I think I will finally today have a better understanding. Thanks for taking the time for such a detailed explanation.

It didn't occur to me at the time of my last post on this, and I naturally assumed that svr.begin(bunch of params...) in the snippet shown was the code of an ESP32 overloaded constructor, but it seems that is not the case, given Inq's Edit, and I am unable to find such an overload.

Cheers


   
ReplyQuote
(@tedbear)
Member
Joined: 5 years ago
Posts: 62
 

@inq Thank you so much for the very detailed reply.  I have read it a few times and find that much of it agrees with my previous thinking but there are many other situations that I need to think through.  For my current ESP32 projects, I use two ESP32 boards.  One on my old Shed where it works with two door openers of the UP, DOWN, STOP type.  The other is in my Shop which works with a single door opener of the UP, DOWN, STOP type and the shop lights via a contactor.  Each of these is setup in the Soft Access Point mode (#6 below) since Internet service is not available at either location.  I used the RemoteXY website to design and create the GUI for a phone or tablet (either IOS or Android).  This sketch is uploaded to the board.  Each Soft Access Point was given an appropriate name within the sketch.  These show up under WiFi in my iPhone, iPad and Android Tablet.  I choose the appropriate one and launch the RemoteXY app on the phone or tablet.  Once communication is established, the GUI is transferred from the ESP32 to the device and it can be used. I notice that if I am communicating with the ESP32 with my iPhone for example, the connection will still show up on the iPad but when I try to launch the RemoteXY app on the iPad, it will complain and will not connect.  Is this the situation in general or is this a block that RemoteXY has implemented?  The app will not allow more than one device to work with that ESP32 at a time (which is good in this case for safety).  Thanks again for the detailed reply.

IMG 1323[1]

 

IMG 1322[1]

 


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

@tedbear - I found the RemoteXY website and skimmed their "How it works".  It is not really telling me "how it works" under the covers.  I'm getting most of my understanding of what they're doing from your description above.   Let me confirm... that your GUI is stored on your ESP32... then you must use their RemoteXY application on your phone to connect to the ESP32 and it "brings" down your designed GUI and runs it.  You upload changes to your ESP32 app and they are reflected on your phone the next time you use it???  

If all that is the case, it almost sounds like they are mimicking the exact behavior of a generalized Web Server / Browser relationship, except they are making it proprietary and you are locked into only the GUI elements they provide to you.  Their phone app is directly replacing the browser (Safaria, Chrome, etc) and the ESP32 library makes your INO sketch mimic a subset of what a Web Server can.

In contrast, a generalized Web Server being run on an ESP32 lets you host your GUI content just like any mainstream Internet Web Server... the common ones are Apache, Microsoft's IIS, et al.  The content can then be anything you can dream since its using strait HTML, CSS, JavaScript, Images and publically available client side libraries and it is viewable/controllable by any browser, mobile or desktop.

Posted by: @tedbear

I notice that if I am communicating with the ESP32 with my iPhone for example, the connection will still show up on the iPad but when I try to launch the RemoteXY app on the iPad, it will complain and will not connect.  Is this the situation in general or is this a block that RemoteXY has implemented? 

The ESP32 (and ESP8266) is fully capable of hosting many clients at the same time on their SoftAP connections.  As I mentioned above, ESP8266 is 8 and I want to say the ESP32 is 12.  Although the effect is the same, I'd say it's more that they just didn't implement it, versus actively blocking the ability.

It is far harder for someone to code a true, generalized web server than just a single connection at a time, proprietary client/server.  For all I can tell, RemoteXY is simply making a strait TCP connection to interact with your phone.  Most of the tutorials on the Internet using the WiFi libraries available on the ESP32/ESP8266 show this latter.  None of the tutorials that I have seen (but I haven't looked in years) do the Full Monty to handle multiple browser clients at the same time and support things like a file system so you can upload new/different content, websockets for fast TCP communications or a connection manager like WiFiManager does.

I apologize for the shameless plug - But my library does all those things (and more) and would allow both your phone and tablet and your desktop and your laptop to all connect at the same time.  If you press a GUI button on one browser, all the others would reflect that the button was pressed on their GUI's.  The down side - My library only works on the ESP8266 processors even though several people have encouraged me to also implement it on the ESP32, (@zander especially 😆).

I hope this helps.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi 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
(@tedbear)
Member
Joined: 5 years ago
Posts: 62
 

@inq Thanks again for the detailed and quick response.  I notice you use the method of repeating what you thought I said to confirm your understanding of what I said.  This is a very successful technique that I've used myself many times. 

Your interpretations in your first paragraph are correct.  The GUI interface is created on the RemoteXY website.  A "starter" sketch is provided.  I can modify or add to the sketch as I see fit.  I edit it and change to my own Soft Access Point name/password and any other parts to the code that I feel necessary.  With this project I didn't need to add anything else. I compile and upload the sketch to my ESP32 board.  To use this with my phone, I first check that the phone is using the proper WiFi Soft Access Point which it usually does since I'm physically closest to it.  I then launch the RemoteXY mobile app on my phone or tablet.  The GUI screen is shown on the phone or tablet because it is transmitted from the ESP32 to the current device.  The GUI layout etc. does not "live" on the phone but is transferred each time from the ESP32 to the phone app.  I have been able to reverse engineer the screen layout to determine what values in their data array affect what.   I played detective and changed one value of their data array at a time to view the effect. I could then draw some conclusions as to what does what.  This allows me to go in and fine tune alignment of the buttons etc. although this is merely a cosmetic touch. 

The buttons, sliders, knobs etc that they have provided then produce some type of action.  If I am doing this on the phone and someone else tries to work with this same project on my iPad or Android, the WiFi connection will be shown.  It can be selected but when the RemoteXY mobile app on that device tries to communicate with the board, I get a "registration" error which prevents the party on the other device from interfering with me on the phone.  In my case of working with the door openers this is very desirable.  It could be dangerous to have more than one person working the doors at the same time. 

The RemoteXY concept is free as long as one uses it on a limited basis of four elements or less. For example, my shop GUI only uses four buttons.  My Shed GUI uses six so a yearly fee is required.  This fee covers a single or multiple devices under my user name.  Renewing the subscription for this year allowed me to use the more complex setups on all my devices.  They allow you to "test" a more complex project for 30 seconds without the subscription fee.  This may entice one to purchase the subscription.  The website can be a bit difficult at times due to the language barrier.  I don't believe English is the author's native tongue. 

Your library for working with several devices at the same time may be helpful in some future projects where sharing data or activities is desirable. 


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @tedbear

I notice you use the method of repeating what you thought I said to confirm your understanding of what I said.  This is a very successful technique that I've used myself many times. 

I've found that if I don't fully understand what someone is asking, I might accidentally give them information that is contrary to their understanding or experience... or that it totally wrong!  Got to make sure we're both on the same page... mostly, me being on your page.   🤣 

I noted before on one of your UI's that you just have the Up/Down buttons.  Do you not have some kind of of electrical safety stop like a standard garage does?  If not, I can certainly agree, having two controlling could be a big CF waiting to happen.  But... have you considered what might happen if the RemoteXY app goes down after pressing the down, but before you stop it?  A bug, or phone loses WiFi connection or even the phone runs out of juice could do something bad??? 

If you added some kind of sensors to your ESP32 that would know when to stop at top and bottom, would be an extra safety factor.  Also, it would negate any issues (except an argument) if two people were trying to control the door at the same time.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi 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


   
Inst-Tech reacted
ReplyQuote
(@tedbear)
Member
Joined: 5 years ago
Posts: 62
 

@inq You bring up some good points.  I do not have the "safety beam" sensors that most garage door openers have.  The opener could be equipped with them and if it were used in a commercial business setting I believe it would be required.  Since this is out on the farm these sensors are not required although they may be a good idea.  The opener itself has a limited safety feature in that when going UP, pushing any DOWN button will have no effect and the door continues to Open.  One must push the STOP button and then the DOWN button will start the close sequence. If the door is going down, pushing the UP button will cause it to stop, reverse and open.

I hadn't really thought about the "lost communication on the way down and I want to stop" scenario.  I actually did experience this with my original sketch and my "light" button on the GUI. The UP, DOWN and STOP buttons were programmed as momentary since a momentary pulse would trigger the desired action.  The "Lights" button was programmed as a switch to a relay that turned on the lights.  I found that although this allowed me to turn ON/OFF the lights as desired, the lights would go back off when the phone app lost communication with the ESP32 board for any reason.  Since that was not desirable, I went with a latching relay and changed the Light button to a momentary pulse also.  By using the latching relay, another system and/or a momentary pushbutton on the wall can toggle the lights. The "lights" will stay at their current status until another pulse comes along.

Some years ago I purchased some devices called GarageMate.  This device use a phone app and a small Bluetooth receiver that is wired in parallel with the momentary push button switch that many garage door openers use.  It in effect allows you to use the your phone to "push the button" to open/close the door.  I emailed the creator of the device and asked him about creating a device that would work with the UP, DOWN, STOP type door controllers that I have.  He said that it should be possible but he wanted to avoid that market since that type of opener was commonly used in commercial settings and he was concerned about liability issues.  I guess I'm flirting with some of those issues in my homemade approach.  


   
ReplyQuote
Mac-in-Memphis
(@mac-in-memphis)
Member
Joined: 2 years ago
Posts: 8
 

Hello, I'm throughly enjoying Bill's delves into the workings of the ESP32 functions!

My questions is in regard to connecting the ESP32 WiFi to an iPhone @tt mobile hotspot.

I've 'successfully' connected just ONCE,,,

but since then, the serial monitor only streams the

"Connecting to Mac's_iPhone ........". '...' ad infinitum.

In case anyone is interested, I'm refering to the sample code exercise for:

"Simple WiFi Server"  ie "WiFi Web Server LED Blink" 

"31.01.2017 by Jan Hendrik Berlin"

I can connect my laptop to the Hotspot, without any issues.

Tried rebooting all, no avail.

As a test, I've changed the hardcoded ssid/password for my home router network, and Blink on/off works..

Does anyone know if @tt trolls for this type of usage, then locks-out any subesequent login attempts?

Regards, Mac

If it is broken, anyway; then just take it completely apart and try to fix it.
you may learn something valuable from the ancient efforts of industrious others. /hms


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

@mac-in-memphis Need more informnation, like a link to the code you are trying to make work.

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
Mac-in-Memphis
(@mac-in-memphis)
Member
Joined: 2 years ago
Posts: 8
 

@zander 

Thank you for your reply & request for more information!

Please disregard.

I've found a setting switch within the iPhone Settings >> Personal Hotspot >> page V...

>>> there is a 'slider switch' to enable "Maximize Compatibility" ( _ >0 )

 

For now, that seems to have solved the issue!   It's working 🙂

But as an FYI to your question:

In Bill's page (his link is below),,,

The code is about half way down that long page, within it's indented window under the section titled:

Simple WiFi Server

https://dronebotworkshop.com/esp32-intro/

 

Thanks again!

Mac

If it is broken, anyway; then just take it completely apart and try to fix it.
you may learn something valuable from the ancient efforts of industrious others. /hms


   
ReplyQuote
(@bob207)
Member
Joined: 3 years ago
Posts: 16
 

I am not sure if this is the place to put this but I have a question about the video.

I have an ESP32 feather that looks to work ok. Following the instructions I can load the wifiaccesspoint sketch, run it and see it with my phone. If I delete the password as explained in the video it connects to my phone ok. If I go to 192.168.4.1 the page just times out and says 'this site can't be reached'.

Can anyone see what I am doing wrong?

Thanks,

Bob.


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

@bob207 This topic is for the video Bill made. Start a new topic probably under help wanted, or esp32. A quick answer is NO, we can't SEE what you are doing wrong. You will beed to read the help on the right side of this page to learn to post the code but keep it as short as possible. Take a screen print of your PC if it shows errors, if errors on your phone screen print transfer and upload here. The more info we have the better chance we can solve it but maybe you can do some self help by googling the error you got. Since you are playing with networks, your network training will come in handy.

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
Page 2 / 3