Communication issue between Arduino and RS232

Hello.

I want to read temperature data using the rs232 port on my PC, but first I checked if the MAX232 converter even works properly and I get this error messages after uploading:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x0c

I selected the right board (Arduino Uno) and the port COM1, I tried restarting while uploading the cord and nothing happens. Connections are as follows:

Vcc to 5V on Arduino
RXD to TX on Arduino
TXD to RX on Arduino
GND to GND too

Arduino is connected to PC via USB for uploading the code (as I read, uploading via serial typically doesn't work) but also connected to 7.5V supply through the barrel jack, so I can disconnect the USB cable after uploading to transfer data entirely via rs232

What kind I do? Thanks in advance

If I understand this correctly, you have an Arduino UNO connected via USB to the PC and it is working, but you are trying to upload code via a MAX232 connected to a physical serial port designated as COM1 on the PC?

In order to program the Arduino via COM1 via the MAX232, you will also need to connect its DTR pin to the reset pin on the Arduino via a suitable capacitor, e.g. 0.1uF should suffice. This is so that the MAX232 can signal the Arduino to reset when the serial connection is opened and run the bootloader which then starts the upload process.

Also bear in min that you can't have both USB and the MAX232 connected at the same time. The UNO has just one UART and that is already being used by the USB connection. When using the MAX232, unplug the USB and vice versa.

Thanks for the response. My MAX adapter isn't a bare, chip, it's a PCB with only the four pins I mentioned above and a DB9 female connector on the other end

I am trying to upload code not via serial, but via USB because I read that otherwise it won't work due to the bootloader.

And I connected both cables because code upload needs USB, but once uploading is finished I should be able to use rs232 interface alone (or so I read) and in that case I need the external power given that the rs232 is only for data, not for power.

If it's an Uno R3, the Tx and Rx pins are weakly connected to the USB interface chip. By hooking up your RS232 board to those pins, you're overriding that connection. That's why the upload fails. You'll have to disconnect the RS232 board, do your upload, then reconnect it.

1. What type of temperature sensor you have conncted with UNO?

2. Are you using the following (Fig-1) TTL <-----> RS232 Converter?


Figure-1:

If you are using the item of Fig-1, then you need the following RS232<----> USB Converter cable (Fig-2).


Figure-2:

3. Are you using the following (Fig-3) TTL <------->USB Converter?


Figure-3:

The item of Fig-3 uses CH340G chip which directly converts the TTL Protocol to USB Protocol and is very suitable to interface UNO's UART Port with PC's USB Port .

OK, in that case there is one other thing you can do. Instead of using the RX/TX pins to connect the MAX232, set up an additional port using SoftwareSerial. This uses a couple of GPIO pins to emulate a serial port that can be used to connect the temperature sensor. That way you can still upload new code via USB as you are doing at present and read the temperature data via the emulated port without the two interfering with each other. The speed of the emulated port will be restricted to 57500 baud or less, but that shouldn't be too much of a problem for reading a temperature sensor periodically.

https://docs.arduino.cc/learn/built-in-libraries/software-serial/

I have fig 1, thank you

I’ll check which rev it is, thanks

I’ll try that out too and see if it works, thanks

You may carry out the following steps of this Tutorial:
1. Make the followih hardware setup (Fig-1):



Figure-1:

2. Upload the following sketch into UNO:

#include<SoftwareSerial.h>
SoftwareSerial SUART(10, 11);  //SRX = 10, STX = 11

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);
}

void loop()
{
  int y = analogRead(A0);
  float testVolt = (5.0 / 1023.0) * y;
  SUART.println(testVolt, 1);
  delay(1000);
}

3. Open a second IDE from Start icon.

4. Select COMX port for the RS232 Converter Cable. If necessay, goto Device Manager and look for the COMX port of the cable.

5. Open Serial Monitor at Bd = 9600 from the second IDE.

6. Check that the Serial Moniotr shows about 3.3 at 1-sec interval.

7. Remove USB Cable from UNO.

8. Apply 7V - 12V at the Barrel Jack of UNO.

9. Press Reset Btton of UNO.

10. Check that second Serial Monitor shows about 3.3 at 1-sec interval.

11. Setup using TTL-to-USB Converter (Fig-2):


Figure-2:

Those arrows between USB and UART just indicate communication between 3.3V and A0, the same goes for USB and UART. Am I right? I am new to this

It says that the 3.3V is coonected with A0-pin using a jumper wire.

Do I need this even if my PC has a native RS232 connection?
Come to think of it, my PC also has an LPT port, and IIRC, those don't need TTL converters, wouldn't be easier to just use the LPT interface?

Then you need RS232 <----> TTL Converter (Fig-1) to interface TTL_levle Arduino UNO using a Software UART Port.


Figure-1:

yup, that's exactly the one I am using