Skip to content

Instantly share code, notes, and snippets.

@dj1711572002
Created November 3, 2023 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj1711572002/40dcbfadb012233d6e84a64c1c0ec027 to your computer and use it in GitHub Desktop.
Save dj1711572002/40dcbfadb012233d6e84a64c1c0ec027 to your computer and use it in GitHub Desktop.
Python Training Serail Recieve & CSV Saving
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