Forum rules

wind speed and temperature conversion

It has taken me two whole days to get this to work, pyportal weather station, but I need help to change the code for temperature to fahrenheit.
And, change the wind speed to MPH from m/s

Any help would be grateful.

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm

Re: wind speed and temperature conversion

Here's some unit conversion formulas:

MPH = 2.23694 * m/s
degF = 32 + 1.8 * degC

You can modify the code with those.

Posts: 14475
Joined: Tue Nov 29, 2016 2:45 pm

Re: wind speed and temperature conversion

your on it tonight, however, I don't know squat about python. this is my first project.
can you point out where in the Adafruit code to change these?

Jon

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm

Re: wind speed and temperature conversion

For windspeed, change this:
Code: Select all | TOGGLE FULL SIZE
return map_range(voltage_val, 0.4, 2, 0, 32.4)

to this:
Code: Select all | TOGGLE FULL SIZE
return 2.23694 * map_range(voltage_val, 0.4, 2, 0, 32.4)

For temperature, change this:
Code: Select all | TOGGLE FULL SIZE
io.send_data(temperature_feed['key'], bme280_data[0])

to this:
Code: Select all | TOGGLE FULL SIZE
io.send_data(temperature_feed['key'], 32 + 1.8 * bme280_data[0])

Posts: 14475
Joined: Tue Nov 29, 2016 2:45 pm

Re: wind speed and temperature conversion

I can't thank you enough. I was going over the code and really didn't have a clue where to start. No way would I have come up with you provided.

I Am a retired electrician that wired commercial buildings, churches and restaurants. The microprocessor just fascinates me, not so much my wife.
If Im not mowing the lawn Im working on something. Its winter in Southwest Missouri, no mowing today.

thanks again.

Jon

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm

Re: wind speed and temperature conversion

Ooooops, the wind speed did not convert.
the temperature did.

These changes are only on the IO

return 2.23694 * map_range(voltage_val, 0.4, 2, 0, 32.4)

windspeed weatherstation.windspeed 9.76337

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm

Re: wind speed and temperature conversion

Seems like wind speed should be OK. Temperature conversion was only done at time of being sent to AIO, so won't show up in serial prints. For that, change this line back to:
Code: Select all | TOGGLE FULL SIZE
io.send_data(temperature_feed['key'], bme280_data[0])

and then further down, change this line to:
Code: Select all | TOGGLE FULL SIZE
# Store bme280 data as a list
bme280_data = [32 + 1.8 * bme280.temperature, bme280.humidity,
bme280.pressure, bme280.altitude]

Posts: 14475
Joined: Tue Nov 29, 2016 2:45 pm

Re: wind speed and temperature conversion

The latest temperature code change has made it very HOT

The Wind Speed is still reading m/s not mph

temperature weatherstation.temperature 159.375 2 minutes ago
tvoc weatherstation.tvoc 13 2 minutes ago
uvindex weatherstation.uvindex 0.0 1 minute ago
windspeed weatherstation.windspeed 1.22342 1 minute ago

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm

Re: wind speed and temperature conversion

Make sure to only change code in one place.

Posts: 14475
Joined: Tue Nov 29, 2016 2:45 pm

Re: wind speed and temperature conversion

Im confussed.
The IO shows a high temp without F or C thats ok
my serial monitor is showing temp as 70 F. I changed C to F in the Helper file
my PyPortal showes 70 C

Wind speed change made last night has not changed anything, but I changed the Helper file from m/s to mph (for when it does work)
my PyPortal is showing m/s

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm

Re: wind speed and temperature conversion

My bad. I didn't change the IO data feed.
So now my PyPortal temp is still in C , my serial temp is correct and the IO is correct.

Wind speed still not converted to mph anywhere.

Sparky56

Posts: 31
Joined: Tue Nov 14, 2017 6:38 pm