Mar-16-2018, 08:40 AM
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/...g-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.
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/...g-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