[SOLVED] - Monitoring serial traffic.

Good afternoon (well, it is here).

I’m currently trying to build a replacement for an iPod interface that I use in the car. I’ve currently got it all set up on the bench, and have an Arduino Mega hooked up to ‘sniff’ the serial traffic that passes between the iPod and the interface. I have written some code that runs on the Arduino, which logs each message and sends it out to a terminal window (on a different serial port) to be viewed/decoded.

Everything works perfectly when I have the Arduino Rx line connected to the iPod Tx line. I can see every message that the iPod sends back to the interface. If I connect the Arduino Rx line to the interface Tx line (iPod Rx line), I get nothing. I’ve tried putting a debug print line in the main loop, that prints to the terminal window if any serial is available, but I get nothing. It’s like the Arduino can’t see any serial activity at all. I know for sure that there’s data on the line, as I can see it on my logic analyser.

Just to recap:

Arduino Rx to iPod Tx - everything fine
Arduino Rx to interface Tx (iPod Rx) - nothing

I can’t see that it’s a problem with the code (I can post it if required), as it works as intended, when connected to the iPod Tx line. The Arduino should see data on either line, and should handle them exactly the same. The data format is identical on both lines, and again, this can be confirmed with the logic analyser.

I’ve attached a schematic that shows how things are connected. I’m just moving the wire that’s coming from the Mega Rx pin to either Tx or Rx. Although not shown, I am actually using a logic level shifter between the Arduino and the iPod side as the iPod logic is at 3.3v. You’ll also see the Arduino shown as an Uno R3, but for this example it makes no difference. I just didn’t have the Mega in Eagle.

I suspect I’m doing something either very obvious, or very stupid (or both), but I’ve been working on this for a couple of days now, and can’t figure out what I’m doing wrong. Am I correct in thinking that the Arduino Rx line should be able to read data on iPod Rx and Tx ?

Thanks for your time,

Ian.

From that diagram you have not connected the grounds on all three systems together.

Grumpy_Mike: From that diagram you have not connected the grounds on all three systems together.

Sorry Mike. Forgot to show any power to the Arduino. I'll update the schematic in a bit, but they all have common ground.

I wouldn't expect to get anything without a common ground.

Ian.

On the Mega and Uno, the RX line is loaded down by the ATMega16U2 which is the USB interface. There's a resistor there so other serial data can override it but if the other transmitter is weak (or has a similar resistor) then it won't work.

Can you connect the logic analyzer at the same time as the Mega? I think you may find that the line goes low and stays low because it can't drive the Mega input.

Since you have a Mega, use one of the other serial ports. They don't have this extra load attached.

MorganS: On the Mega and Uno, the RX line is loaded down by the ATMega16U2 which is the USB interface. There's a resistor there so other serial data can override it but if the other transmitter is weak (or has a similar resistor) then it won't work.

Good call 8) . Swapped to Serial2 and it now works as intended.

Can you connect the logic analyzer at the same time as the Mega? I think you may find that the line goes low and stays low because it can't drive the Mega input.

Yes, was able to have the Mega and logic analyser hooked to both Tx & Rx at the same time. This is what was confusing me.

Thanks very much.

Ian.

I am attempting a very similar project and was wondering if you would be willing to post the code you wrote to output the serial from/to the ipod. Thanks in advance.