Electrical – Atmega328p RS232 communication what’s wrong

atmegars232serial

I'm trying to connect Atmega328P to PC via RS232, the Microcontroller code is basically a : Serial.write("Greetings !"); inside the loop function.
I've tried the following circuit but it doesn't work and doesn't show anything in my serial monitor :
enter image description here

Am I missing anything here ??


Here is the full code:

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

void loop() {
  // put your main code here, to run repeatedly:
  Serial.write("Greetings !");
  Serial.write("\n");
  delay(1000);
}

Best Answer

Since your design includes two ICs, I suggest you debug them separately. Bruce already suggested a good test for the MAX232: connect TXD and RXD pins together and see if whatever you send from the PC echoes back.

A good test for the Atmega chip is to connect it to your PC via a USB UART and see if you can read your greetings message. If you don't have a USB UART, connect a LED to the TX pin:

schematic

simulate this circuit – Schematic created using CircuitLab

If you have programmed the MCU correctly, the LED should briefly blink every second, as MCU is transmitting your "Greetings" message.

Finally, since you don't show how you connect the two ICs, so you may want to double check that. Do they have a common ground? Did you connect TX to RX and vice versa?