In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you a sample analysis of raspberry pie and arduino serial communication. I hope you will get something after reading this article. Let's discuss it together.
Serial communication between raspberry pie and arduino
Step 1: first set the hardware serial port to assign to the GPIO serial port
Enter the sudo raspi-config command to enter the raspberry pie system configuration interface and select the third Interfacing Options
Go in and choose Serial Port.
Then choose to turn off the serial login function and turn on the hardware serial port debugging function.
Modify the configuration file
Open the / boot/config.txt file, type sudo vim / boot/config.txt, and add two lines at the end: 1, dtoverlay=pi3-miniuart-bt 2, force_turbo=1
Then restart the raspberry pie, ls / dev-al to check the serial port
Serial port 0 corresponds to ttyAMA0 and serial port 1 corresponds to ttyS0, which means that the hardware serial port can communicate with others through GPIO at this time.
Step 2: write a test program
Raspberry pie:
Import serial import time port = "/ dev/ttyAMA0" ser = serial.Serial (port,115200,timeout=1) # / / Open the serial port and connect to ser.flushInput () # / / clear the input buffer while True: # ser.write ("7" .encode () ser.write ("s" .encode ()) Size = ser.inWaiting () # get the buffer character if size! = 0: response = ser.read (size); print (response) time.sleep (3)
Arduino:
Void setup () {Serial.begin (115200); / / define baud rate} void loop () {while (Serial.available () > 0) {char teststring = Serial.read (); Serial.println (teststring); if ('s'= = teststring) Serial.println ("Hello Raspberry,I am Arduino.");}}
Screenshots of test results:
The wiring is, R for raspberry pie to T for Arduino, T for raspberry pie to R for Arduino, and then connect to GND.
There are also programs in C language, so I don't bother to sort them out.
After reading this article, I believe you have a certain understanding of "sample analysis of raspberry pie and arduino serial communication". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.