Getting values from Arduino into python and saving it as csv file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Getting values from Arduino into python and saving it as csv file (/thread-8989.html) |
Getting values from Arduino into python and saving it as csv file - Yamin - Mar-16-2018 Hi totally newbie to python here. I was following this tutorial on how to get data from arduino and saving it as a csv file https://engineersportal.com/blog/2018/2/25/python-datalogger-reading-the-serial-output-from-arduino-to-analyze-data-using-pyserial I would like to know how to log multiple sensor values. I know it should be something to do with data parsing. Here is the code which I use to get the value of just one sensor. import serial import time import csv ser = serial.Serial('COM3') ser.flushInput() while True: try: ser_bytes = ser.readline() decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8")) print(decoded_bytes) with open("test_data.csv","a", newline='') as f: writer = csv.writer(f,delimiter=",") writer.writerow([time.strftime("%H : %M : %S"),decoded_bytes]) except: print("Keyboard Interrupt") break RE: Getting values from Arduino into python and saving it as csv file - woooee - Mar-20-2018 Are you accessing other ports, COM1, etc. If not, how is the data coming into the computer? |