Use Yun bridge without a Yun?

Is it possible to use an 'standard' Arduino (e.g. Uno) connected to a Linux computer via USB (as two of my projects already are) and make use of a Yun type bridge?

What I am really asking is, has/is anyone porting the Yun Linux side software so it is installable on a standard Linux PC?

Technically it is possible to do it, but practically you might face some problems.

Also, it would be easier to try with Arduino Leonardo first instead of Uno, since the AVR part in YUN is more similar to Leonardo than Uno.

I would not be surprised if the developers used a regular arduino and a pc to develop the bridge.

I gave it a try with a Duemilanove (I have no Uno) and a Leonardo.

When compiled for the Leonardo, the bridge library uses Serial1 (the uart), so you have to hook up a serial to usb converter to the tx (1) and rx (0) pins. Communication with the bridge goes via this extra converter. But the upside is that you have Serial free for println debugging.

When compiled for the Duemilanove, the bridge library automatically uses Serial, so communication goes via the (only) usb cable.

As suggested elsewhere in this forum I added the possibility to start the bridge with a specified baudrate. In Bridge.h I made this change:

class SerialBridgeClass : public BridgeClass {
  void begin(unsigned long baud = 250000) {

I feel more comfortable with 115200 as baudrate, so in the ConsoleRead sketch:


Upload e.g. the ConsoleRead sketch to the Duemilanove, Leonardo…

The bridge library does not set the baud rate, so you should do that yourself:

stty -F /dev/ttyUSB0 115200

Get the YunBrigde source from Arduino’s git hub repository.

The avr on the Yun fires up the bridge on linino by itself, but for experimentation on the pc you can just start it manually. e.g. for the Duemilanove:

python </dev/ttyUSB0 >/dev/ttyUSB0

The bridge will try to run the scripst /usr/bin/blink-start and /usr/bin/blink-stop. You might comment this out in, but I just installed two dummy scripts on my pc and made them executable:

echo "$0" 1>&2

In the scripts, make sure not to echo stuff (for debugging) on stdout because it will be sent to the arduino, messing up the bridge communictaion. That is what the 1>&2 is for: it makes sure echo’s output ends up on stderr. Likewise if you want to do ‘printf debugging’ from the python scripts, don’t use print, but use:

from sys import stderr
stderr.write("some string\n").

The arduino may kick out the python script by sending it the ‘XXXXX’ command. Just start it again or ignore the command in

Now, in another terminal window, say telnet localhost 6571 and you should see ‘Hi, what’s your name?’

I did not yet manage to make it run smoothly though. If I type my name, it takes several seconds till I see ‘Hi peter! Nice to meet you!’
It looks as if for every send from the arduino to the pc, there is a latency of a second or so. I want to figure out where this comes from…I have no Yun, so I don’t know whether it runs smoother on a Yun. I see no reason why it would. On the Yun, there is no usb to serial converter involved but that should not be a bottle neck?. Maybe I did not yet find the magic stty settings?.

On a side note, the Bridge contained in the nightly builds on the IDE (they will become version 1.5.5) is already patched

Ok, I did a git pull and ran from there.

Note that the overloaded function SerialBridgeClass::begin(int baud) in the new code is wrong, the baud rate must be an unsigned long for baudrates like 115200 to work. Adding just an optional baud argument like in my code snippet works also and is backward compatible too.

I observed not behavioural differences. On the Leonardo it works a bit faster than on the Duemilanove. As said, I will try to figure out where the latencies come from. Does this run smoothly on the Yun?

Your right: should be a long.

Syntax Serial.begin(speed)

Parameters speed: in bits per second (baud) - long

Fixed. Thank you