I am trying to connect Uno with RN-134 wifi module. I connected pin 2 of Uno to TX and pin 3 to RX of Wifly through a 3.3-5 level shifter. And, I tried to test the connection, here is my code
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
Serial.println("Connected");
Serial.println(" * Use $$ (with no line ending) to enter WiFly command mode. (\"CMD\")");
Serial.println(" * Then send each command followed by a carriage return.");
Serial.println("Waiting for input.");
}
void loop()
{
while(mySerial.available() > 0) {
Serial.write(mySerial.read());
}
if(Serial.available()) { // Outgoing data
mySerial.write(Serial.read());
}
}
The problem is whenever I try to enter to command mode, I get different kind of unreadable characters.
But if I use Mega2560, and use Serial3() in place of mySerial(), it works fine. And, Uno has only one serial, so I can't use serial3.
What is wrong with the above code? I want to use Uno for this purpose, not Mega. And, I just want to have serial connection with RN134.
Thank you.