Multiple ESP32 clients connected to a single server

javikistan
Posts: 5
Joined: Sun Jun 23, 2019 6:24 pm

Multiple ESP32 clients connected to a single server

Postby javikistan » Sun Jun 23, 2019 6:31 pm

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

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Multiple ESP32 clients connected to a single server

Postby ESP_Sprite » Mon Jun 24, 2019 4:26 am

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, ...?

javikistan
Posts: 5
Joined: Sun Jun 23, 2019 6:24 pm

Re: Multiple ESP32 clients connected to a single server

Postby javikistan » Mon Jun 24, 2019 4:40 pm

ESP_Sprite wrote:
Mon Jun 24, 2019 4:26 am
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, ...?
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 point

Does it help?

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Multiple ESP32 clients connected to a single server

Postby ESP_Sprite » Tue Jun 25, 2019 2:27 am

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.

javikistan
Posts: 5
Joined: Sun Jun 23, 2019 6:24 pm

Re: Multiple ESP32 clients connected to a single server

Postby javikistan » Sat Jun 29, 2019 10:20 am

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