简体   繁体   中英

Sending a message to esp32 access point with javascript

The thing that I am trying to do is this:

  1. Set an esp32 board as an access point.

  2. Create a website where we can enter the credentials of the access point (ssid, pass), connect to it and then start exchanging messages with the board.

Now, after having set the esp32 as an access point, how can we connect to it with javascript and start exchaning messages?

I am guessing I will have to use sockets, but I dont really know how to use them with javascript, and the information from the web for this topic is not really helpful for me.

Any guidance on how to achieve this or what to read would be appreciated. Thanks.

Edit: The website is running on an orange pi board.

If your website is on an other device, the device should connect to the ESP32's AP. If this device on the esp's network, you can set up the routes on your ESP for posting credentials.

For example:

  • ESP32 --> AP
  • Device connects to ESP32's AP
  • If connected, client can load webpages from the device on it's route.
  • Device can POST a request to the ESP on a predefined route and save the things.

If your device is not connected to the esp's AP then it is not possible.

Another way is to setup a webpage on the ESP32 and serve everything from just the esp. In this case you can setup a server. For this i recommend this library: https://github.com/me-no-dev/ESPAsyncWebServer Everything is documented there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM