-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial-log.py
29 lines (24 loc) · 851 Bytes
/
serial-log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import serial
import sys
import time
import os
print('************************************************************')
print('* A pthon code written for Air Quality Sensor Calibration *')
print('* It will Read data from USB port and *')
print('* Display on Screen and Same on File as named *')
print('* as Sensor id *')
print('************************************************************')
serial_port = input('ENTER Serial-Port:')
sensor_id = input('Enter Sensor-ID:')
f = open(sensor_id + ".csv", "a+")
ser = serial.Serial()
ser.baudrate = 9600
ser.port = serial_port
ser.open()
while True:
data = ser.readline()
data = data.decode('ascii')
data = data.replace('\r\n', '')
data = str(time.time()) + "," + data
print(data)
f.write(data + "\n")