Created
April 29, 2023 11:06
-
-
Save yoggy/bfb197f69aaf3822e2b7a7476a86a9c0 to your computer and use it in GitHub Desktop.
pyserial samples
This file contains hidden or 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
#!/usr/bin/python | |
import serial | |
import time | |
import datetime | |
s = serial.Serial("COM4", 9600) | |
while True: | |
line = s.readline().decode("utf-8") | |
print(line) |
This file contains hidden or 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
#!/usr/bin/python | |
import serial | |
import time | |
import datetime | |
s = serial.Serial("COM3", 9600) | |
while True: | |
time.sleep(10) | |
dt = datetime.datetime.now() | |
print(dt) | |
s.write(str.encode(dt.isoformat("T") + "\r\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment