SoftwareSerial Support on the Yun

I have been unable to read any data using the SoftwareSerial library on my new Yun. A simple sketch that turns on an LED when bytes are available works as expected on my Uno, however I cannot seem to get it to work on my Yun. Transmitting data works fine, however. Is the SoftwareSerial library supported yet on the Yun, or is it possible that I have some bad hardware?

Uhmm SoftwareSerial works fine AFAIK. Can you attach a test sketch and describe the wiring so we can reproduce the problem?

I have tried something along the lines of this with an LED wired to pin 12 and another Arduino outputting data at 9600 baud, wired into pins 2 and 3 of my Yun. The LED is wired correctly and lights if I set pin 12 high. I have loaded the same sketch on my Uno and the LED lights as expected. I have also tried reversing the RX and TX pins to verify I don't have them backwards.

serialtest.ino (266 Bytes)

Software serial is working ok on my Yun. Any chance you could post your code?

Sorry , missed your code... Will give it a go

Just for pig iron, how about looping pins 2 and 3 together on the Yun, and writing data in your setup? Is all is ok, it should show as available in your main loop and light the led....

No luck. I looped Pins 2 and 3 as you suggested and modified my test sketch as attached so that now the LED is lit until data can be read, and the LED stays lit.

serialtest.ino (348 Bytes)

So is there anything else I can try, or should I start the RMA process and see if another unit works better for me?

I was reminded that software serial requires pins with change interrupt. On leonardo (and therefore on yun) the following limitation is known

Not all pins on the Leonardo support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

Can you change pins and retry?

That was it! Works like a charm now - thanks!

Had the same problem, connected an arduino to a roomba via serial and used SoftwareSerial with Pins 2 and 3 on the arduino. Pin 3 did transmit data to the roomba and it was possible to send commands to make it start cleaning etc.. Pin 2 wouldn't receive anything from the roomba at all though (wanted to read sensor values), neither on the Arduino Yun nor on the uno.
Changing Arduino RX from Pin 2 to Pin 10 and leaving Pin 3 as TX made it work! I wonder what's wrong with Pin 2.
Thanks guys!

I have the same problem. I am trying to connect an nrf24L01 module to the arduino yun and it prints are gibberish.

this is my code:

/*
  Software serial multple serial test
 
 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.
 
 The circuit: 
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)
 
 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts, 
 so only the following can be used for RX: 
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
 
 Not all pins on the Leonardo support change interrupts, 
 so only the following can be used for RX: 
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
 
 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example
 
 This example code is in the public domain.
 
 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 3); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

This is the output:

Goodnight moon!
0'ÚšÚ‚ÚŠ¢Ú:…Ñ•Ý…å�šÑ…ÉÐÕp complete.

It should be:

0;0;3;9;0 Gateway startup complete. //Not sure about the numbers but I'm sure about the text

SoftwareSerial won't work at 115200 baud. Try 9600 baud.

...R

It's working now!

For future references:
Download AltSoftSerial library.

Please take note on connecting the right pins.
I have been using arduino uno for so long now that I have only realized this after n hours.
Yun = Leonardo. Connect the pins to RX=13 and TX=5.

// AltSoftSerial always uses these pins:
//
// Board Transmit Receive PWM Unusable
// ----- -------- ------- ------------
// Teensy 3.0 & 3.1 21 20 22
// Teensy 2.0 9 10 (none)
// Teensy++ 2.0 25 4 26, 27
// Arduino Uno 9 8 10
// Arduino Leonardo 5 13 (none)
// Arduino Mega 46 48 44, 45
// Wiring-S 5 6 4
// Sanguino 13 14 12

This is the code just in case you're freakin out because you can't see the code that worked ehem me :o :roll_eyes:

(You dont have to change anything on the code. Just the wiring)

#include <AltSoftSerial.h>


AltSoftSerial altSerial;

void setup() {
  Serial.begin(9600);
  while (!Serial) ; // wait for Arduino Serial Monitor to open
  Serial.println("AltSoftSerial Test Begin");
  altSerial.begin(9600);
  altSerial.println("Hello World");
}

void loop() {
  char c;

  if (Serial.available()) {
    c = Serial.read();
    altSerial.print(c);
  }
  if (altSerial.available()) {
    c = altSerial.read();
    Serial.print(c);
  }
}

arduinoTime:
It's working now!

I see you are using AltSoftSerial at 9600 baud.

Did you try SoftwareSerial at that baud rate ?

...R