Skip to main content

Pi Dawn

Project description

Use a Raspberry Pi connected to WS2801-based RGB LED strip to wake you up in the morning.

Setup

Hardware

Software

These instructions install Pi Dawn for the default Raspbian user pi. Run all command as this user.

  1. Download Raspbian, flash it to a SD card and configure the system to your liking (network configuration, SSH access, locale etc.)

  2. Setup Raspbian for Pi Dawn

    Run:

    sudo raspi-config

    Then select Localisation OptionsChange Timezone. Pick the timezone you are living in from the list.

    Then select Interfacing OptionsP4 SPI. Answer Yes to enable the SPI interface.

  3. Allow the user pi to access the SPI interface:

    sudo gpasswd -a pi spi

    In order to become effective, you have to log in again.

  4. Install required Raspbian packages:

    sudo apt -y install python3 python3-venv redis-server nginx

    This installs Python 3 with the venv module, Redis and Nginx.

  5. Create an virtual Python environment for Pi Dawn:

    cd ~
    python3 -m venv pi-dawn
  6. Install Pi Dawn:

    ./pi-dawn/bin/pip install pi_dawn
  7. Create the database:

    mkdir pi-dawn/var
    FLASK_APP=pi_dawn ./pi-dawn/bin/flask initdb
  8. Setup services:

    sudo -s
    FLASK_APP=pi_dawn ./pi-dawn/bin/flask setup_nginx
    FLASK_APP=pi_dawn ./pi-dawn/bin/flask install_services
    exit

    The first command will add a new site to act as a proxy for the Flask web application, disable the conflicting default site, validate the NGINX configuration for good measure and reload NGINX to make the changes effective.

    This second command will install Systemd service units for the web frontend and the alarm daemon. After this, it starts the services and configures them for automatic launch at boot.

That’s it. You can access the web interface on port 80 of your Raspberry Pi. Use it to configure alarms or as a light switch.

Development

Prerequisites

Make sure you have the following software packages available on your system:

  • Python (≥ 3.5)

  • Node.js (≥ 10.x)

  • Redis

Get the source code

Clone this repository:

git clone git@github.com:sebasgo/pi-dawn.git

Installation

Execute the following commands inside your working copy of the repository:

  1. Setup a new Python virtual environment:

    python3 -m venv venv
  2. Activate the environment:

    source venv/bin/activate
  3. Install the package with its dependencies:

    pip install -e .[dev]
  4. Create the database:

    FLASK_APP=pi_dawn flask initdb
  5. Install the dependencies for the frontend:

    cd pi_dawn/frontend
    npm install

Running

The application consists of three distinct components which all have to be running at the same time in order to function properly. Also, you need to start a Redis server.

  1. Redis:

    redis-server

    This command can be executed from any working directory.

  2. Backend Flask application:

    FLASK_APP=pi_dawn FLASK_DEBUG=1 flask run

    While developing the Flask application only serves the backend API.

  3. Frontend Vue.js application:

    cd pi_dawn/frontend
    npm run serve

    You can access the web frontend at: http://127.0.0.1:8081/

  4. Execute the daemon:

    DEBUG=1 pi-dawn-daemon

    The daemon controls the LED stripe and makes sure it lights up at the programmed alarms.

    In debug mode, the daemon won’t actually try to program a LED stripe. Instead, it will use Pygame to display the intended result in a window.

Changelog

Version 1.0 (Unreleased)

  • Initial release.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pi-dawn-1.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

pi_dawn-1.0-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file pi-dawn-1.0.tar.gz.

File metadata

  • Download URL: pi-dawn-1.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for pi-dawn-1.0.tar.gz
Algorithm Hash digest
SHA256 d848d8563699573f5dca1bcd297025b2eabedc35a82c11a6da87f24a1d12e282
MD5 acdca1dffa912b8129266d74a718b7b3
BLAKE2b-256 0cc24a300ebf2fec44326e3ce62656717af2843a65e540509d5ad0979299f85b

See more details on using hashes here.

File details

Details for the file pi_dawn-1.0-py3-none-any.whl.

File metadata

  • Download URL: pi_dawn-1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for pi_dawn-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8378f59a80e1796215250869ed1d80b835ab6fbdf4d614bc03040f62fd4193e7
MD5 46b891e888aff579ae4fffd541beb6e7
BLAKE2b-256 b17339a498290a56ba109b90c921e2010ac95964e7b02ace417ff0ce4ce68c1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page