Build a digital clock

From The World according to Vissie
Jump to navigation Jump to search

Setup instructions

Ok, and now that I have my clock up and running, here is my notes. This was done on OSMC


Install these files:

sudo apt-get update
sudo apt-get install python-smbus i2c-tools cron
sudo apt-get install git

If not allready, add this line to the end :

vim: /boot/config.txt
dtparam=i2c_arm=on
vim: /etc/modules
i2c-bcm2708
i2c-dev

Depending on your distribution, you may also have a file called /etc/modprobe.d/raspi-blacklist.conf. Make sure the above 2 files in not blacklisted.

Reboot now

Your Pi has to see the device. Check this by:

ls -l /dev/i2c-1
sudo i2cdetect -y 1
git clone my py_clocks files
sudo crontab -e
@reboot sh /home/pi/bbt/launcher.sh &


All the rest is old

Have a look at this site. Very good:

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git [The old location]

Then the code:

apt-get install git
git clone https://github.com/adafruit/Adafruit_Python_LED_Backpack.git

Then hopefully all works (as root or sudo):

cd Adafruit-Raspberry-Pi-Python-Code/Adafruit_LEDBackpack/
python ex_7segment_clock.py

Seems things have changed a bit.

New location of the code

Also install:

sudo apt-get update
sudo apt-get install build-essential python-dev
sudo apt-get install python-smbus python-imaging


git clone https://github.com/adafruit/Adafruit_Python_LED_Backpack.git

Then run:

sudo python setup.py install


To get the script to run at startup:

sudo apt-get install cron
#!/bin/bash                                                                                                                         
# navigate to home directory, then to this directory, then execute python script, then back home
cd /home/vissie/adafruit
sudo python ex_7segment_clock.py
cd /
sudo crontab -e
@reboot sh /home/pi/bbt/launcher.sh &

Some notes and places to go read

What I need:

https://chicagodist.com/collections/adafruit-products/products/adafruit-0-56-4-digit-7-segment-display-w-i2c-backpack-red 
https://chicagodist.com/products/adafruit-0-56-4-digit-7-segment-display-w-i2c-backpack-green 
https://chicagodist.com/products/adafruit-0-56-4-digit-7-segment-display-w-i2c-backpack-blue 

I'll go for the green one. Girlfriend friendly....

And then the how:

https://chicagodist.com/blogs/news/8464281-back-to-basics-building-a-7-segment-display-clock-for-a-raspberry-pi 

And another howto, maybe I'll get some tips there...

https://learn.adafruit.com/large-pi-based-thermometer-and-clock/software

I might as well, while at it get: https://chicagodist.com/products/adafruit-4-x-aa-battery-holder-with-on-off-switch