Skip to content
The Raspberry PI IOT for reading messages off of a queue
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fonts
images
iot
.gitignore
README.md
config-example.yaml
ledmetric.py
ledtext.py
ledticker.conf
ledticker.py
ledticker.service
ledweather.py
requirements.txt
runicon.py
runtext.py
samplebase.py
utils.py

README.md

ledticker-pi

allows a raspberry pi to drive an LED display as an IOT divide in AWS. The idea is to make a IOT thing that is basically just a slave to the messages sent to a queue. This allows the device to be dumb and multiple suppliers to be as sophisticated as needed.

research and background

These are the guides that accelerated building this project extensively.

install for python 3

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

installing flashlex-pi-python

This is a flashlex project. That is it uses the flashlex cloud IOT framework to send messages to the Raspberry Pi. You can get more info on flashlex at flashlex.com

git clone https://github.com/claytantor/flashlex-iot-python.git
cd flashlex-iot-python
sudo python setup.py install

running on cli

sudo /home/pi/projects/ledticker-pi/venv/bin/python -u /home/pi/projects/ledticker-pi/flashlex.py --led-no-hardware-pulse true -m adafruit-hat -r 32 --led-cols 32 --log DEBUG --config /home/pi/projects/ledticker-pi/config.yml 

creating the systemd service

Instructions for setting up your service can be found at https://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/

sudo cp ledticker.service /lib/systemd/system/ledticker.service
sudo chmod 644 /lib/systemd/system/ledticker.service
sudo systemctl daemon-reload
sudo systemctl enable ledticker.service

add logging to syslog

Then, assuming your distribution is using rsyslog to manage syslogs, create a file in /etc/rsyslog.d/<new_file>.conf with the following content:

if $programname == '<your program identifier>' then /path/to/log/file.log
& stop

restart rsyslog (sudo systemctl restart rsyslog) and enjoy! Your program stdout/stderr will still be available through journalctl (sudo journalctl -u <your program identifier>) but they will also be available in your file of choice.

We have included a conf file that makes this easier. Use the instructions below to enable rsyslog for ledticker.

sudo cp ledticker.conf /etc/rsyslog.d/ledticker.conf
sudo systemctl daemon-reload
sudo systemctl restart ledticker.service
sudo systemctl restart rsyslog

check the status of the service

sudo systemctl status ledticker.service

rotating logs

you will want to rotate logs so your disk doesnt fill up with logs. your conf file for logrotation looks like this in /etc/logrotate.conf:

/var/log/ledticker.log {
    daily
    missingok
    rotate 7
    maxage 7
    dateext
    dateyesterday
}

make a crontab that executes logrotate daily

/usr/sbin/logrotate /etc/logrotate.conf
You can’t perform that action at this time.