alanlyyy
Posts: 8
Joined: Mon Jan 08, 2018 11:41 pm

Serial Port + minicom not working

Wed Jan 17, 2018 11:43 pm

Hi guys,

I am currently performing a loop back test using pins 14(TX) and 15(RX) of the raspberry Pi. I am trying to write text in minicom and
have it loopback into the terminal shell to be displayed. I am having a problem with minicom flickering crazily when I run my python program and eventually giving me an error closing my program: "serial.serialutil.SerialException: device reports readiness to read but returned no data."

I have already enabled UART writing the following lines in /boot/config.txt: "enable_uart = 1" and "dtoverlay=pi3-disable-bt".
I have disabled getty login service for port ttyAMA0 using the command: "systemctl mask [email protected]".
The code is shown below.


import serial
import RPi.GPIO as GPIO
import time

port = serial.Serial("/dev/ttyAMA0", baudrate =9600, timeout = 3.0)

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

while True:
rcv =port.readline()
port.write(rcv)

port.close()

Please help I'm stuck!

klricks
Posts: 5899
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Serial Port + minicom not working

Thu Jan 18, 2018 12:32 am

Verify the loopback working before trying any code.
You can't run your code and minicom at the same time if that is what you are trying to do.....
If you want to test your code then you need a 2nd RPi running minicom connected TX to RX and RX to TX + GND to GND to a RPI running your code. Or use a serial RS232 adapter to another computer / laptop.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

alanlyyy
Posts: 8
Joined: Mon Jan 08, 2018 11:41 pm

Re: Serial Port + minicom not working

Thu Jan 18, 2018 2:25 am

Thanks I thought minicom was similar to the arduino serial monitor, however I don't think its the case.

alanlyyy
Posts: 8
Joined: Mon Jan 08, 2018 11:41 pm

Re: Serial Port + minicom not working

Mon Jan 22, 2018 3:02 am

I got it to work!

For anyone trying to figure out how to use minicom to communicate with your device like using the serial monitor on arduino.
The link below shows you a step by step process to find your serial port and and changing the baud rate/parity/bits to communicate
with your serial device. In my case I was trying to figure out how to read the responses of the AT commands I was writing with a python script to a HC-12 RF sensor from my raspberry pi

Note: this guide does not teach you how to setup your UART port for serial communication by disabling bluetooth or using mini-UART


reference:
https://help.ubuntu.com/community/Minicom

Return to “Beginners”