NUM_OF_SAMPLES = 1000
import serial
s = serial.Serial(port="/dev/ttyACM0")
def read():
data = []
for i in range(NUM_OF_SAMPLES):
line = s.readline().rstrip().decode("ascii")
if line != "":
#line format is e.g. "measured: 4111"
data.append(int(line.split(":")[1]))
return data
data_untouched = read()
data_touched = read()
s.close()
plot(data_untouched) #blue
plot(data_touched) #green
[<matplotlib.lines.Line2D at 0xcc8f5ec>]
We can take a look at the dynamic range by taking the minimum of the untouched samples and the maximum of the touched samples (when it is acutally touched which happens somewhere before the 300th datapoint)
min(data_untouched) - max(data_touched[300:-1])
8
So that's potentially 3-bits of dynamic range. Bearing in mind that that's not pressure but more electrode area covered and that maybe we did'nt cover the elctrode as much as we could