115200 serial data communication in software - e.g. to communicate with WR703N

Hi all,

I am doing a project to combine the TP-Link WR703 wifi router with an Arduino Nano.
The TP-Link can be extended with a serial communication line (examples of how to do this easily found on the web).
This could be connected to the Arduino’s HW serial port. But then there is no option anymore to monitor the Arduino, e.g. via USB to the PC.

There is a software serial library that can be used next to the HW serial port. However, the WR703 communicates at 115200 baud and the sw serial lib does not support such a high speed.

Instead I succeeded in making a dedicated implementation that can handle the 115200 reading, which I like to share. Someone might find it useful for other applications, or find some inspiration for other high speed problems.

Code is in the attached file.

Its not yet split as separate library. Furthermore only the reading part (RX) is implemented. I now can start on the writing (TX).
If you want to use it on other Arduino types, then you might need to change some port mapping.
Furthermore, it only works for continuous bursts of max 1024 characters, because I cannot get a larger buffer.
And 115200 baud does not give me any spare cycles to do something with the data and hence empty the buffer entries.

Greetings, Patrick

swserial.ino (8.73 KB)

There is a software serial library that can be used next to the HW serial port. However, the WR703 communicates at 115200 baud and the sw serial lib does not support such a high speed.

It does, but only works reliably for very short messages.

And 115200 baud does not give me any spare cycles to do something with the data and hence empty the buffer entries.

Not to belittle your attempts, but if you don't have time to do anything with the data, why bother reading the data?

A device with two or more hardware serial ports really seems like a better idea.

The problem with WR703N is that -at least during boot- it generates very long messages (read long bursts). By the way, I initially tried the standard sw serial lib and it looked like even the first bytes of a burst where not received well.

Of course I have time to process the data that has been read, but not during the burst itself. That is what I meant to say. In between the bursts in the attached application the characters are printed on the HW console.

In my target application I want to communicate commands from the WR703N to the arduino to set/get data, and thus use the WR703N as a wifi gateway. Then I have full control of the sequence of sending/receiving characters, in a ping-pong fashion.

Grt, Patrick