Hello everyone, this is my first post in this forum.
I recently obtained an UNO R3 and I am trying to setup a serial connection to a GSM core board. My problem is the rx pin of my UNO doesn't detect any incoming data.
I wrote this test code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(5,6);//rx,tx
void setup (){
mySerial.begin(9600);
Serial.begin (9600);
delay(300);
}
void loop (){
mySerial.println("Hello");
delay(2000);
}
I connected pin 6 to the rx pin 0 and pin 5 to the tx pin 1. I was expecting the software serial to print to the hardware serial so I can see a response in the monitor but I get nothing. The rx LED doesn't even light.
That's not testing the hardware serial at all.... you're not watching the hardware Rx pin for incoming data, nor are you then trying to send it out again with a hardware Serial.print().
You need to use Serial.available() to be on the lookout for incoming, as explained for example here.
ps.... assuming you know the sketch has been uploaded, the Rx pin must have worked since that's how the sketch gets in.
Thank you JimboZA for the reply. As you can tell, I am new to this. So if I wanted to use the hardware rx port, I need to tell the board to listen for incoming data by using:
If serial.available () function, store the data to an array then print the contents of the array?
I will give it an try and post my results.