Communicationg TWO ESP32 Boards

shota@gymstinct.com
Posts: 3
Joined: Fri Sep 04, 2020 3:59 pm

Communicationg TWO ESP32 Boards

Postby shota@gymstinct.com » Fri Sep 04, 2020 4:07 pm

Hello

Me and my colleagues have been trying to communicate two ESP32 Boards for a very long time (started using Serial Communication RS232/485 continued with TwoWire). We have invested huge amount of time in the development process. There have been lots of BUGs, we have tried to overcome with software and hardware solutions (even altering libraries etc), at some point we have advanced but now we are finally stuck and there is no explanation to what happens to the board/libraries and why are we getting data sometimes and why are we not.

So the General question is what is most relible method to communicate two or more boards for a commercial application?
Any assistance and suggestions are appreciated.

Agree007
Posts: 103
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

Re: Communicationg TWO ESP32 Boards

Postby Agree007 » Mon Sep 07, 2020 9:19 am

WiFi and bluetooth are normaly used to communicate between boards 😉

If you need a wired connection, then it will depend on your requirement, speed, data size ect. ?

I have testede serial between two esp32 and it works fine.

What issue/problems do you have using serial ?
And what have you tryed to overcome it ?

shota@gymstinct.com
Posts: 3
Joined: Fri Sep 04, 2020 3:59 pm

Re: Communicationg TWO ESP32 Boards

Postby shota@gymstinct.com » Mon Sep 07, 2020 1:57 pm

Agree007 wrote: WiFi and bluetooth are normaly used to communicate between boards 😉

If you need a wired connection, then it will depend on your requirement, speed, data size ect. ?

I have testede serial between two esp32 and it works fine.

What issue/problems do you have using serial ?
And what have you tryed to overcome it ?
I need wired connection. Serial/TwoWire usually loses data/reads with 0s or other charrecters.
I don know whats your application, I usually use interrupt timers and haw "Reach Slave Device" code to ready changes in a loop.
Tested many things and does not always work (usually 85% of packets arrive in case of serial and lass in case of TwoWire).

Agree007
Posts: 103
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

Re: Communicationg TWO ESP32 Boards

Postby Agree007 » Mon Sep 07, 2020 4:36 pm

Hmm it works for me using task to read incomming data.

What speed are you using ?
Do you have the same problem with lower speed ?

What about the physical wire, is that on a PCB or long/short jumper wired ?

shota@gymstinct.com
Posts: 3
Joined: Fri Sep 04, 2020 3:59 pm

Re: Communicationg TWO ESP32 Boards

Postby shota@gymstinct.com » Fri Sep 11, 2020 8:26 am

Hmm it works for me using task to read incomming data.

What speed are you using ?
Do you have the same problem with lower speed ?

What about the physical wire, is that on a PCB or long/short jumper wired ?
Here is sample code, I reach slave device every 100 ms (function is called 2 slaves at different Wire objects).
Wire is at declared at 100000 rate.

Code: Select all

bool Periphery_Manager::Reach_Periphery_Devices(TwoWire * wire, uint8_t * buffer)
{
    static uint32_t reach_st = 0;
    if (millis() < (reach_st + 100))
        return false;
    reach_st = millis();
    if (Read_New_ID(wire, buffer))
        return true;
    return false;
}

Agree007
Posts: 103
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

Re: Communicationg TWO ESP32 Boards

Postby Agree007 » Sat Sep 12, 2020 8:51 pm

Have you try with lower speed and only one (1) slave ?
Do you then have errors ?
How have you made your physical connections ?

If your speed is 100.000 bps and you read every 100ms how is your timing then ?

Suggest you try with one connection, use task to poll incomming data and.make that work 100 % befor you try with two slaves.

Just my 2 cent.

kadoat
Posts: 2
Joined: Tue Sep 22, 2020 12:01 am

Re: Communicationg TWO ESP32 Boards

Postby kadoat » Wed Sep 23, 2020 12:02 am

I'm not familiar with TwoWire but have you checked to see if your cables are too long?

mrburnette
Posts: 22
Joined: Mon Feb 12, 2018 6:50 pm

Re: Communicationg TWO ESP32 Boards

Postby mrburnette » Wed Sep 30, 2020 3:43 am

shota@gymstinct.com wrote:
Mon Sep 07, 2020 1:57 pm
...
I need wired connection. Serial/TwoWire usually loses data/reads with 0s or other charrecters.
I don know whats your application, I usually use interrupt timers and haw "Reach Slave Device" code to ready changes in a loop.
Tested many things and does not always work (usually 85% of packets arrive in case of serial and lass in case of TwoWire).
If you are using interrupts, did you use the IRAM_ATTR attribute for the interrupt function and any called function?

See this for how to do this correctly:
https://techtutorialsx.com/2017/10/07/e ... nterrupts/

Bad things happens when you break rules :shock:

Personally, I prefer to just pass structures from one Arduino to another.
See: https://github.com/LowPowerLab/RFM69/tr ... r/Examples
Examples: Struct_send & Struct_receive

Fredckx
Posts: 17
Joined: Mon Mar 29, 2021 8:55 pm

Re: Communicationg TWO ESP32 Boards

Postby Fredckx » Mon Sep 27, 2021 1:38 pm

Hi, I need a communication means that has low memory usage.

I want to free up memory by removing WIFI and MQTT code to have more space for the core of the project. I could add a second board that has a wired connection with the first board and does the wireless communication with the network.

Can I save memory space on the first board in this way? Or is the code for wired communication comparable in size with WIFI / MQTT.

My gut feeling says that this would be a good way to free up space at the cost of an additional board for the wireless part of the communication.

Any comments ???

Who is online

Users browsing this forum: No registered users and 67 guests