A web version of my old project which I made to control relays in my room. Instead of HC-05, it now uses NodeMcu to control them. NodeMcu runs a web server that exposes an API to control the relays and also serves a React app on my LAN accessible at http://roomlight.local which utilizes the API.
(I will not talk about how to make the react app or how to connect nodemcu with the relay. Just point you in the right direction and highlight the pitfalls)
Look at this file.
It is simple and will work for most of your use cases.
Just change the SSID, password and adapt the JSON response according to your needs. You can use the Arduino IDE and it should work without any issues.
Look at this file for the NodeMcu code. Change the SSID, password and adapt the json response according to your needs.
- You will need to use PlatformIO instead of the Arduino IDE for this.
- The API part is very similar to the earlier example but a few changes have been made to make it work with ESPAsyncWebServer
- For the React App
- Try to make the app as small as possible. I was not able to upload anything larger than 1mb (which I am guessing is the flash size). Not generating source maps helps, see my build script in package.json
- Upload the contents of your build folder to the NodeMcu by following the instructions here. You need to use LittleFS instead of SPIFFS because the latter does support directories.