Electrical – Serial communucation rasperberry pi and atmega328p

atmega328praspberry pi

I have a design system which is generate data. My system include lidar sensor and atmega328p. Atmega is driving my sensor and generate data. No problem is here.
But my aim is data processing in matlab so ı have to communication matlab and my rasperberry wireless because this project is robotic project.

I am using rasperberry pi. Rasperberry pi is the center of system. All data is gather here. it will be analyze and robot will move with this data.Rasper will send data matlab. Matlab will show graph and information also.This is Description of my project.

My problem is raspberry and atmega serial communication. I can't succeed it. How can ı solve this problem. I am beginner rasper and ı don't understand anything. A lot of people says minicom etc. I install it but ı can't see anything. Everybody says the first step is you must connect rx tx pin to rasper and send rasper ls /dev/tty this command and it will output like this /dev/ttyAMA0 but ı can't see this output also.
raspberry pi

Best Answer

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 <-> Tx

Tx <-> Rx

GND <-> 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 "as serial" 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!!!

Related Topic