0

wind speed and temperature conversion
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

wind speed and temperature conversion

by Sparky56 on Wed Jan 22, 2020 7:35 pm

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

by adafruit_support_carter on Wed Jan 22, 2020 9:11 pm

Here's some unit conversion formulas:

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

You can modify the code with those.

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

Re: wind speed and temperature conversion

by Sparky56 on Wed Jan 22, 2020 9:48 pm

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

by adafruit_support_carter on Wed Jan 22, 2020 9:54 pm

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])

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

Re: wind speed and temperature conversion

by Sparky56 on Wed Jan 22, 2020 10:17 pm

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

by Sparky56 on Wed Jan 22, 2020 10:45 pm

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

by adafruit_support_carter on Thu Jan 23, 2020 1:07 pm

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]

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

Re: wind speed and temperature conversion

by Sparky56 on Thu Jan 23, 2020 3:12 pm

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

by adafruit_support_carter on Thu Jan 23, 2020 3:17 pm

Make sure to only change code in one place.

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

Re: wind speed and temperature conversion

by Sparky56 on Thu Jan 23, 2020 3:37 pm

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

by Sparky56 on Thu Jan 23, 2020 4:13 pm

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

Please be positive and constructive with your questions and comments.