Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Raspberry pie communicate with Serial Devices using uart Serial Port

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Raspberry pie how to use uart serial port to communicate with serial devices, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Raspberry pie hardware version: second generation B +

Raspberry pie system version

Root@raspberrypiroot@raspberrypi:~# lsb_release-aNo LSB modules are available.Distributor ID:RaspbianDescription:Raspbian GNU/Linux 8.0 (jessie) Release:8.0Codename:jessie

Modify the file: vim / boot/cmdline.txt

Change it to root@raspberrypi:~# cat / boot/cmdline.txtdwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait like this

Restart raspberry pie:

Root@raspberrypi:~# reboot

Connect the serial port of raspberry pie with other serial devices

Raspberry pie GND-- > GND serial port equipment

Raspberry pie TXD-- > RXD serial port equipment

Raspberry pie TXD-- > RXD serial port equipment

Use the pyserialroot@raspberrypi:~# apt-get install python-serial one-character content "return" echo program Add "return" baud rate: 9600root@raspberrypi:~# vim python_serial.py#-*-coding: utf-8-* import serial import time # Open serial port ser = serial.Serial ("/ dev/ttyAMA0" 9600) def main (): while True: # get the receive buffer character count = ser.inWaiting () if count! = 0: # read and echo recv = ser.read (count) + ".... return\ n\ n" ser.write (recv) # clear the receive buffer Ser.flushInput () # necessary software delay time.sleep (0.1) if _ _ name__ ='_ _ main__': try: main () except KeyboardInterrupt: if ser! = None: ser.close () run program: root@raspberrypi:~# python python_serial.py test chart

This is the answer to the question about how raspberry pie uses the uart serial port to communicate with serial devices. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report