sachin221199
Posts: 5
Joined: Tue Jan 31, 2017 10:15 am
Location: india

UART port not working properly

Tue Jan 31, 2017 12:04 pm

Hello,

I am using Rsapberry pi 3 model B with raspbian installed through Noobs;

Actually,
I am trying to communicate with UART port given at GPIO pins.

So,
to enable serial port from GPIO for UART communication some settings need to be done.
All settings has been done from cmdline.txt to config.txt;
and
from systemctl stopped S0 and disabled S0;
and from systemctl enabled AMA0 as well;

Minicom has been installed successfully;

so now, i am opening it using following command in terminal in raspbian os in raspberry pi3;
sudo minicom -D /dev/ttyAMA0 -b115200

minicom starts ok;
Actually, i had looped back serial pins on raspberry pi3 (tx pin has been sorted with rx pin on raspberry pi3 itself)

now what problem comes into picture are as given below:

1) so as i had sorted tx rx of pi3 so whatever i ll type in minicom it will be echoed back
but suddenly it stops and a string printed on the screen as shown in picture.
and it asks for login and password somehow after a seconds it ll be automatically logged in and then i can type in it. after 1 or 2 minutes it stops working
and same message displayed on screen.
2) when i try to communicate it by using python 3.0 by sometimes it works and as suddelnly it stops working and displays some error messages to shell.
like:
1) OSError: [Error 11] Resource temporarily unavailable;
2) IOError: [Error 5] Input/Output error;
and when i restarts the program it starts working ok and suddenly stops somehow.
3) when i communicate pi3 with an arduino then i am just sending my name "siddharth" or any other string to be written over PI and sending to arduino;
1) sometimes it sending ok but suddenly it stops sending that string and sends like : "Raspberrypi login: password:"
2) it continuously sending same login as written above and suddenly shows those error list.

Kindly guide me at where or how it can be solved;
or is there any settings need to be done in pi;

thank you
Siddharth Parmar
Attachments
0202.jpg
0202.jpg (23.2 KiB) Viewed 3122 times
0101.jpg
0101.jpg (43.21 KiB) Viewed 3122 times

User avatar
Gert van Loo
Posts: 2486
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: UART port not working properly

Tue Jan 31, 2017 8:12 pm

The login prompt is the clue: you still have a process running which allows users to use the UART port as terminal.
See this thread: viewtopic.php?f=66&t=123081&hilit=inittab#p828794

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: UART port not working properly

Wed Feb 01, 2017 4:59 pm

sachin221199 wrote:All settings has been done from cmdline.txt to config.txt;
I do not think you have edited these files correctly.
Post the output of these three commands:

Code: Select all

cat /boot/cmdline.txt
grep uart /boot/config.txt
uname -a
Dave.

sachin221199
Posts: 5
Joined: Tue Jan 31, 2017 10:15 am
Location: india

Re: UART port not working properly

Thu Feb 02, 2017 4:54 am

dear dgordon42

Kindly refer the attachment.
Attachments
020217_001_001.jpg
020217_001_001.jpg (36.83 KiB) Viewed 2875 times

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: UART port not working properly

Thu Feb 02, 2017 1:42 pm

You are running the 4.4.38 kernel, so your Raspbian OS is up to date, which is good.

Your '/boot/cmdline.txt' file looks good.

Your '/boot/config.txt' contains one instance of "enable_uart=1", which is also good.

Your '/boot/config.txt' file also contains the entry "dtoverlay=pi3-miniuart-bt". Do you really need this? It is not necessary to get a Serial Port working on a Pi 3B!
Unless you really really need to use the '/dev/ttyAMA0' UART instead of the '/dev/ttyS0' UART, I would recommend that you remove this line from '/boot/config.txt', reboot your Pi, and try again.
sachin221199 wrote:from systemctl stopped S0 and disabled S0;
and from systemctl enabled AMA0 as well;
I do not know what commands you issued to do this, but it is not necessary to issue any Systemd commands to get the Serial Port working, so I suggest you undo all of these commands. You may also need a reboot after this.

You should refer to your Serial Port as "/dev/serial0", that's serialZero, not serialOh, instead of using the 'ttyAMA0' or 'ttyS0'. By using 'serial0', you will always get connected to the 'users Serial Port' regardless of which UART is being used, and your code and settings should work correctly in future software or hardware upgrades for the RaspberryPi.

If, when you get this working, you plan on connecting the Pi's Serial Port to another device or computer, you should be aware that the Port works at 3.3V. It cannot handle the 5V from a TTL Serial Port, or the full RS232 signal voltages. Anything more then 3.3V on the Pi's Serial Port pins can destroy the Pi. Serial Port Level Converters are available if you need them, and Google should be able to find them for you.

If you really must use "dtoverlay=pi3-miniuart-bt", then you also need to add the line "core_freq=250" to '/boot/config.txt'.

I'm not sure where the log-in message shown in your screen shots is coming from. With your version of '/boot/cmdline.txt' and the Serial Port pins connected together for a loopback test, you should not see this unless you have used Systemd to enable a getty on the Serial Port. You may have done this inadvertently as part of 'enabling AMA0 with Systemd' as per your above quote. If you have, undo it, at least until you get the rest working.

Good Luck,
Dave.

sachin221199
Posts: 5
Joined: Tue Jan 31, 2017 10:15 am
Location: india

Re: UART port not working properly

Wed Feb 08, 2017 4:36 am

Thanks for your reply dave,
but , not resolved yet.


There might be something which is interrupting UART port during communication.

And not able to understand why this login string comes to screen.

and during communication with arduino it also sends that login string to it.
There must be some command needs to be executed to mask this interruption.


:!:

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: UART port not working properly

Wed Feb 08, 2017 12:58 pm

Here are a few things to check:

First, please confirm that your '/boot/cmdline.txt' file has not changed from the version you posted above.

Next, please confirm that you have removed the "dtoverlay=pi3-miniuart-bt" line from the '/boot/config.txt' file.

Then, post the output of:

Code: Select all

ls -lh /dev/serial0


Finally,
sachin221199 wrote:and during communication with arduino
Please confirm that you understand my advice from above concerning the 3.3V limit on the Pi's Serial Port. Most, but not all, Arduinos work at 5V.

Thanks,
Dave.

syed.idris
Posts: 1
Joined: Wed Apr 11, 2018 7:17 am

Re: UART port not working properly

Wed Apr 11, 2018 7:40 am

Hi,

I am also facing kind of similar issue with my Raspberry pi3 in serial communication.
I am using NodeRed for communication of Raspberry pi3 and Arduino.
I am able to send the data from Raspberry pi to Arduino but data receiving from Arduino is not working fine.

while receiving data some times data getting loss or sometimes it is showing as
"serial port /dev/serial0 error: Error: Permission denied, cannot open /dev/serial0"

sometimes error as
"serial port closed unexpec"

sometimes data is received to raspberry pi but it is showing the login details of raspberry pi.

please find details of my Raspberry pi settings as attached

Regads,
Idris
Attachments
test.JPG
test.JPG (46.19 KiB) Viewed 1614 times

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: UART port not working properly

Wed Apr 11, 2018 12:48 pm

@syed.idris:
First, what type of Arduino are you using?
Most (but not all) of them work at 5V, the Pi's UART works at 3.3V, and sending it a 5V signal directly from an Arduino can destroy a Pi.
syed.idris wrote:while receiving data some times data getting loss or sometimes it is showing as
"serial port /dev/serial0 error: Error: Permission denied, cannot open /dev/serial0"
syed.idris wrote:sometimes data is received to raspberry pi but it is showing the login details of raspberry pi.
Both of the above errors are most likely caused by having the phrase "console=serial0,115200" in your '/boot/cmdline.txt' file.
Use a text editor to remove this phrase from '/boot/cmdline.txt'. Be careful not to split the line when editing it, the '/boot/cmdline.txt' file must contain only 1 line to work correctly. The Pi will need a reboot after the '/boot/cmdline.txt' file has been edited.

Hope this helps,
Dave.

Return to “Troubleshooting”