Acquiring Data¶
Procedure¶
- Close the Putty window, to free up the COM port.
- Power off the chipsat
- In the code provided below, change the COM Port to whichever has the USB to UART dongle attached. For me, it was COM5.
- Note: This code will open a serial connection to the USB to UART converter and write 200 measurements from each sensor to the filename that you specified.
- Run the code.
- Power on the chipsat.
- Wait while data is gathered.
- Change the filename, and repeat for the other chipsats.
Code¶
# Import libraries
import numpy
import serial
import matplotlib.pyplot as plt
import os
# Specify port and baud rate
ser = serial.Serial('COM5', 9600)
# Indicate a file name and directory to store data
# Note that this file name should be different for each chipsat
# I recommend using the convention that the file name is the chipsat
# identification number.
filename="./Prior_Data/22.txt"
# Write 200 sensor measurements to the specified file, then close the file
datafile=open(filename, 'a')
count = 0;
while count < 200:
datafile=open(filename, 'a')
data = ser.readline().rstrip()
datafile.write(str(data))
datafile.write('\n')
print(data)
count += 1
datafile.close()
datafile.close()
ser.close()