I'm intending to create some (like 5-10) boxes with sensors and/or relays inside using ESP32's.
For connection to a laptop and mobile phone I found a tutorial at ESP32 WebSocket Server: Control Outputs (Arduino IDE) which uses an async webserver with sockets.
However, I wonder if I would use multiple boxes, how to solve this. I thought of one of the following 'solutions"
I want to have the boxes work together (e.g. to make a web page that I can set that e.g. when sensor X has value Y than on another box relay 1 should be on).
- Making each a webserver. But having 5-10 webservers seem hard to handle as I don't want to visit 10 web pages for each server on my laptop/mobile phone.
- Make one of them the webserver. But this seems strange as they are all more or less equal (they will have different sensors but that's not relevant for the webserver functionality).
- Create a separate webserver (on an ESP32), that does nothing except handling all data.
I guess the second or third solution is best. Than my next question would be what is the best way to have the boxes communicate to each other. Can I for example have a websocket for the HTML page(s) on the laptop/mobile phone to the server and next to that use HTTP messages to communicate with all other boxes?
I hope this questions is not too generic, I'm just a newbie to webservers/sockets.
Note, I prefer to use my router as this is in the middle of the house and all my boxes will be within vicinity of it (more or less close).