Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #31

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 51 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,74 @@
[![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
Weather HAT is a tidy all-in-one solution for hooking up climate and environmental sensors to a Raspberry Pi. It has a bright 1.54" LCD screen and four buttons for inputs. The onboard sensors can measure temperature, humidity, pressure and light. The RJ11 connectors will let you easily attach wind and rain sensors. It will work with any Raspberry Pi with a 40 pin header.

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

You must enable:
* [Weather HAT](https://shop.pimoroni.com/products/weather-hat-only)
* [Weather HAT + Weather Sensors Kit](https://shop.pimoroni.com/products/weather-hat)

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

You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces.
We'd recommend using this library with Raspberry Pi OS Bookworm or later. It requires Python ≥3.6.

# Installing
## Full install (recommended):

We've created an easy installation script that will install all pre-requisites and get your Weather HAT
up and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal
on your Raspberry Pi desktop, as illustrated below:

![Finding the terminal](http://get.pimoroni.com/resources/github-repo-terminal.png)

In the new terminal window type the commands exactly as it appears below (check for typos) and follow the on-screen instructions:

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

**Note** Libraries will be installed in the "pimoroni" virtual environment, you will need to activate it to run examples:

Stable library from PyPi:
```
source ~/.virtualenvs/pimoroni/bin/activate
```

## Development:

If you want to contribute, or like living on the edge of your seat by having the latest code, you can install the development version like so:

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

## Install stable library from PyPi and configure manually

* Set up a virtual environment: `python3 -m venv --system-site-packages $HOME/.virtualenvs/pimoroni`
* Switch to the virtual environment: `source ~/.virtualenvs/pimoroni/bin/activate`
* Install the library: `pip install weatherhat`

* Just run `pip3 install weatherhat`
In some cases you may need to us `sudo` or install pip with: `sudo apt install python3-pip`.

In some cases you may need to use `sudo` or install pip with: `sudo apt install python3-pip`
This will not make any configuration changes, so you may also need to enable:

Latest/development library from GitHub:
* i2c: `sudo raspi-config nonint do_i2c 0`
* spi: `sudo raspi-config nonint do_spi 0`

* `git clone https://github.com/pimoroni/weatherhat-python`
* `cd weatherhat-python`
* `./install.sh --unstable`
You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces.

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

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

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

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

# Using The Library
Expand Down
18 changes: 10 additions & 8 deletions examples/lcd.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#!/usr/bin/env python3

import ST7789
from st7789 import ST7789
from fonts.ttf import ManropeBold as UserFont
from PIL import Image, ImageDraw, ImageFont

print("""
print(
"""
lcd.py - Hello, World! example on the 1.54" LCD.
Press Ctrl+C to exit!
""")
"""
)

SPI_SPEED_MHZ = 80

# Create LCD class instance.
disp = ST7789.ST7789(
disp = ST7789(
rotation=90,
port=0,
cs=1,
dc=9,
backlight=12,
spi_speed_hz=SPI_SPEED_MHZ * 1000 * 1000
spi_speed_hz=SPI_SPEED_MHZ * 1000 * 1000,
)

# Initialize display.
Expand All @@ -29,7 +31,7 @@
HEIGHT = disp.height

# New canvas to draw on.
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
img = Image.new("RGB", (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)

# Text settings.
Expand All @@ -39,7 +41,7 @@
back_colour = (0, 170, 170)

message = "Hello, World!"
size_x, size_y = draw.textsize(message, font)
_, _, size_x, size_y = draw.textbbox((0, 0), message, font)

# Calculate text position
x = (WIDTH - size_x) / 2
Expand All @@ -57,4 +59,4 @@

# Turn off backlight on control-c
except KeyboardInterrupt:
disp.set_backlight(0)
disp.set_backlight(0)
Loading