Use a Raspberry Pi connected to WS2801-based RGB LED strip to wake you up in the morning.
These instructions install Pi Dawn for the default Raspbian user
pi. Run all command as this user.
Download Raspbian, flash it to a SD card and configure the system to your liking (network configuration, SSH access, locale etc.)
Setup Raspbian for Pi Dawn
Then select Localisation Options → Change Timezone. Pick the timezone you are living in from the list.
Then select Interfacing Options → P4 SPI. Answer Yes to enable the SPI interface.
Allow the user
pito access the SPI interface:
sudo gpasswd -a pi spi
In order to become effective, you have to log in again.
Install required Raspbian packages:
sudo apt -y install python3 python3-venv redis-server nginx
This installs Python 3 with the
venvmodule, Redis and Nginx.
Create an virtual Python environment for Pi Dawn:
cd ~ python3 -m venv pi-dawn
Install Pi Dawn:
./pi-dawn/bin/pip install pi_dawn
Create the database:
mkdir pi-dawn/var FLASK_APP=pi_dawn ./pi-dawn/bin/flask initdb
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.
Make sure you have the following software packages available on your system:
- Python (≥ 3.5)
- Node.js (≥ 10.x)
Get the source code
Clone this repository:
git clone firstname.lastname@example.org:sebasgo/pi-dawn.git
Execute the following commands inside your working copy of the repository:
Setup a new Python virtual environment:
python3 -m venv venv
Activate the environment:
Install the package with its dependencies:
pip install -e .[dev]
Create the database:
FLASK_APP=pi_dawn flask initdb
Install the dependencies for the frontend:
cd pi_dawn/frontend npm install
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.
This command can be executed from any working directory.
Backend Flask application:
FLASK_APP=pi_dawn FLASK_DEBUG=1 flask run
While developing the Flask application only serves the backend API.
Frontend Vue.js application:
cd pi_dawn/frontend npm run serve
You can access the web frontend at: http://127.0.0.1:8081/
Execute the 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.