3
votes

I'm using an Arduino Micro. When I use "Serial.write" etc with the Arduino's IDE serial monitor everything is working fine.

However when I try to read or send data via "Serial1", I get nothing. "Serial1" is suppose to use 0 and 1 RX,TX respectively.

Do I need to connect these pins through a USB converter or are they connected on the boards USB converter?

Here is the code:

Void setup(){ Serial1.begin(4800); } 
Void loop(){ Serial1.prrint('X'); }
9
Please show us your code ;-)Uli Köhler
Void setup(){ Serial1.begin(4800); } Void loop(){ Serial1.prrint('X'); }user3194881
Please edit your question and add it there so anyone can easily see it. This is usually considered a best practice on SO, it would be great if you used it as well ;-)Uli Köhler

9 Answers

8
votes

The only serial port connected to the USB that the serial monitor can read from is Serial.

Serial1, Serial2, and Serial3 are all logic level serial and will not show up on the Arduino serial monitor.

If you want to see the output from these on your computer,it will require extra hardware.

5
votes

Serial is the only serial port connected to USB. So serial monitor can access only that port. If you need Serial1 or Serial2 to be accessed by serial monitor, then you should use 'USB to TTL Serial Cable' and connect this to RX and TX pins of the arduino's Serial1 port. Please visit link for USB to TTL Serial Cable, enter link description here

3
votes

"Serial1" in Arduino Micro is Physically connected to TX and RX pins (TTL), "Serial" is just a "virtual port" which you can read using Arduino IDE's Serial Monitor, thats why arduino micro is little different from another such as nano or pro mini.

if you use Serial and Serial1 you can aproach this advantage and upload code using USB and make a connection thought bluetooth (using HC06 connected to physical pins) without disconnect the USB cable and powered both devices (micro and bluetooth).

If you can't upload code to your micro sometimes, press micro's reset button then release it and press upload button in Arduino IDE's. "virtual port" sometimes needs to restart and connect using USB.

This is from Arduino's Documentation Website:

"...Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class. "

1
votes

You said it right, Serial1 is the RX and TX pin, while Serial is a virtual interface between computer and Arduino. I have used the TX and RX pins for a wireless module, and if you NEED to use Serial1, it would have to occupy pins 0 and 1, and switch from DLINE to UART on your board.

0
votes
Void setup()
{ 
Serial.begin(4800);  //9600.... 
}
void loop()
{

 if(Serial.available())    
 {   
  int a= Serial.read();
  Serial.Writeln(a);
 }
 else
 {
  Serial.Writeln("Error");
  }
}

Open serial monitor with the icon placed in right corner of Arduino IDE. It will be available if you connect the Arduino with PC.

0
votes

When you open the Arduino IDE write this code block

 Void setup()
    { 
    Serial.begin(9600);
    }
    void loop()
    {
     if(Serial.available())    
     {   
      char get= Serial.read();
      Serial.Write(get);
     }
    }

Select the arduino 9600 port and write something. If you get your written text your arduino is ready from serial comminicate..

0
votes

Make sure you go to tool/board: and select Arduino Mega (or other board with multiply serial ports) or it won't work, because the Uno only has one Serial communication port (aka The TX and RX pins on pins on 1 and 0)! Write 1,2 or 3 depending on what TX and RX pins you are using on the Board. The mega has a whole set of extra pins for Serial 1,2 and 3, for example:

Arduino Uno (etc):

Serial.begin(9600)
Serial.write("testing")

Arduino Mega:

Serial1.begin(9600) // <{or what even baud rate you should use}
Serial1.write("testing")

or

Serial2.begin(9600)
Serial2.write("testing")

or

Serial3.begin(9600)
Serial3.write("testing")
0
votes

You have to define Serial1 by using SoftwareSerial class from SoftwareSerial library ,Google and download the library :

the code should be something like this :

//Example
SoftwareSerial Serial1(9 , 10)  ; //Rx and Tx respectively 

Void setup() { 
    Serial1.begin(4800); //Here is your New serial 
    Serial.begin(9600);//This is where arduino is connected to your PC
       }
 Void loop(){
   //Code goes Here 
  }
-1
votes

Serial1 is the wrong class for pin 0 and pin 1. You should use Serial class.

Do I need to connect these pins through a USB converter or are they connected on the boards USB converter?

It makes no difference for Serial class.