Created
March 6, 2019 00:11
-
-
Save mikbuch/9840a146df896abd66ba9f8811779516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
# Source: https://pyserial.readthedocs.io/en/latest/shortintro.html#opening-serial-ports | |
# Additional info: | |
# * you have to install pyserial in order for this code to work, command `sudo pip install serial` | |
# * run this script with sudo: `sudo python read_serial.py` | |
with serial.Serial('/dev/ttyUSB0', 9600, timeout=1) as ser: | |
while True: | |
# read a '\n' terminated line | |
line = ser.readline() | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment