Thursday, April 7, 2016

Raspberry Pi 3 How to Use Serial Port

Here is my work summery on the Raspberry Pi 3.  As I start working on it and putting it all together, this efforts are made to collect all the information I need, it is wise to save all my work notes.

So, first of all you should have the following items on your desk to start working on the Raspberry Pi:
I like this image from Element 14 Community.






I am done writing all the drivers and some apps that use I2C, SPI, GPIO, and other resources on the board. so, I will be updating this page soon.

Setting up the RaspberryPi:
to start here is the ID and password for the default user
ID: pi
Password: raspberry


Serial port:
So, on the Raspberry Pi 3 and other too, the serial port is used for the consol out put.  that is not going to work if we are trying to use it for our designs.  So, the first thing is to stop the consol from writing to the port and freeing it for us to use.
In Raspberry Pi there is a tool called Raspberry Pi Configuration.  you can start this tool by clicking Menu-> Preference, then Raspberry Pi Configuration.
Now, in the second tab, Interfaces, click on disable next to Serial.  Clock OK and restart the Pi.

Important:  Serial port on Raspberry Pi 3 is called /dev/serial0.  So if you try to use the /dev/ttyAMA0 or any other name it will not work.

Using minicom or potty applications you can test port
connect pin GPIO14 and GPIO15 to make a loop back, so if you type any character in the terminal you should see it.  If the connection between GPIO14 and GPIO15 is missing you should not see any characters on the screen.

Sample code to use to configure/interface to the serial port: