Serial communucation rasperberry pi and atmega328p
Let's assume you are using python for simplicity.
Electronic part:
Connect the serial ports of the ATmega to the serial ports of the Rpi. This is:
Rx &lt;-&gt; Tx
Tx &lt;-&gt; Rx
GND &lt;-&gt; GND
You must be sure of two things to be sure that you are not going to burn anything and the logic levels are correctly recognices: the sources of each one must be the correct one; that means, the Rpi to 5V and the ATMega to whatever it uses. The second is that the grounds must be connected together, if they are not, each one would have a potencial reference different and this could end very badly.
Raspberry Configuration:
The raspberry is by default configured to use the serial as console in case you have troubles and you dont find yourself with a screen, ethernet or whatever. To connect it with another device you must first disable this option.
Got to : sudo raspi-config and in advance option deactivate the &quot;as serial&quot; option.
You should also check that you have the permissions to talk to tty, for this you can google tty linux and you will find 5k answers of how to add yourself to the correct group.
Software
by doing dmesg | grep tty you should see your device connected to tty (serial) and the name given by Rpi.
Then you can just use the python pyserial library and talk via serial without any problem. using serial.Write and serial.Read
https://pythonhosted.org/pyserial/
Good Luck!!!