Hi, Im starting a new project where I manage an ESP32 client from a server located on my PC. However I would like to add multiple ESP32 clients but I dont know how to handle that. Do you know any way I could choose the ESP32 I want to send the data
I would also like to send as package an object with different fields (maybe position, identfier etc) is there a way? so far I could only send string data.
Thank you
Multiple ESP32 clients connected to a single server
-
- Posts: 5
- Joined: Sun Jun 23, 2019 6:24 pm
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: Multiple ESP32 clients connected to a single server
You'll have to be a bit more specific than that: what protocol are you using? Are the server and the client on the same network, or does it also need to work if there's a NAT in between (needs a 3rd-party server)? How do you connect from client to server: is the ESP32 an access point, does it connect to existing infrastructure, ...?
-
- Posts: 5
- Joined: Sun Jun 23, 2019 6:24 pm
Re: Multiple ESP32 clients connected to a single server
Yeah you're right. So the idea is to use the TCP/IP protocol to communicate both devices, server and client need to be on the same network but doesn't need to support a NAT in between. As for the connection, Im trying to come up with different options, but I feel that the most correct way would be that the ESP32 connect to the PC as it worked as an access pointESP_Sprite wrote: ↑Mon Jun 24, 2019 4:26 amYou'll have to be a bit more specific than that: what protocol are you using? Are the server and the client on the same network, or does it also need to work if there's a NAT in between (needs a 3rd-party server)? How do you connect from client to server: is the ESP32 an access point, does it connect to existing infrastructure, ...?
Does it help?
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: Multiple ESP32 clients connected to a single server
Yeah, sure. Sounds you need to set up a TCP/IP server that can handle multiple clients at the same time on the PC; the implementation of that depends on what language you use there. For packaging data into something that you can send over a TCP connection: the 'default' encapsulation method is JSON, and I think we have a library for that (cJSON) in ESP-IDF, or you can go the hacky way and assemble a JSON packet using printf and base64_encode calls manually.
-
- Posts: 5
- Joined: Sun Jun 23, 2019 6:24 pm
Re: Multiple ESP32 clients connected to a single server
Thank you for the suggestion! What I think Im going to try is to set up a TCP socket with WiFi.h and a python "server" so I can send short string messages and try to split pseudo-elements with special characters as "#" o "+" . But I'll definitely look into the cJSON option in case I'll need something more elaborate
Who is online
Users browsing this forum: Bing [Bot] and 119 guests