Any software serial library for ESP32 can be used to receive data?

Super169
Posts: 6
Joined: Fri Jul 20, 2018 7:11 am

Any software serial library for ESP32 can be used to receive data?

Postby Super169 » Sat Feb 23, 2019 6:37 pm

I have a project which need to communicate with 5+ serial device, some of them are connected using softwareserial in signal wire mode with esp8266.

I'd like to upgrade the project to use esp32 as it can provide more GPIOs, but unfortunately, those softwareserial for esp32 using Arudino framework in GitHub can only used for sending data, and it will cause error if there has data received. (e.g. https://github.com/jdollar/espsoftwareserial/).

Is there any softwareserial library for ESP32 which can be used to receive data?

paulvha
Posts: 6
Joined: Thu Dec 27, 2018 2:29 pm

Re: Any software serial library for ESP32 can be used to receive data?

Postby paulvha » Sun Feb 24, 2019 9:43 am

Try this one https://github.com/paulvha/ESP32

it is based on the Jdollar library but it needed a large number of fixes before it worked. Make sure to read the readme!

Super169
Posts: 6
Joined: Fri Jul 20, 2018 7:11 am

Re: Any software serial library for ESP32 can be used to receive data?

Postby Super169 » Mon Feb 25, 2019 1:43 am

Thanks a lot.
However, according to the README.md, "It now works OK-is, most of the time. But do not expect it to work above 56K (stretch already !!)", it seems the library is still not stable, and only work for 56K. But I need to connect the device in 115200.

I will study how it fix the issue in jdollar's version, and try to modify it for half-duplex mode.

Super169
Posts: 6
Joined: Fri Jul 20, 2018 7:11 am

Re: Any software serial library for ESP32 can be used to receive data?

Postby Super169 » Mon Feb 25, 2019 3:52 am

paulvha wrote:
Sun Feb 24, 2019 9:43 am
Try this one https://github.com/paulvha/ESP32

it is based on the Jdollar library but it needed a large number of fixes before it worked. Make sure to read the readme!
I just test your library, and it seems that your change on rxRead cause the issue in 115200bps.

According to your comment, you have changed the wait time as the delay measured is neglectable; however, when I tested in 115200, even it cannot receive the result correctly, but it has consistent return for same data, it seems that the received bit is shifted.
So I try to restore the original formula for wait time ( i.e. unsigned long wait = m_bitTime + m_bitTime/3 - 500; ), it works fine in 115200 now. This 3.5us is important for fast baud rate.

I will have more test for the stableness, and try to add support on single wire half duplex mode, as my device is running in this mode.

Thank you very much for fixing the receive issue.

Super169
Posts: 6
Joined: Fri Jul 20, 2018 7:11 am

Re: Any software serial library for ESP32 can be used to receive data?

Postby Super169 » Mon Feb 25, 2019 6:52 am

By modifying the wait time, there has no more receiving issue in your library, I have tested with continue data received for over 1 hour (receiving 50 bytes/sec). But it has problem in sending data, the data is corrupted.

However, if I fallback to jdollar's version, it cannot receive data, but there has no error sending data.
It seems that as you only call portENTER_CRITICAL for slow connection; however, there always have some background task in ESP32, this is important for high speed also. And also the calculation of start point for bit waiting time is different.

I have fallback some change in your library to jdollar's version, and it works fine with bidirectional communication in 115200 bps now.

I will keep testing for longer time to ensure the connection in 115200 bps is stable.

Thanks a lot.

paulvha
Posts: 6
Joined: Thu Dec 27, 2018 2:29 pm

Re: Any software serial library for ESP32 can be used to receive data?

Postby paulvha » Mon Feb 25, 2019 9:23 am

Thanks.

Timing is very critical indeed for softserial. I have not seen any software serial work correct on 115K on any platform.(Uno, ESP8266, mega2560, ESP32 etc). Maybe only for sending. All is depending on how fast the code is working, the system is handling interrupts and the system load. Personally I would not use above 56K. Maybe you device can not be switched to lower baudrate, but otherwise I would try that. I would welcome your changes/code back on the github and make it one.

regards,
Paul

Super169
Posts: 6
Joined: Fri Jul 20, 2018 7:11 am

Re: Any software serial library for ESP32 can be used to receive data?

Postby Super169 » Mon Feb 25, 2019 2:05 pm

paulvha wrote:
Mon Feb 25, 2019 9:23 am
Thanks.

Timing is very critical indeed for softserial. I have not seen any software serial work correct on 115K on any platform.(Uno, ESP8266, mega2560, ESP32 etc). Maybe only for sending. All is depending on how fast the code is working, the system is handling interrupts and the system load. Personally I would not use above 56K. Maybe you device can not be switched to lower baudrate, but otherwise I would try that. I would welcome your changes/code back on the github and make it one.

regards,
Paul
plerup's library already works in 115200 with ESP8266, I have modified the library for one wire half duplex connection, and used in my RobotControl project for a year, it's very stable in 115200.

Who is online

Users browsing this forum: Baidu [Spider] and 57 guests