RasPi Blinkt IoT widgetry - Ongoing project used with work-experience students
Web-controlled status indicator built on top of the Blinkt HAT and library
== Components
- Status demon - Blinkt wrapper
- Flask app to control getting/setting state
crontab is a background process which allows you to execute scripts at specific times
- Create launcher.sh file in same dir and add the following lines:
#!/bin/sh
# launcher.sh
# navigate to home directory, then to this directory, then execute python script, then back home
cd /
cd home/pi/bbt
sudo python bbt.py
cd /
-
Make it an executable by typing "chmod 755 launcher.sh" in terminal
-
Edit crontab using terminal:
sudo crontab -e
@reboot sh /home/pi/YOURDIRECTORY/launcher.sh
- Please read the license
- This project can be placed in any directory
- This is not the finished product so there will be bugs!
- Run dashboard.py
- Visit localhost:5000 in any browser to edit your status! If they are reported as missing, make sure they are powered up.
- Look at demo.py and basic_func.py to create a new function in demo.py
- Install "avahi-utils":
sudo apt-get install avahi-utils
- Copy
blinkt.service
to/etc/avahi/services
- Download Raspbian
- Put the micro SD card in the USB reader and plug it in to the back of the Ubuntu computer
- Use Etcher to burn Raspbian to the SD card
- BEFORE BOOTING: Copy the ssh and wpa_supplicant.conf (AFTER EDITING IT) files to the /boot drive
- Put the micro SD card into the pi and plug it into power - let it boot up. Give it a couple minutes.
- Put the SD card back in the USB reader and transfer api.py, basic_func.py, status.py and either lightswitch.py or demo.py to /home/pi/yourfolderhere
- Copy blinkt.service to /etc/avahi/services
- Put the SD card into the pi and plug it in
- Open terminal, type ssh pi@raspberrypi and then cd /etc/hostname and then sudo nano hostname and change raspberrypi to something like blinkt4
- Also in terminal, do crontab -e and add these lines:
@reboot python /home/pi/yourfolderhere/api.py
@reboot python /home/pi/yourfolderhere/demo.py (OR lightswitch.py, depending on which one you picked)
api.py talks to dashboard.py and tells it the device's current status, found from status.py. What it does during this status is defined by demo.py (or whatever you decide to call it; there's another called lightswitch.py). You will find multiple 'building block' processes in basic_func.py. blinkt.service announces the device as a blinkt service to avahi.py, which tells dashboard.py the locations of api.py. ssh and wpa_supplicant.conf are to be copied to the boot drive of the SD card before you boot it up for the first time.