Go Down

Topic: ESP32 AP and WebServer (Read 143 times) previous topic - next topic

WaitSome

Hi, I am very-new to the ESP things.

I want to make a device that will read a tank level and behave as an AP to allow a phone to connect so the tank data can be displayed on a webpage on the phone browser.

Available locally and not via the Internet but I can't seem to get my head around these seemingly (to me) conflicting things.

Can someone please point me at some sketches that will do this to get me started figuring it out?

I tried several example files but the SSID never shows up on the phone. There is always an ESP32-xxxxx SSID that I can connect to without a password, but the SSID in the sketch does not show.

Thanks

Robin2

#1
Jul 21, 2019, 11:17 pm Last Edit: Jul 21, 2019, 11:17 pm by Robin2
I have recently got an ESP32-CAM and it can be set up to link to an existing WiFi network or an as Access Point. Following is the code for the two options.

Code: [Select]
// connect to existing network
 //~ WiFi.begin(ssid, password);

 //~ while (WiFi.status() != WL_CONNECTED) {
 //~ delay(500);
 //~ Serial.print(".");
 //~ }
 //~ Serial.println("");
 //~ Serial.println("WiFi connected");
 //~ Serial.print(WiFi.localIP());
//~ Serial.println("' to connect");


Code: [Select]
// set up as an Access Point
 Serial.print("Setting AP (Access Point)…");
 // Remove the password parameter, if you want the AP (Access Point) to be open
 WiFi.softAP(ssid, password);

 IPAddress IP = WiFi.softAPIP();
 Serial.print("AP IP address: ");
 Serial.println(IP);


Obviously you will need a different SSID and password for the two options.

I think nothing else in the program needs to be changed.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

WaitSome

Thanks Robin, I have ordered one of those ESP32-CAMs  as well.

Thanks for the code, but it is way too cryptic for me at this stage. I don't have a clue how to glue that all together as a function thing. I have done about 4-hours research before asking here and still getting no closer. :)

The example sketches I have tried all looked very similar to your code but the SSID never shows up on the phone, just a weird numbered one that requires no password to connect to. But, it is NOT the SSID I have defined in the sketch.

noiasca

#3
Jul 22, 2019, 02:35 am Last Edit: Jul 22, 2019, 11:18 am by noiasca
The Example

WiFi | WifiAccessPoint

should give you a first start. Even if you leave

const char *ssid = "yourAP";
const char *password = "yourPassword";


it should work (when you get the password right).
DE: Wie man Fragen postet:
1. was hat man (Sketch und Hardware)
2. was SOLL es machen
3. was macht es: IST (Fehlverhalten, Fehlermeldungen, Serial.Output ...)
4. Eine Frage stellen bzw. erklären was man erwartet

Robin2

#4
Jul 22, 2019, 08:40 am Last Edit: Jul 22, 2019, 08:41 am by Robin2
The example sketches I have tried all looked very similar to your code but the SSID never shows up on the phone, just a weird numbered one that requires no password to connect to. But, it is NOT the SSID I have defined in the sketch.
You need to post the code of the simplest (shortest) example program and tell us in detail what happens when you run it and what you want it to do that is different.

I am by no means an expert with ESP32 or ESP8266 but I had no problem getting the ESP32-CAM cameraWebServer example working. There is a bit more about it here

A basic knowledge of WiFi concepts helps.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

WaitSome

#5
Jul 22, 2019, 04:28 pm Last Edit: Jul 22, 2019, 04:29 pm by WaitSome
Thanks Robin, I have a good grasp of wifi, it is the HTML side I am struggling with at the moment. I am trying to understand the send and receive stuff and everything in between. Also using Ajax is adding more confusion and complexity to this tired old brain.

Thanks for that link, it will come in very handy when my ESP32-CAM arrives. That is a "just for interest," toy as I have no direct use for it yet. But the tank level is a "must do," within the next week as a diesel delivery is imminent. The system currently used is to keep filling until the tank feels right with the markings on the outside. I suspect the guy overfills rather than under, but it eats at my Engineer's brain not knowing exactly what we are getting. :)

Anyway, for now the point is moot as I have a basic working sketch from Rui Santos' website. I will try and work Ajax into that mix today. Thanks for your help.

Go Up