From: Steven Baltakatei Sandoval Date: Sat, 2 Oct 2021 03:00:10 +0000 (+0000) Subject: fix(examples/a):Change display scale from kg/kg to g/kg X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/commitdiff_plain/eba03e3f2ea5a98a2e7bae4d229e0117fe619d9a?ds=inline fix(examples/a):Change display scale from kg/kg to g/kg - Note: [g water vapor / g dry air] --- diff --git a/examples/all-in-one-enviro-mini-bk.py b/examples/all-in-one-enviro-mini-bk.py index 8913cef..88c3475 100755 --- a/examples/all-in-one-enviro-mini-bk.py +++ b/examples/all-in-one-enviro-mini-bk.py @@ -99,7 +99,7 @@ def display_text(variable, data, unit): # Displays data and text on the 0.96" LCD def display_text2(variable, data, unit, values): # Scale the values for the variable between 0 and 1 - print('DEBUG:len(values[' + str(variable) + ']):' + str(len(values[variable]))) + #print('DEBUG:len(values[' + str(variable) + ']):' + str(len(values[variable]))) #print('DEBUG:values[' + str(variable) + ']:' + str(values[variable])) vmin = min(values[variable]) vmax = max(values[variable]) @@ -256,7 +256,7 @@ def pollSensors(): # now_temp_tuple (°C) # now_pressure_tuple (hPa) # now_humidity_tuple (%) - # now_humidity_abs_tuple (g water vapor / kg dry air) + # now_humidity_abs_gkg_tuple (g water vapor / kg dry air) # now_illuminance_tuple (lux) # Depends: time, bme280, ltr559, get_cpu_temperature(), rel_to_abs() @@ -264,7 +264,7 @@ def pollSensors(): global now_temp_tuple global now_pressure_tuple global now_humidity_tuple - global now_humidity_abs_tuple + global now_humidity_abs_gkg_tuple global now_illuminance_tuple # Initialize cpu_temps = [] @@ -287,8 +287,9 @@ def pollSensors(): # Calculate absolute humidity reading raw_temp_k = 273.15 + raw_temp; # convert sensor temp from degC to K now_pressure_pa = now_pressure * 100; # convert sensor pressure from hPa to Pa - now_humidity_abs = rel_to_abs(raw_temp_k,now_pressure_pa,now_humidity); # calc abs humidity - now_humidity_abs_tuple = (time.time_ns(), 'g/kg', now_humidity_abs); + now_humidity_abs = rel_to_abs(raw_temp_k, now_pressure_pa, now_humidity); # calc kg/kg abs humidity + now_humidity_abs_gkg = now_humidity_abs * 1000; + now_humidity_abs_gkg_tuple = (time.time_ns(), 'g/kg', now_humidity_abs_gkg); # Get light reading proximity = ltr559.get_proximity() # get proximity reading if proximity < 10: @@ -386,7 +387,7 @@ def updateBuffer(): global now_temp_tuple global now_pressure_tuple global now_humidity_tuple - global now_humidity_abs_tuple + global now_humidity_abs_gkg_tuple global now_illuminance_tuple global varLenBuffer global fixLenBuffer @@ -400,7 +401,7 @@ def updateBuffer(): #print('DEBUG:now_temp_tuple:' + str(now_temp_tuple)) #print('DEBUG:now_pressure_tuple:' + str(now_pressure_tuple)) #print('DEBUG:now_humidity_tuple:' + str(now_humidity_tuple)) - #print('DEBUG:now_humidity_abs_tuple:' + str(now_humidity_abs_tuple)) + #print('DEBUG:now_humidity_abs_gkg_tuple:' + str(now_humidity_abs_gkg_tuple)) #print('DEBUG:now_illuminance_tuple:' + str(now_illuminance_tuple)) # Append new sensor tuples to varying-length buffer @@ -411,7 +412,7 @@ def updateBuffer(): ## Relative Humidity varLenBuffer[variables[2]].append(now_humidity_tuple) ## Absolute Humidity - varLenBuffer[variables[3]].append(now_humidity_abs_tuple) + varLenBuffer[variables[3]].append(now_humidity_abs_gkg_tuple) ## Illuminance varLenBuffer[variables[4]].append(now_illuminance_tuple) #print('DEBUG:varLenBuffer:' + str(varLenBuffer)) @@ -535,7 +536,15 @@ try: now_pressure = bme280.get_pressure() # get hPa from BME280 sensor now_pressure_pa = now_pressure * 100; # convert sensor pressure from hPa to Pa now_humidity = bme280.get_humidity() # get % relative humidity from BME280 sensor - data = rel_to_abs(raw_temp_k,now_pressure_pa,now_humidity); # calc abs humidity + now_humidity_abs = rel_to_abs(raw_temp_k,now_pressure_pa,now_humidity); # calc [kg water / kg dry air] abs humidity + now_humidity_abs_gkg = now_humidity_abs * 1000; # convert kg/kg to g/kg abs humidity + data = now_humidity_abs_gkg; + # print('DEBUG:raw_temp:' + str(raw_temp)); + # print('DEBUG:raw_temp_k:' + str(raw_temp_k)); + # print('DEBUG:now_pressure:' + str(now_pressure)); + # print('DEBUG:now_pressure_pa:' + str(now_pressure_pa)); + # print('DEBUG:now_humidity:' + str(now_humidity)); + # print('DEBUG:now_humidity_abs_gkg:' + str(data)); display_text2(variables[mode],data,unit,fixLenBuffer) if mode == 4: