add 3.3 - data
This commit is contained in:
parent
42eb3d679c
commit
40a78b81f7
|
@ -46,6 +46,9 @@ def read():
|
|||
while True:
|
||||
dat_list = np.random.randint(0, v_in * 1000, SENSORS_MAX) # create a randomized voltage data
|
||||
# take only the nonzero indices, and truncated to two decimal places to "filter" out some hardware errors
|
||||
# According to the actual req, the data in the data list should be (3.3-data)
|
||||
for x in range(dat_list.size):
|
||||
np.put(dat_list, x, 3.3 - dat_list[x])
|
||||
dat_sel = np.trunc((np.take(dat_list, sensor_ports) / 1000) * 10**2) / 10**2
|
||||
r_arr = np.take(refRes, sensor_ports) * (v_in / dat_sel - 1) # *2 <-- change with actual formula for ammonia concentration
|
||||
# created a new array to convert resistance values to sci notation
|
||||
|
@ -84,6 +87,9 @@ def read():
|
|||
read_data = controller.readline().decode("utf-8")
|
||||
# use numpy so it can make list calculations easier (and possibly faster)
|
||||
dat_list = np.asarray(json.loads(read_data), dtype=np.float32)[:SENSORS_MAX]
|
||||
# According to the actual req, the data in the data list should be (3.3-data)
|
||||
for x in range(dat_list.size):
|
||||
np.put(dat_list, x, 3.3 - dat_list[x])
|
||||
dat_sel = np.take(dat_list, sensor_ports)
|
||||
# if we decided to switch back to analogRead(), replace this line of comment to the algorithm to something like the commented line below
|
||||
# dat_sel = np.take(dat_list, sensor_ports) * v_in / resolution
|
||||
|
|
Loading…
Reference in New Issue