weatherhat


Nameweatherhat JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryLibrary for the Pimoroni Weather HAT
upload_time2023-07-18 17:18:46
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License Copyright (c) 2018 Pimoroni Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pi raspberry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Weather HAT Python Library & Examples

[![Build Status](https://img.shields.io/github/actions/workflow/status/pimoroni/weatherhat-python/test.yml?branch=main)](https://github.com/pimoroni/weatherhat-python/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/weatherhat-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/weatherhat-python?branch=master)
[![PyPi Package](https://img.shields.io/pypi/v/weatherhat.svg)](https://pypi.python.org/pypi/weatherhat)
[![Python Versions](https://img.shields.io/pypi/pyversions/weatherhat.svg)](https://pypi.python.org/pypi/weatherhat)

# Pre-requisites

This library requires Python ≥3.6 so we'd recommend using it with Raspberry Pi OS Buster or later.

You must enable:

* i2c: `sudo raspi-config nonint do_i2c 0`
* spi: `sudo raspi-config nonint do_spi 0`

You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces.

# Installing

Stable library from PyPi:

* Just run `pip3 install weatherhat`

In some cases you may need to use `sudo` or install pip with: `sudo apt install python3-pip`

Latest/development library from GitHub:

* `git clone https://github.com/pimoroni/weatherhat-python`
* `cd weatherhat-python`
* `./install.sh --unstable`

Some of the examples use additional libraries. You can install them with:

```bash
pip3 install fonts font-manrope pyyaml adafruit-io numpy
```

You may also need to install `libatlas-base-dev`

```
sudo apt-get install libatlas-base-dev
```

# Using The Library

Import the `weatherhat` module and create an instance of the `WeatherHAT` class.

```python
import weatherhat

sensor = weatherhat.WeatherHAT()
```

Weather HAT updates the sensors when you call `update(interval=5)`.

Temperature, pressure, humidity, light and wind direction are updated continuously.

Rain and Wind measurements are measured over an `interval` period. Weather HAT will count ticks of the rain gauge and (half) rotations of the anemometer, calculate rain/wind every `interval` seconds and reset the counts for the next pass.

For example the following code will update rain/wind speed every 5 seconds, and all other readings will be updated on demand:

```python
import time
import weatherhat

sensor = weatherhat.WeatherHAT()

while True:
    sensor.update(interval=5.0)
    time.sleep(1.0)
```

# Averaging Readings

The Weather HAT library supplies set of "history" classes intended to save readings over a period of time and provide access to things like minimum, maximum and average values with unit conversions.

For example `WindSpeedHistory` allows you to store wind readings and retrieve them in mp/h or km/h, in addition to determining the "gust" (maximum wind speed) in a given period of time:

```python
import time
import weatherhat
from weatherhat.history import WindSpeedHistory

sensor = weatherhat.WeatherHAT()
wind_speed_history = WindSpeedHistory()

while True:
    sensor.update(interval=5.0)
    if sensor.updated_wind_rain:
        wind_speed_history.append(sensor.wind_speed)
        print(f"Average wind speed: {wind_speed_history.average_mph()}mph")
        print(f"Wind gust: {wind_speed_history.gust_mph()}mph")
    time.sleep(1.0)
```

# Quick Reference

## Temperature

Temperature readings are given as degrees celsius and are measured from the Weather HAT's onboard BME280.

### Device Temperature

```python
sensor.device_temperature
```

Device temperature in degrees celsius.

This is the temperature read directly from the BME280 onboard Weather HAT. It's not compensated and tends to read slightly higher than ambient due to heat from the Pi.

### Compensated (Air) Temperature

```python
sensor.temperature
```

Temperature in degrees celsius.

This is the temperature once an offset has been applied. This offset is fixed, and taken from `sensor.temperature_offset`.

## Pressure

```python
sensor.pressure
```

Pressure in hectopascals.

## Humidity

```python
sensor.humidity
```

Humidity in %.

### Relative Humidity

```python
sensor.relative_humidity
```

Relative humidity in %.

Relative humidity is the water content of the air compensated for temperature, since warmer air can hold more water.

It's expressed as a percentage from 0 (no moisture) to 100 (fully saturated).

### Dew Point

```python
sensor.dewpoint
```

Dew point in degrees celsius.

Dew point is the temperature at which water - at the current humidity - will condense out of the air.

## Light / Lux

```python
sensor.lux
```

Light is given in lux.

Lux ranges from 0 (complete darkness) to 64,000 (full brightness).

## Wind

Both wind and rain are updated on an interval, rather than on-demand.

To see if an `update()` call has resulted in new wind/rain measurements, check:

```python
sensor.updated_wind_rain
```

### Wind Direction

```python
sensor.wind_direction
```

Wind direction in degrees.

Wind direction is measured using a potentiometer and uses an analog reading internally. This is converted to degrees for convenience, and will snap to the nearest 45-degree increment with 0 degrees indicating North.

### Wind Speed

```python
sensor.wind_speed
```

Wind speed in meters per second.

Weather HAT counts every half rotation and converts this to cm/s using the anemometer circumference and factor.

It's updated depending on the update interval requested.

## Rain

```python
sensor.rain
```

Rain amount in millimeters per second.

Weather HAT counts every "tick" of the rain gauge (roughly .28mm) over the given update internal and converts this into mm/sec.

### Total Rain

```python
sensor.rain_total
```

Total rain amount in millimeters for the current update period.

0.0.2
-----

* Values will now always be float
* Fixed backlight pin
* Fixed latest/average mph

0.0.1
-----

* Initial Release

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "weatherhat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Philip Howard <phil@pimoroni.com>",
    "keywords": "Pi,Raspberry",
    "author": "",
    "author_email": "Philip Howard <phil@pimoroni.com>",
    "download_url": "https://files.pythonhosted.org/packages/17/69/b91d9e08c34519313b803555a7b707321497b381af9819f8ec29d76192b8/weatherhat-0.0.2.tar.gz",
    "platform": null,
    "description": "# Weather HAT Python Library & Examples\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/pimoroni/weatherhat-python/test.yml?branch=main)](https://github.com/pimoroni/weatherhat-python/actions/workflows/test.yml)\n[![Coverage Status](https://coveralls.io/repos/github/pimoroni/weatherhat-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/weatherhat-python?branch=master)\n[![PyPi Package](https://img.shields.io/pypi/v/weatherhat.svg)](https://pypi.python.org/pypi/weatherhat)\n[![Python Versions](https://img.shields.io/pypi/pyversions/weatherhat.svg)](https://pypi.python.org/pypi/weatherhat)\n\n# Pre-requisites\n\nThis library requires Python \u22653.6 so we'd recommend using it with Raspberry Pi OS Buster or later.\n\nYou must enable:\n\n* i2c: `sudo raspi-config nonint do_i2c 0`\n* spi: `sudo raspi-config nonint do_spi 0`\n\nYou can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces.\n\n# Installing\n\nStable library from PyPi:\n\n* Just run `pip3 install weatherhat`\n\nIn some cases you may need to use `sudo` or install pip with: `sudo apt install python3-pip`\n\nLatest/development library from GitHub:\n\n* `git clone https://github.com/pimoroni/weatherhat-python`\n* `cd weatherhat-python`\n* `./install.sh --unstable`\n\nSome of the examples use additional libraries. You can install them with:\n\n```bash\npip3 install fonts font-manrope pyyaml adafruit-io numpy\n```\n\nYou may also need to install `libatlas-base-dev`\n\n```\nsudo apt-get install libatlas-base-dev\n```\n\n# Using The Library\n\nImport the `weatherhat` module and create an instance of the `WeatherHAT` class.\n\n```python\nimport weatherhat\n\nsensor = weatherhat.WeatherHAT()\n```\n\nWeather HAT updates the sensors when you call `update(interval=5)`.\n\nTemperature, pressure, humidity, light and wind direction are updated continuously.\n\nRain and Wind measurements are measured over an `interval` period. Weather HAT will count ticks of the rain gauge and (half) rotations of the anemometer, calculate rain/wind every `interval` seconds and reset the counts for the next pass.\n\nFor example the following code will update rain/wind speed every 5 seconds, and all other readings will be updated on demand:\n\n```python\nimport time\nimport weatherhat\n\nsensor = weatherhat.WeatherHAT()\n\nwhile True:\n    sensor.update(interval=5.0)\n    time.sleep(1.0)\n```\n\n# Averaging Readings\n\nThe Weather HAT library supplies set of \"history\" classes intended to save readings over a period of time and provide access to things like minimum, maximum and average values with unit conversions.\n\nFor example `WindSpeedHistory` allows you to store wind readings and retrieve them in mp/h or km/h, in addition to determining the \"gust\" (maximum wind speed) in a given period of time:\n\n```python\nimport time\nimport weatherhat\nfrom weatherhat.history import WindSpeedHistory\n\nsensor = weatherhat.WeatherHAT()\nwind_speed_history = WindSpeedHistory()\n\nwhile True:\n    sensor.update(interval=5.0)\n    if sensor.updated_wind_rain:\n        wind_speed_history.append(sensor.wind_speed)\n        print(f\"Average wind speed: {wind_speed_history.average_mph()}mph\")\n        print(f\"Wind gust: {wind_speed_history.gust_mph()}mph\")\n    time.sleep(1.0)\n```\n\n# Quick Reference\n\n## Temperature\n\nTemperature readings are given as degrees celsius and are measured from the Weather HAT's onboard BME280.\n\n### Device Temperature\n\n```python\nsensor.device_temperature\n```\n\nDevice temperature in degrees celsius.\n\nThis is the temperature read directly from the BME280 onboard Weather HAT. It's not compensated and tends to read slightly higher than ambient due to heat from the Pi.\n\n### Compensated (Air) Temperature\n\n```python\nsensor.temperature\n```\n\nTemperature in degrees celsius.\n\nThis is the temperature once an offset has been applied. This offset is fixed, and taken from `sensor.temperature_offset`.\n\n## Pressure\n\n```python\nsensor.pressure\n```\n\nPressure in hectopascals.\n\n## Humidity\n\n```python\nsensor.humidity\n```\n\nHumidity in %.\n\n### Relative Humidity\n\n```python\nsensor.relative_humidity\n```\n\nRelative humidity in %.\n\nRelative humidity is the water content of the air compensated for temperature, since warmer air can hold more water.\n\nIt's expressed as a percentage from 0 (no moisture) to 100 (fully saturated).\n\n### Dew Point\n\n```python\nsensor.dewpoint\n```\n\nDew point in degrees celsius.\n\nDew point is the temperature at which water - at the current humidity - will condense out of the air.\n\n## Light / Lux\n\n```python\nsensor.lux\n```\n\nLight is given in lux.\n\nLux ranges from 0 (complete darkness) to 64,000 (full brightness).\n\n## Wind\n\nBoth wind and rain are updated on an interval, rather than on-demand.\n\nTo see if an `update()` call has resulted in new wind/rain measurements, check:\n\n```python\nsensor.updated_wind_rain\n```\n\n### Wind Direction\n\n```python\nsensor.wind_direction\n```\n\nWind direction in degrees.\n\nWind direction is measured using a potentiometer and uses an analog reading internally. This is converted to degrees for convenience, and will snap to the nearest 45-degree increment with 0 degrees indicating North.\n\n### Wind Speed\n\n```python\nsensor.wind_speed\n```\n\nWind speed in meters per second.\n\nWeather HAT counts every half rotation and converts this to cm/s using the anemometer circumference and factor.\n\nIt's updated depending on the update interval requested.\n\n## Rain\n\n```python\nsensor.rain\n```\n\nRain amount in millimeters per second.\n\nWeather HAT counts every \"tick\" of the rain gauge (roughly .28mm) over the given update internal and converts this into mm/sec.\n\n### Total Rain\n\n```python\nsensor.rain_total\n```\n\nTotal rain amount in millimeters for the current update period.\n\n0.0.2\n-----\n\n* Values will now always be float\n* Fixed backlight pin\n* Fixed latest/average mph\n\n0.0.1\n-----\n\n* Initial Release\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2018 Pimoroni Ltd.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Library for the Pimoroni Weather HAT",
    "version": "0.0.2",
    "project_urls": {
        "GitHub": "https://www.github.com/pimoroni/weatherhat-python",
        "Homepage": "https://www.pimoroni.com"
    },
    "split_keywords": [
        "pi",
        "raspberry"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f93916bc9f7b739a76cd58d49981481662342fbf32072ab84a06354243163f55",
                "md5": "56a03c7980d6e834cf4a5844a58fcede",
                "sha256": "febcf24b1105f0bd314a7c464a7d1e43c90077fbe3e65fa436c74efc380f280f"
            },
            "downloads": -1,
            "filename": "weatherhat-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "56a03c7980d6e834cf4a5844a58fcede",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11392,
            "upload_time": "2023-07-18T17:18:44",
            "upload_time_iso_8601": "2023-07-18T17:18:44.960898Z",
            "url": "https://files.pythonhosted.org/packages/f9/39/16bc9f7b739a76cd58d49981481662342fbf32072ab84a06354243163f55/weatherhat-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1769b91d9e08c34519313b803555a7b707321497b381af9819f8ec29d76192b8",
                "md5": "849fe116afd24a0b411c34405cbe7c21",
                "sha256": "c6031555e6d3286d6deed4be0ff6c1dad32dbe8b258c7e9be470cbc9c608e2ea"
            },
            "downloads": -1,
            "filename": "weatherhat-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "849fe116afd24a0b411c34405cbe7c21",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 27487,
            "upload_time": "2023-07-18T17:18:46",
            "upload_time_iso_8601": "2023-07-18T17:18:46.130007Z",
            "url": "https://files.pythonhosted.org/packages/17/69/b91d9e08c34519313b803555a7b707321497b381af9819f8ec29d76192b8/weatherhat-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-18 17:18:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pimoroni",
    "github_project": "weatherhat-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "weatherhat"
}
        
Elapsed time: 0.09161s