Go Back
No Bridge Library on Arduino Yun
07th, May
Arduino Yun – TCP/IP to Serial1 redirect

!! Code available on my GitHub toskyRocker account !!

Many of us, Arduino lovers, want to get rid of the Bridge library, due to its lame performance, it’s slow and heavy.
A simple way to avoid this problem is to replace the Bridge library (Atmega side) with a python script (Atheros side) that redirects the TCP/IP stream to the Serial1 .

1. First of all replace inittab (using copy over SSH) on OpenWrt with the one given in my GitHub account.

>>scp inittab root@

This step makes Serial1 available on startup.
NOTE: Arduino Yun’s IP is usually

2. Copy tcp_serial_redirect.py in the right place on OpenWrt.

>>scp tcp_serial_redirect.py root@

3. Copy pyserial-2.7 folder on OpenWrt

>>scp -r pyserial-2.7/ root@

4. Install pyserial on OpenWrt

>>ssh root@
>>cd pyserial-2.7
>>python setup.py install

5. In order to enable the redirect type this command in the OpenWrt terminal:

>>python tcp_serial_redirect.py -p /dev/ttyATH0 -b 115200 -P 8888 

115200 is the baudrate selected.
8888 the port for the connection.

6. You’re ready to use the serial1 communication on Atmega32u4. You can write something like this to test your connection:

void setup() {

void loop() {
  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.print(inByte, BYTE); 
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.print(inByte, BYTE); 

Don’t forget to use the same baudrate for both the python script and Arduino sketch

This site uses Akismet to reduce spam. Learn how your comment data is processed.

December 16th, 2015 at 20:58 by Todd


Very nice, this fixed my stability problem trying to use Console.
I considered doing a C version, clever to use pyserial.

December 17th, 2015 at 21:05 by Todd


So I am a fan, but there are some issues – rebooting the Yun is a real
issue, as the Atmega application I am running spews data into the USB console. I can only control a bit by unplugging my sampling device, wait for the YUN to connect/network, then unblock the atmega app at startup.

while(Serial1!); is not enough!

any other workarounds?

December 17th, 2015 at 23:16 by AndrewTosky


Thank you for appreciating my work 🙂

Do you need the script running on Yun startup?

September 19th, 2017 at 13:32 by Eduardo


Interesting post, I will test with project because I have strange problems with bridge library.

November 28th, 2017 at 23:19 by Fred Briggs


Very interesting, I have been looking for a way to bypass bridge because it is to slow. I am trying to write to the SD card at 200Hz and with bridge I only get 40Hz. How would I use this in that environment? Sorry but I am new to python and Linux so I am just trying to learn.