How to be Sure My UNO is sending and receiving on pins 0 & 1

I’m another new guy to Arduinos and I have a UNO and I am not certain the serial pins (0 & 1) really work.
I wrote a program sending HEX data. Since I’m not using SoftwareSerial lib, I think pins 0 & 1 should be working, but I’m not getting any response from the board I’m trying to talk to.
I do get response from Serial Monitor but does Serial Monitor really show what is coming and going from pins 0 & 1? If it does show, how do I test for any problems that may be interfering with communications?

billz1:
I’m another new guy to Arduinos and I have a UNO and I am not certain the serial pins (0 & 1) really work.
I wrote a program sending HEX data. Since I’m not using SoftwareSerial lib, I think pins 0 & 1 should be working, but I’m not getting any response from the board I’m trying to talk to.
I do get response from Serial Monitor but does Serial Monitor really show what is coming and going from pins 0 & 1? If it does show, how do I test for any problems that may be interfering with communications?

The serial data that goes from the Uno to you PC first goes through pins 0 and 1 and then to the IC controlling the USB connection to your PC. So, the standard answer is to NOT use pins 0 and 1 unless you remove the IC doing the USB interface.
This is why the software serial code was invented for the UNO!
Paul

billz1:
I’m another new guy to Arduinos and I have a UNO and I am not certain the serial pins (0 & 1) really work.

Don't worry about it. They do.

If something is not working as you expect the problem will be with your program - which you did not Post.

...R

You have to determine what the other board uses.

  • You have to connect the Arduino TX to that other board RX. And the Arduino RX to the other board TX. But only if the voltage levels match.
  • If the other board is a 3.3V board, then you might damage things when connecting an Arduino Uno to it.
  • Sometimes the "TX" and "RX" labels are wrong. This happens a lot.
  • It can be logic level signal of 5V that is idle high and the startbit is low (this is what the Arduino Uno uses).
  • It can be a inverted signal.
  • It can be the wrong baudrate.
  • It can be RS-232 which can be in the range of 0...5V up to -15...+15V.
  • It can be something that is not standard.
  • The other board might expect a checksum and maybe the checksum is wrong. Can you do a simple request to the other board ?
  • and so on, and so on.

Can you connect the other board to a computer ? Is there a way to test the other board serial communication without using an Arduino ?

What kind of thing is the other board ?

I do appreciate any and all of your help because this part of controllers and program is all very new to me.

If I'm understanding correctly, one says 'no' and another says 'yes'. I do like the check list.

I have not connected the UNO to another UNO because I don't have one yet. I have connected it to a USB to serial device and can see some LED action but nothing displays on my Windows box.

If the signal is inverted from the UNO, can it be set the other way?

The directions on the MP3 player gives the expected UART settings -> Adopt full duplex serial port communications. 9600 Baud, 8 data bits, 1 stop bit, no check bit. I'm not sure how to verify all of this on the UNO.

Using a USB to serial device on my Windows box, I can send HEX codes to the MP3 player and it works but sending the same codes using the UNO, it doesn't work even though the Serial Monitor shows the same code. There is an 'except' though. The Serial Monitor doesn't echo any leading zeros when sending HEX 00, 01, 02, 03... Is it sending both or not? I am not sure that it matters or not, it is just different from the utility in Windows.

Here is my code:

#define d_sleep 10000

static byte ccPlay[]   = {0xAA, 0x02, 0x00, 0xAC};
static byte ccNext[]   = {0xAA, 0x06, 0x00, 0xB0};
static byte ccVolU[]   = {0xAA, 0x14, 0x00, 0xBE};

void send_command_to_MP3_player(byte command[], int len) {
  for (int i=0; i<len; i++) {
  //Serial.println(command[i], HEX); //<-- includes cr/lf which I don't want
    Serial.print(command[i], HEX);
  }
  //Serial.println();
  delay(100);
}

void setup() {
  Serial.begin(9600);
  delay(1500);
  //send_command_to_MP3_player(ccVolU, 4);
  //delay(1500);
}

void loop() {
  
  send_command_to_MP3_player(ccPlay, 4);
  delay(d_sleep);
  send_command_to_MP3_player(ccNext,4);
  delay(d_sleep);

}

billz1:
I do get response from Serial Monitor but does Serial Monitor really show what is coming and going from pins 0 & 1?

Yes.

If you see what you expect to see, your programme is kosher and your problem is somewhere else. It is absolutely OK to use hardware serial pins 0,1 as you intend. Indeed, you are at an advantage as you then get to use the serial monitor to see what is going on in both directions. Software serial is often just an exercise of last resort for the desperate, lazy, and incompetent, and best avoided.. The first thing to do now is check your wiring. You don't say what you are doing other than "sending data", and you clearly have no difficulty doing that, but you say nothing about what you are sending the data to, and the problem may well be there.

Edit
I thought you were seeing what you expect to see on the monitor but your reply #4 seems to contradict this. If your receiving device does what it is told from Windows, presumably a standard terminal, I guess your problem is that you are not formatting your hex output correctly, i.e. you may indeed be seeing what you expect to see, but it is not what the receiver wants to see.

The program I showed before is suppose to send HEX AA0200AC but the Serial Monitor shows that it is sending AA20AC, like it is not sending the leading zeros on the 2nd and 3rd bite. If the Serial Monitor is designed to show exactly what is being transmitted, then how do I change the program to send the leading zeros?

The MP3 player I am attempting to communicate to does work using a serial port utility and a USB to serial adapter sending HEX AA0200AC and the serial port utility does echo the leading zeros.

I'm afraid I don't know anything about HEX. I guess you need to convert it to char or a string so that it looks right to the receiver.

If you want a simple way to see if communication works between the Arduino and the Serial Monitor try the program from the second example in Serial Input Basics and type a message (such has "hello world" at the Serial Monitor. Make sure to have the line-ending in the Serial Monitor set to line-feed or both.

...R

I started looking at Serial Input Basics and 'Hello World' but my project requires HEX UART communications, not text. I'm saying this with much respect and kindness. If the Arduino UNO sends UART inverted, then how do I un-invert it without any more circuits?

Basically, how do I make this work?

billz1:
I started looking at Serial Input Basics and 'Hello World' but my project requires HEX UART communications, not text. I'm saying this with much respect and kindness. If the Arduino UNO sends UART inverted, then how do I un-invert it without any more circuits?

Basically, how do I make this work?

Hex is the text representation of binary, so it is easily readable by humans.
Paul

As you are talking about missing leading zeros, I assume that your device expects to receive ASCII characters representing a hexadecimal number.

When you send your number to the serial port, check it's value first and if it is less than 16, then send an extra '0'.
Something like:

void send_command_to_MP3_player(byte command[], int len)
 {
  for (int i=0; i<len; i++) {
    if (command[i]<16) Serial.print("0");
    Serial.print(command[i], HEX);
  }
  delay(100);
}

Thanks markd833, That code did fix the echo issue with Serial Monitor. However, the MP3 player doesn't respond.

It was mentioned on one posting that the UNO may send inverted UART commands. Is something like that possible and if so, how do I not invert the UNO communication?

The MP3 player does respond to the same HEX commands using a windowz Serial Port Utility.

The MP3 player does respond to the same HEX commands using a windowz Serial Port Utility.

Does this mean the MP3 player is connected to the PC using USB directly? Or is it connected using an RS-232 adapter on the USB?

Paul

Paul,

When I move the MP3 player to the USB to serial device that is on the windoz box, using a serial port utility and the MP3 player plays the MP3s. But when I run this program on the UNO with the MP3 Player connected to the UNO, and the program is suppose to be sending the very same commands, the MP3 Player does NOT respond. I don't know why. I thought the missing zero was the issue. Maybe not.

It was mentioned that the UNO sends an inverted HEX signal. I can't figure why they would be different from the rest of the world. But, I'm willing to try un-inverting.

billz1:
Paul,

When I move the MP3 player to the USB to serial device that is on the windoz box, using a serial port utility and the MP3 player plays the MP3s. But when I run this program on the UNO with the MP3 Player connected to the UNO, and the program is suppose to be sending the very same commands, the MP3 Player does NOT respond. I don't know why. I thought the missing zero was the issue. Maybe not.

It was mentioned that the UNO sends an inverted HEX signal. I can't figure why they would be different from the rest of the world. But, I'm willing to try un-inverting.

The your MP3 device has an RS-232 serial port. That means it requires the data signal to be between +3 to +12 volts and -3 to -12 volts. It alternates between those + and - signals for each bit that is sent. Your Arduino only sends data using 0 volts and +5 volts for data.
You need to use an adapter board between your Arduino and the MP3 that will convert the Arduino 0 and +5 volt signal to a proper + and - signal for the MP3.
Paul

I wonder if your Windows serial port program is sending CR & LF as well as the command characters?

To answer your Q in reply #4, I think 8N1 (8 data bits, no parity, 1 stop bit) is the default setting for the UNO serial port.

Do you have any information on your MP3 player? Can you provide a link to the documentation for it?

OOPS! Didn't see Paul's reply. That's probably the solution for you.

billz1:
I started looking at Serial Input Basics and 'Hello World' but my project requires HEX UART communications, not text.

I realise that.

Your Original Post says that you do not know if the Serial pins are working. My suggestion to use the example fro Serial Input Basics was for the purpose of verifying that Serial is working. It's much easier to do that with human readable text.

Once you are satisfied that Serial is working you can then focus on sending your HEX data without concerns about whether the microprocessor and the USB link is faulty.

...R

Being new to Tx/Rx communications via UNOs I don't know where to go next, so I'm looking for advice.

What I did last night was to connect a MEGA to the OUN, run the same program sending the HEX to the MEGA, then using Serial Monitor, watch what goes to the MEGA, what I saw was exactly what I think should be being sent and should make the MP3 layer work. But when connecting to the MP3 Player, it doesn't work. I tried extra grounds between the UNO and even powering the MP3 player through the UNO as well as another power source with appropriate grounding.

Again, I connected the MP3 Player to the USB to serial adapter and sent the same commands through a serial port utility to the MP3 Player and the player responded appropriately (it worked).

What do I not know about that could inhibit proper communications to this MP3 player?