enviroplus-python icon indicating copy to clipboard operation
enviroplus-python copied to clipboard

celcius to farenheit?

Open Esteidinger opened this issue 6 years ago • 5 comments

Can anyone offer a suggestion on how to change the values to F?

Thanks.

Esteidinger avatar Jul 23 '19 19:07 Esteidinger

(1°C × 9/5) + 32 = 33.8°F

If you want to get Farenheit directly out of the library then it might be worth raising a feature request against the bme280 driver here - https://github.com/pimoroni/bme280-python

Gadgetoid avatar Jul 31 '19 12:07 Gadgetoid

Yes add the code and #comment it out and let users that want F comment it in.

kflmiami420 avatar Aug 18 '19 02:08 kflmiami420

Good point!

While I think I'd prefer something like bme280.get_temperature_fahrenheit() or bme280.get_temperature(unit='fahrenheit') but since - in both instances - that would require the code being there and commented out... might as well stick the maths right into the examples.

Gadgetoid avatar Aug 20 '19 15:08 Gadgetoid

This what I came up with :

you have to add a mode or renumerate all your modes. ( I found out that if you touch the light sensor it changes the display output )

I added a new value

-Create a values dict to store the data variables = ["temperature", "temperature2",

Then I added a new mode called 1 since 0 is the default for Celsius degrees

One mode for each variable if mode == 0: variable = "temperature" unit = "C" cpu_temp = get_cpu_temperature() # Smooth out with some averaging to decrease jitter cpu_temps = cpu_temps[1:] + [cpu_temp] avg_cpu_temp = sum(cpu_temps) / float(len(cpu_temps)) raw_temp = bme280.get_temperature() data = raw_temp - ((avg_cpu_temp - raw_temp) / factor) display_text(variable, data, unit)

if mode == 1: variable = "temperature2" unit = "F" cpu_temp = get_cpu_temperature() # Smooth out with some averaging to decrease jitter cpu_temps = cpu_temps[1:] + [cpu_temp] avg_cpu_temp = sum(cpu_temps) / float(len(cpu_temps)) raw_temp = bme280.get_temperature() data = raw_temp - ((avg_cpu_temp - raw_temp) / factor) data = (data * 1.8) + 32 display_text(variable, data, unit)

I think my math is correct , Maybe someone can double check it .

if it works for me then hopefully someone can incorporate the code in an update

I am still unsure why my factor has top be adjusted so high to get proper temps ( I am at 8.2 factor)

My setup

I have the pi zero w enclosed in a https://www.adafruit.com/product/3252 case with an extra tall https://www.adafruit.com/product/1992 header so how do I remove the compensation code ?

I want raw sensor temps and humidity ?

  • --Sorry but this post removes proper indentation of the code , just follow the indent of other variables and modes in original code

kflmiami420 avatar Aug 20 '19 17:08 kflmiami420

kflmiami420's code works almost- the last line of "display_text(variable, data, unit)" didn't work for me until I changed it to "display_text(variable[mode], data, unit)", then hey presto. Many thanks!

ScottTheHippy avatar Apr 09 '22 07:04 ScottTheHippy