summaryrefslogtreecommitdiff
path: root/README.md
blob: e088361f8540b6008e20b33c8eaf548987deb420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# xwing-sensor

Reads temperature and humidity from an SI7021 sensor over I2C and displays the readings on a Waveshare 2.13 inch e-Paper HAT, running on a Raspberry Pi Zero 2 W.

## Hardware

- Raspberry Pi Zero 2 W
- SI7021 temperature/humidity sensor (I2C, address `0x40`, bus 1)
- Waveshare 2.13 inch e-Paper HAT (250×122 px, SPI)

Waveshare HAT documentation and wiring guide:
https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT_Manual#Overview

## System dependencies

Before running `uv sync`, install the required system libraries.

**Pillow build dependencies:**

```bash
sudo apt-get update && sudo apt-get install -y \
    build-essential \
    python3-dev \
    libjpeg62-turbo-dev \
    zlib1g-dev \
    libfreetype-dev \
    libopenjp2-7-dev
```

**lg GPIO library:**

The `lgpio` Python package requires the `lg` C library. Follow the install instructions at https://github.com/joan2937/lg, which requires `swig`:

```bash
sudo apt-get install -y swig
```

Then build and install `lg` per the instructions in that repository.

## Waveshare EPD library

The `waveshare_epd` library is **not bundled** in this repo. Download it from Waveshare's GitHub:

```bash
git clone https://github.com/waveshare/e-Paper
```

The `lib/` directory (`e-Paper/RaspberryPi_JetsonNano/python/lib`) must be on `PYTHONPATH` at runtime. When running as a systemd service this is handled via the `Environment=` line in the unit file (see below). For manual runs:

```bash
PYTHONPATH=/home/pi/e-Paper/RaspberryPi_JetsonNano/python/lib uv run xwing-sensor
```

The import in `main.py` uses `epd2in13_V4` — adjust to match your HAT version if needed.

## Setup

```bash
uv sync
```

## Running as a systemd service

Copy the unit file to systemd and enable it:

```bash
sudo cp xwing-sensor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable xwing-sensor
sudo systemctl start xwing-sensor
```

Check status or logs:

```bash
sudo systemctl status xwing-sensor
journalctl -u xwing-sensor -f
```

Before enabling, verify the paths in `xwing-sensor.service` match your environment:

| Field | Default value | What to check |
|---|---|---|
| `User` | `pi` | The user that owns the project directory |
| `WorkingDirectory` | `/home/pi/xwing_sensor` | Absolute path to this repo on the Pi |
| `PYTHONPATH` | `/home/pi/e-Paper/…/lib` | Where you cloned the Waveshare repo |
| `ExecStart` | `/home/pi/xwing_sensor/.venv/bin/xwing-sensor` | Created by `uv sync` |