Skip to content
Merged
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ A Python weather station for Raspberry Pi using the Pimoroni Weather HAT. Reads
- Pimoroni Weather HAT
- I2C and SPI enabled (`sudo raspi-config`)

> **Low-RAM Pis (Zero/Zero 2 W/3A+):** numpy is built from source during
> install and will OOM on boards with ≤512 MB RAM. Enable swap first:
>
> ```bash
> sudo dphys-swapfile swapoff
> sudo sed -i 's/^CONF_SWAPSIZE=.*/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile
> sudo dphys-swapfile setup
> sudo dphys-swapfile swapon
> ```
>
> A Pi 4 or newer has enough RAM that this is not required.

### Install

```bash
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ setuptools==80.9.0
smbus2==0.5.0
spidev==3.8
st7789==1.0.1
toml==0.10.2
weatherhat==1.0.0
toml==0.10.2
6 changes: 6 additions & 0 deletions scripts/install-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ setup_virtualenv() {
sudo -u "$SERVICE_USER" "$VENV_PATH/bin/pip" install --upgrade pip
sudo -u "$SERVICE_USER" "$VENV_PATH/bin/pip" install -r "$TARGET_PROJECT/requirements.txt"
info "Dependencies installed"

# Install local weatherhat package (contains ha_discovery, i2c_recovery, etc.
# that aren't in the upstream PyPI release)
info "Installing local weatherhat package..."
sudo -u "$SERVICE_USER" "$VENV_PATH/bin/pip" install --no-deps "$TARGET_PROJECT"
info "weatherhat package installed"
}

# Check and setup environment file
Expand Down
6 changes: 4 additions & 2 deletions weatherhat-display.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Documentation=https://github.com/pimoroni/weather-station
After=weatherhat.service
# Optional: start after main weather service

# Restart rate-limit: stop retrying after 3 failures in 5 minutes.
StartLimitBurst=3
StartLimitIntervalSec=300

[Service]
Type=simple
User=weather
Expand All @@ -27,8 +31,6 @@ ExecStart=/home/weather/.virtualenvs/pimoroni/bin/python /home/weather/weather-s
# Restart on failure
Restart=on-failure
RestartSec=10
StartLimitBurst=3
StartLimitIntervalSec=300

# Resource limits - display uses minimal resources when sleeping
MemoryMax=128M
Expand Down
10 changes: 5 additions & 5 deletions weatherhat.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Wants=network-online.target time-sync.target
# Optional: if using lgpiod daemon
# After=lgpiod.service

# Restart rate-limit: 10 restarts per hour prevents permanent death
# while still absorbing transient I2C/hardware glitches.
StartLimitBurst=10
StartLimitIntervalSec=3600

[Service]
Type=simple
User=weather
Expand All @@ -30,14 +35,9 @@ ExecStartPre=/bin/sleep 15
ExecStart=/home/weather/.virtualenvs/pimoroni/bin/python /home/weather/weather-station/bin/mqtt-publisher.py

# Restart configuration - robust for remote deployment
# Generous limits: transient I2C/hardware glitches can cause several
# rapid restarts. 10 restarts per hour prevents permanent death while
# still catching genuine boot loops.
Restart=on-failure
RestartSec=60
TimeoutStopSec=15
StartLimitBurst=10
StartLimitIntervalSec=3600

# Resource limits - improved version uses less CPU
MemoryMax=128M
Expand Down
Loading