I want to implement functionality where I fill a form to provide Wi-Fi credentials and setpoints to an ESP32. The form should send the Wi-Fi credentials and setpoints to the ESP32, and it should then connect to the Wi-Fi network.
I’m using a simple RESTful server sample code and created my own custom form that works properly. My doubt is whether I need to host the code externally or on the ESP32's flash by creating a partition table.
If I run my Node.js server on the ESP32, the frontend can send the response to the backend. However, if I host the website on an external platform, would I also need to host the backend server there as well for it to work properly?
On the ESP32, I’ve noticed that when I upload the folder, it runs index.html (frontend code). What are the best ways to achieve this functionality with ESP32? Should I host both the frontend and backend on the ESP32, or is external hosting a better solution?
Hosting a Node.js Server on ESP32 or External Hosting for Wi-Fi and Setpoint Form
-
- Posts: 1750
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Hosting a Node.js Server on ESP32 or External Hosting for Wi-Fi and Setpoint Form
If you were to host (part of) the application on a different server, how would that application communicate with an ESP32 which is not yet connected to WiFi?
Re: Hosting a Node.js Server on ESP32 or External Hosting for Wi-Fi and Setpoint Form
I haven't hosted application yet. I am just clearing my doubt. Can I upload backend and frontend on the esp32. If yes then how can the communicate. I didn't clear the concept of this.
-
- Posts: 9772
- Joined: Thu Nov 26, 2015 4:08 am
-
- Posts: 1750
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Hosting a Node.js Server on ESP32 or External Hosting for Wi-Fi and Setpoint Form
Probably not in the way you're thinking of.
An ESP32 will easily run an HTTP server, serving HTML, JavaScript, and other files to a browser; and it will as well receive and process any data sent to it via HTTP, e.g. input into an HTML page/form it also served via HTTP.
It will not run some Node.js (backend) application you may have developed.
The common approach for provisioning ESPs is to, upon first start and/or when it fails to connect to any WiFi network, let the ESP open up a WiFi access point ("SoftAP") and run the HTTP server; a user can then connect to this access point and interact with the ESP via HTTP+HTML, see above. Once the ESP has received all required information, it shuts down its access point and connects to the desired WiFi network in station (STA) mode.
For more options see also https://docs.espressif.com/projects/esp ... oning.html
Who is online
Users browsing this forum: No registered users and 105 guests