-
-
Save dj1711572002/40dcbfadb012233d6e84a64c1c0ec027 to your computer and use it in GitHub Desktop.
Python Training Serail Recieve & CSV Saving
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 datetime | |
import os | |
import serial | |
path = os.getcwd() | |
print(path) | |
print(type(path)) | |
now = datetime.datetime.now() | |
filename =now.strftime('%Y%m%d_%H%M%S') + '.csv' | |
with open(filename, 'w',newline='')as f: | |
writer = csv.writer(f) | |
ser = serial.Serial("COM19", 115200) | |
while True: | |
val_arduino = ser.readline() | |
txt = val_arduino.decode('utf8') | |
str_arduino = txt.strip('\r\n') | |
writer.writerow([str_arduino]) | |
print("str="+str_arduino) | |
print(val_arduino) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment