Weatherhat Experments

I adjusted the Weatherhat to reflect imperial settings and match as close as possible my weather stations. My feed is producing too many decimal places to the right. Does anyone know to set it two decimal places?

in python, you can convert floats to string with

t = f"temp: {value:.2f}"

Or you could use the round() function.

I could not your formula work. I sent you the code.

from time import sleep

from Adafruit_IO import Client, Dashboard, Feed, RequestError

import weatherhat

sensor = weatherhat.WeatherHAT()

print(""" - Example showing how to send sensor data from Weather HAT into
Sign up for an account at to obtain a username and key.
Press Ctrl+C to exit!

# Set to your Adafruit IO key.
# Remember, your key is a secret,
# so make sure not to publish it when you publish this code!
ADAFRUIT_IO_KEY = 'redacted'

# Set to your Adafruit IO username.
# (go to to find your username)

# We can compensate for the heat of the Pi and other environmental conditions using a simple offset.
# Change this number to adjust temperature compensation!
OFFSET = -7.5

# Create an instance of the REST client.

# Create new feeds
    aio.create_feed(Feed(name="Relative Humidity"))
    aio.create_feed(Feed(name="Wind Speed"))
    aio.create_feed(Feed(name="Wind Direction"))
    print("Feeds created!")
except RequestError:
    print("Feeds already exist!")

temperature_feed = aio.feeds('temperature')
humidity_feed = aio.feeds('relative-humidity')
pressure_feed = aio.feeds('pressure')
light_feed = aio.feeds('light')
windspeed_feed = aio.feeds('wind-speed')
winddirection_feed = aio.feeds('wind-direction')
rain_feed = aio.feeds('rain')

# Create new dashboard
    dashboard = aio.create_dashboard(Dashboard(name="Weather Dashboard"))
    print("Dashboard created!")
except RequestError:
    print("Dashboard already exists!")

dashboard = aio.dashboards('weather-dashboard')

print("Find your dashboard at: " +

# Read the BME280 and discard the initial nonsense readings
sensor.temperature_offset = OFFSET
temperature = sensor.temperature
humidity = sensor.relative_humidity
pressure = sensor.pressure
print("Discarding the first few BME280 readings...")

# Read all the sensors and start sending data

while True:

    wind_direction_cardinal = sensor.degrees_to_cardinal(sensor.wind_direction)

    temperature = sensor.temperature  
    humidity = sensor.relative_humidity
    pressure = sensor.pressure 
    light = sensor.lux
    windspeed = sensor.wind_speed
    winddirection = wind_direction_cardinal
    rain = sensor.rain

        aio.send_data(temperature_feed.key, temperature
        aio.send_data(humidity_feed.key, humidity)
        aio.send_data(pressure_feed.key, pressure)
        aio.send_data(light_feed.key, light)
        aio.send_data(windspeed_feed.key, windspeed)
        aio.send_data(winddirection_feed.key, winddirection)
        aio.send_data(rain_feed.key, rain)
        print('Data sent to')
    except Exception as e:

    # leave at least 30 seconds between updates for free accounts

In your code there is no place where you used the proposed round() function.

I tried your suggested format and it failed. That is why sent the code to you.

How should I tell what your error is, if I don’t see how you coded it?

This is at least one error you have, but this has nothing to do with the round-function.

Hi Larry - just a heads up that you were sharing your Adafruit ID and key in your message, I’ve redacted those for you.

If you enclose big blocks of code in triple backticks (```) it makes them much easier to read.