or communicate through UART interface, it is required to have the following Hardware requirements.
GitHub Link: Getting Start with SP2302 - UART
YouTube Link: Getting Start with SP2302 - UART
1. Hardware connection: We need to connect the GPIO pins for UART2's TXD, RXD and GND pins. Please find the following image for details
2. If you are communicating with your PC, we recommend you to use a USB to TTL converter.
How to configure SP2302's UART in pythonThe UART communication python code is a UART loopback code. For details, please refer the following description or towards to our GitHub site.
For activate the SP2302 UART terminal in python, it is required to have a pyserial library.
pip install pyserial
1. For our demo code, we will open SP2302's serial port that is /dev/ttyMH2 with 9600 baud rate.
By receiving the data from serial terminal, it will directly return the data back to the sender with printing the result of data in SP2302.
2. Run the codes
Use git clone command to download the GitHub repository:
git clone https://github.com/SecurePi/basic_python_SP2302.git
Command to run the code
python3 uart.py
For detail demo, please refer to our YouTube video below.
Comments
Please log in or sign up to comment.