Trouble with Serial Comnumication

Hi, Im trying to control my Pioneer amplifier with Arduino. Previously I had a Sony Tv which controlled the pioneer perfectly in terms of powering on and selecting it as the audio device. Samsung however does not play well with CEC. All I need to do to get it all in sync is power the amplifier back off and on again. this then sets the amplifier as the desired audio device.

So on my amp it has a serial interface. In the spec it states 9600 8N1 standard settings. It has a full command reference so this will be easy.

First thing i did was hook the amp up to my PC and checked it out in putty. Everything looks great. Putty set to 9600 yields 2 way communication. I can send commands to power on and off the amp at will.

So i wrote a simple sketch that toggles the amp every 10 seconds off/ on as a test. uploaded, nothing happened. In the serial monitor i can see the data P0, PF appearing as expected but the amplifier does not respond.

So next i changed my sketch to see what the data looks like coming in from the amplifier. This is my sketch

String dataIn;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {

if (Serial.available() > 0) {
Serial.println("This just in");
dataIn = Serial.readString();
Serial.println(dataIn);
}
}

This is the result in serial monitor

As you can see it is just garbage data.

It should look like this

I've checked all the baud settings and frankly they are pretty standard. I know it look's like that however if you don't have anything deeper to add than "Check your baud settings" kindly do not replying. I'm wondering if the data needs to be converted or something. BTW, I'm using the same serial cable to connect to my PC and Arduino, just using some jumper wires to connect to the pins on both the cable end and Arduino. Using pin2/3 RX/TX and 5 GND. As data is being received i believe I'm on the right track with the wiring.

Using Arduino Nano

Serial settings in putty

The amplifier will have an RS232 serial interface but the Arduino Serial interface operates at TTL levels, so the two are incompatible and you will need a converter between the two

With what?

The code is incomprehensible. You don't say what Arduino you are using, but I bet the only serial commands I can see are hardware serial which is just talking to itself, and the amplifier is doing nothing and hearing nothing and the "this just in" message is a lie. Baud rate is clearly not the problem but everything else is. Since you appear to want to use the serial monitor, you will need two serial channels, one for the serial monitor and the other for the amplifier. So far, you have only got the former, which is probably kosher - just mis-used.

UKHeliBOB --> thanks that is definitely the issue which I just overlooked

to Nick_pyner - go away your no value to this conversation

I don’t think @Nick_Pyner was too far off topic, he just assumed you had the faintest idea what you were doing.

Fair enough, you admitted you didn’t, but burning people that are trying to help isn’t a good way to start your forum life.

Thanks for your advice, I honestly didnt find Nick_Pyner response helpful at all, He said i didn't state what board I'm using, it clearly says in my post I'm using arduino nano, He says my code is garbage, says something about "this just in is a lie", the data shown after that line is the actual data received from the amp on arduino serial all be-it unreadable. Regardless all i was trying to achieve was to get the amplifier serial feed to display in the serial monitor, which the image shows i achieved, so code works, he then asks how i connected it to my pc, given the amp has a rs232c interface i would have thought that was pretty obvious (my mistake). So all in all, wasn't keen on hearing any further.

Apologies. I missed your note that you had a Nano, I just saw

and merely assumed you had something of that ilk, which is indeed true, and still leaves the question about how you communicate with any serial device on pins 2/3. Further, you haven't said what is connected to pins 2/3, but you imply that you are using them for serial comms.

As things stand with the code, I submit that the "this just in" that you see on the monitor tells you no more than that the loop has arrived at that particular line, and did so by virtue of an input from the monitor. On top of that, there is nothing in your code that suggests you are using pins 2/3 for anything, so my unhelpful guess is that you just think you are.

You did not say your amplifier used RS232, somebody else did, and did it with no more than the name of the manufacturer, so, unsurprisingly being unfamiliar with serial ports on Pioneer amplifiers, I wouldn't have thought it was obvious at all, indeed I thought it rather unlikely - hence my question. This was particularly asked in the light of your assertion that "everything looked great" using the PC and Putty, and I haven't seen a PC with RS232 for quite some time.

Nick, Thanks for clarifying, I guess i felt your original reply came across as aggressive and condescending which is why I reacted like I did. Reading your comments puts things into perspective and shows I need to state everything clearly. When reading back in my head it made perfect sense, however of course it did as I'm party to all the context.

I'm sure UKHeliBobs suggestion will solve this anyhow, and I should know today as a rs232 to ttl converter should show up on my door. But to answer the points you raised:

still leaves the question about how you communicate with any serial device on pins 2/3. Further, you haven't said what is connected to pins 2/3, but you imply that you are using them for serial comms

I was referring to the pins i was using on the cables db9 connector itself. this was to ward of questions of how i was connecting to the RS232 interface of the amplifier. As I'm just using Serial.begin in the code on a Nano board, i would assume that you would think i was using the dedicated serial TX/RX pins on the board. I concede this paragraph could have been better written.

You did not say your amplifier used RS232, somebody else did, and did it with no more than the name of the manufacturer, so, unsurprisingly being unfamiliar with serial ports on Pioneer amplifiers, I wouldn't have thought it was obvious at all, indeed I thought it rather unlikely - hence my question. This was particularly asked in the light of your assertion that "everything looked great" using the PC and Putty, and I haven't seen a PC with RS232 for quite some time.

OK well any consumer equipment that as a serial interface, 99.9% of my experience is that it is rs232. In commercial applications you do see RS485, again my assumption that everyone would assume this is wrong. I would be interested to know what standard you would assume if you saw the serial db9 on the back of your unit.

RS232 is still quiet common on desktop pc's although on laptops it went the way of the dodobird a long time ago.

Thanks again for your inputs

UART is 1:1 communication.
If you are using "Serial" to connect your PC to Nano occupies RXD and TXD of D0 and D1.
It can no longer be used to communicate with the your amplifier.

I'm only connecting the Nano to the pc via usb. I'm using the serial monitor function in the IDE just to see what is going on

How exactly did you test the amplifier using puTTY and your PC ?
How were they connected ?

That is exactly as it appears, hence my original post, the last para of which might merit another read.

It clearly doesn't work, and I submit the image tells you nothing. However, it is all very confusing, and I now believe that the code you posted has nothing to do with the proposed project. It is in fact quite kosher for the serial monitor and the peripheral to share hardware serial so that the monitor can "see what's going on", but that's all it does. I don't know what you would expect to see in that event. Maybe the amplifier sends periodic data, without input or control from you.

I haven't seen the D9, and nobody told me it's got one. I don't know anything about RS485 but I believe one of my old laptops has it. I would have expected a consumer item would simply use USB these days, in which case there should be no problem connecting to Arduino, hence the question. Actually, I have just looked behind my current desktop and found that it has a D9.

RS232 null modem between Pioneer amp and my Dell Desktop which also has rs232

The code works fine for what i want it to do, all I'm trying to achieve here is see the data reflected in the serial monitor which is what all the upside down ????? are. As already suggested, the issue is due to mismatching serial standards. The image tells me, If I see "this just in" it has received data on the serial port, The next line is the data it received. Why do you think this is not working for me apart from the garbled data?

I think you are implying that you are receiving data from the amplifier. If that is the case, what is prompting it to send it?