Page 1 of 1

Communicationg TWO ESP32 Boards

Posted: Fri Sep 04, 2020 4:07 pm
by shota@gymstinct.com
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.

Re: Communicationg TWO ESP32 Boards

Posted: Mon Sep 07, 2020 9:19 am
by Agree007
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 ?

Re: Communicationg TWO ESP32 Boards

Posted: Mon Sep 07, 2020 1:57 pm
by shota@gymstinct.com
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).

Re: Communicationg TWO ESP32 Boards

Posted: Mon Sep 07, 2020 4:36 pm
by Agree007
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 ?

Re: Communicationg TWO ESP32 Boards

Posted: Fri Sep 11, 2020 8:26 am
by shota@gymstinct.com
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;
}

Re: Communicationg TWO ESP32 Boards

Posted: Sat Sep 12, 2020 8:51 pm
by Agree007
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.

Re: Communicationg TWO ESP32 Boards

Posted: Wed Sep 23, 2020 12:02 am
by kadoat
I'm not familiar with TwoWire but have you checked to see if your cables are too long?

Re: Communicationg TWO ESP32 Boards

Posted: Wed Sep 30, 2020 3:43 am
by mrburnette
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

Re: Communicationg TWO ESP32 Boards

Posted: Mon Sep 27, 2021 1:38 pm
by Fredckx
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 ???