Software Serial - Not working for my device but normal serial is

Hi,

I have been trying to use the software serial on my arduino micro. I am trying to get this working in preparation from my arduino FIO arriving - Arduino Fio with Serial Sensor Possible? - Project Guidance - Arduino Forum

This is because the FIO only has one serial port which is already used to send info to the Xbee. As i am trying to monitor a remote serial sensor this causes some problems as i need a separate serial port for my sensor.

When i power cycle my sensor it sends a serial data stream which i have connected pin 2 (RX) of my micro. The TX is not used but i configured it anyway as it was in the example.

However i get no response from my sensor. Here is the code i am using.

#include <SoftwareSerial.h>

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

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(1200);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(1200);
}

void loop() // run over and over
{
  

  if (mySerial.available())
    Serial.write(mySerial.read());
 
  else
    Serial.write("no coms\n"); 
    delay(1000); 
}

So i tried just using a regular serial port on the micro and it worked perfectly. When i power cycled the sensor i got the expected serial read out from the sensor in the serial monitor window (see attached).

{
  // Open serial communications and wait for port to open:
  Serial.begin(1200);

// Open serial communications to the sensor and wait for port to open:
  Serial1.begin(1200);

}

void loop() // run over and over
{

  if (Serial1.available())
    Serial.write(Serial1.read());
 
  else
    Serial.write("no coms\n"); 
    delay(1000); 
}

Any ideas where i could be going wrong? This is just the code from one of the practice examples so no idea why softwaretoserial is not working in my case.

I have attached what the correct serial stream looks like after power cycling the sensor.

Thanks

Alastair

Serial.png

http://www.arduino.cc/en/Reference/SoftwareSerial

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).

The Micro has the same processor as the Leonardo.

Thanks for your reply,

I read that to but also for the micro - http://arduino.cc/en/Main/arduinoBoardMicro

A SoftwareSerial library allows for serial communication on any of the Micro's digital pins.

Just wanted to let you know i have now used port 10 and it works great

So documentation is a little misleading :stuck_out_tongue:

medium_999:

A SoftwareSerial library allows for serial communication on any of the Micro's digital pins.

Yes, misleading is the word. You can use any pin for output.

Thanks for your clarification.

Really happy this is working now :slight_smile:

medium_999:
So documentation is a little misleading :stuck_out_tongue:

I raised a bug report about the documentation, but don't hold your breath. :slight_smile: