miklat-alert

March 19, 2026 ยท View on GitHub

Visual alert indicator for the Israeli Home Front Command (Pikud HaOref) Red Alert system, built for Raspberry Pi Zero with a WS2812B (NeoPixel) LED strip.

The script polls the official alert API and drives a NeoPixel strip to show the current status at a glance:

ColorMeaning
๐Ÿ”ต BlueSystem starting up / self-test
๐Ÿ”ด RedActive alert (rocket / hostile aircraft)
๐ŸŸ  OrangePre-alert ("in the coming minutes")
๐ŸŸข GreenAlert released โ€“ turns off automatically after 5 minutes
โšซ OffIdle / no active alert

Hardware Requirements

  • Raspberry Pi Zero (W / WH / 2 W)
  • WS2812B (NeoPixel) LED strip โ€“ 15 LEDs (configurable in code)
  • 330 ฮฉ resistor (placed on the data line)
  • 5 V power supply adequate for the strip (each LED draws โ‰ˆ 60 mA at full white)
  • Jumper wires

Wiring Diagram

              Raspberry Pi Zero
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚                  โ”‚
             โ”‚  GPIO 18 (PWM)   โ”‚โ”€โ”€ 330 ฮฉ โ”€โ”€โ”
             โ”‚                  โ”‚            โ”‚
             โ”‚  GND             โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚     โ”‚
                                       โ”‚     โ”‚
              WS2812B LED Strip        โ”‚     โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚     โ”‚
             โ”‚  DIN  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚  GND  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚  +5V  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€ 5 V Power Supply (+)
             โ”‚                  โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 GND of Pi and Power Supply
                                 must be connected together

Note: The 330 ฮฉ resistor is placed between GPIO 18 and the strip DIN (data-in) pin to protect the data line from voltage spikes.
If your strip has more than ~30 LEDs, power it from an external 5 V supply and connect the ground to the Pi's GND.


Software Installation

1. Prepare the Pi Zero

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y python3 python3-pip git

2. Clone the repository

sudo git clone https://github.com/t0mer/miklat-alert.git /opt/redalert
cd /opt/redalert

3. Install Python dependencies

sudo pip3 install -r requirements.txt

This installs:

  • rpi_ws281x โ€“ low-level WS281x LED driver
  • adafruit-circuitpython-neopixel โ€“ NeoPixel high-level library
  • adafruit-blinka โ€“ CircuitPython compatibility layer for Raspberry Pi
  • loguru โ€“ structured logging

4. Enable SPI (if needed) and set GPU memory

Some WS281x configurations require SPI or a minimum GPU memory split:

sudo raspi-config
# Interface Options โ†’ SPI โ†’ Enable
# Performance Options โ†’ GPU Memory โ†’ set to at least 16

Reboot after changes:

sudo reboot

Configuration

The script reads configuration from environment variables:

VariableDefaultDescription
TARGET_LOCATION(empty โ€“ all locations)Hebrew city/area name to filter alerts for (e.g. ืจืขื ื ื”)
MAX_IDS1000Number of alert IDs to keep before clearing the seen list

Set them in the systemd service file or export before running:

export TARGET_LOCATION="ืจืขื ื ื”"

LED Strip Parameters (in code)

ConstantDefaultDescription
LED_COUNT15Number of LEDs on the strip
LED_PIN18GPIO pin (must support PWM โ€“ GPIO 18 recommended)
LED_BRIGHTNESS65Brightness 0-255
LED_DMA10DMA channel

Running

Manual test

sudo python3 /opt/redalert/redalert.py

sudo is required because the WS281x library needs root access to the GPIO/PWM hardware.

Install as a systemd service

Copy the provided service file and enable it:

sudo cp /opt/redalert/redalert.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable redalert.service
sudo systemctl start redalert.service

Check status:

sudo systemctl status redalert.service

View logs:

sudo journalctl -u redalert.service -f

Service File Reference

The included redalert.service runs the script as root, restarts on failure, and waits for network connectivity:

[Unit]
Description=Red Alert
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service

[Service]
KillSignal=SIGINT
WorkingDirectory=/opt/redalert
Type=simple
User=root
ExecStart=/usr/bin/python3 /opt/redalert/redalert.py
Restart=always

[Install]
WantedBy=multi-user.target

To filter for a specific location, add an Environment line under [Service]:

Environment="TARGET_LOCATION=ืจืขื ื ื”"

License

See LICENSE for details.