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