# 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])
# 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()
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 = []
# 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:
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
#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
## 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))
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: