Pages: [1]   Go Down
Author Topic: Problem with Serial in both Uno boards and Micro  (Read 205 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi. I did my research and found an old post on the matter, however it was recommended to open a new topic instead of writing on the old. So sorry for the repost.
I have two Ard Uno3 boards and a Micro.
I tried to serial communicate from the Uno to the Micro, and then tried between the two Unos  wired as follows:
Uno TX-micro RX (Same setup was used when I tried to connect the two Unos)
Uno RX-micro TX
Uno ground (on digital side) - Micro ground (on RX-TX side)

Uno -was sending and micro was receiving
 
this was the sketch used for sender
---------------------------------------------
void setup()
{
 Serial.begin(9600);
}

void loop()  {
 
  //--- display the character just sent on console ---
  Serial.println( "Hello world" );
delay(1000);
 

----------------------------------------
and this the code for receiver
--------------------------------------
void setup()
{
 Serial.begin(9600);

}

void loop()  {
 if (Serial.available() > 0) {
    int temp=Serial.read();
    Serial.println(temp);
 } else {
    Serial.println("Not available data");
 }
 delay(1000);
}
------------------------------------------------
this is what I got:
---------------------------------------------
Not available data
72
101
108
108
111
... and a bunch of more numbers
-----------------------------------------------
then I removed the common ground and change its position and got:
-------------------------------------------------
Not available data
72
101
... more numbers
-------------------------------------------------------
then moved delay(1000) up on the sketch as follows:
Serial.println("Not available data");
  delay(1000);
 and got:
--------------------------------------------------
avrdude: stk500_getsync(): not in sync: resp=0x00
------------------------------------------------
thus I disconected all pins and reloded the skectch. Now the avrdude error did not appeared.
I reconected the pins and got
------------------------------------------------------
Not available data
72
101
...more numbers

-----------------------------------------------
then I changed ground to left side (analog side) and got
------------------------------------------------
Not available data
72
101
... more numbers
------------------------------------------------------
Then added  the "while (!Serial);" script in the setup() as recommended in other posts for the Micro board
and got
----------------------------------------------------
Not available data
72
101
... more numbers
------------------------------------------------------------
Help please !!! Thank you.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I finally got the Uno talking to the Micro, this is how.

/* Setup is as follows
TX on micro to RX on Uno
RX on micro to TX on Uno
ground on micro (analog side) to ground on Uno (digital side)
Sketches uploaded prior to connecting pins.
Sender's sketch as originally proposed
this is the receiver's sketch
*/

void setup()
{
 Serial1.begin(9600);
 int Serial1;

}

void loop()  {
  while(Serial1.available())
 if (Serial1.available() > 0) {
    Serial.println ("Data is available");
    char temp=Serial1.read();
    delay (50);
    Serial.println(temp);
     }
     else {
    Serial.println("Not available data");
 }
 //delay(5000);
}

 smiley-grin
Logged

Pages: [1]   Go Up
Jump to: