Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Sense HAT CLI + Webserver

Quick Wiring (Raspberry Pi)

Before running the script, connect these pins from the Sense HAT to the Raspberry Pi:

  • 3.3V
  • GND
  • I2C SCL
  • I2C SDA

Those four connections are enough to use this script.

If connected correctly, the LED matrix will light up. You can later switch the matrix off using this script.

LED matrix support is experimental and there may be bugs. Pull requests are welcome.

Photos

Wiring

Sense HAT

Raspberry Pi

Features

  • Reads sensor data from:
    • LPS25 (pressure_hpa, temperature_c)
    • LSM9DS1 (acceleration_m_s2, magnetic_gauss, gyro_rad_s, temperature_c)
    • HTS221 (relative_humidity_percent, temperature_c)
  • LED color by name, hex, or RGB triplet
  • Human-formatted output with grouped labels
  • Built-in web UI and JSON endpoint

Requirements

  • Python 3.10+
  • Sense HAT connected over I2C
  • Python packages:
    • adafruit-blinka
    • adafruit-circuitpython-lps2x
    • adafruit-circuitpython-lsm9ds1
    • adafruit-circuitpython-hts221
    • adafruit-bus-device

Install in a virtual environment:

python -m venv .venv
source .venv/bin/activate

pip install --upgrade pip
pip install adafruit-blinka adafruit-circuitpython-lps2x adafruit-circuitpython-lsm9ds1 adafruit-circuitpython-hts221 adafruit-bus-device

Usage

Run script:

python sensehat.py [options]

Sensor options

  • -all return all sensor data
  • -temp return temperature data
  • -pressure return pressure data
  • -accel return accelerometer data
  • -gyro return gyroscope data
  • -mag return magnetometer data
  • -humidity return humidity data
  • -human return human-readable output

LED options

  • -led-off clear the LED matrix
  • -led-on enable LED matrix (uses -led-color or white default)
  • -led-color COLOR set color:
    • named color (example: lime, amber, blue)
    • hex (example: #00ff00)
    • RGB triplet (example: 0 255 0)
  • -led-rainbow paint rainbow rows

Webserver options

  • -webserver start web mode
  • -web-host bind host (default 0.0.0.0)
  • -web-port bind port (default 8000)

Start webserver:

python sensehat.py -webserver -web-host 0.0.0.0 -web-port 8000

Endpoints:

  • / HTML dashboard
  • /json JSON payload
  • /human plain-text human format
  • /health health check (ok)

About

Sense HAT utility for reading sensors, controlling the LED matrix, and serving live data through a lightweight webserver

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages