This was challenging for me to get into Python programming and setting Raspberry Pi to my own needs. I know this is overkill but also this is a path for future projects for example info display which can display time, the temperature in your place, and maybe turn on lights in the living room and the list goes on and on.
Hardware requirements:
Raspberry Pi Waveshare 5inch HDMI LCD MicroSD Card PSU for Raspberry Pi
1. create micro sd card with raspberry pi os lite
Here we need to enter the path and name of the image we want to write to the sd card instead of "/ source_image_file" and instead of "/ destination_disk_drive" we need to enter the path and name of the disk we want to write to.
sudo dd if=/source_image_file of=/destination_disk_drive
2. enable SSH
To be able to access over SSH we need to create an empty file named SSH in the boot partition of our Micro SD card.
sudo touch /media/your_username/boot/SSH
3. setup hostname
sudo nano /media/ebaketa/rootfs/etc/hostname
4. edit the host's file and replace "myhostname" with the desired hostname:
sudo nano /media/your_username/rootfs/etc/hosts 127.0.0.1 localhost ::1 localhost 127.0.1.1 myhostname.localdomain myhostname
5. setup a static IP address
sudo nano /media/your_username/rootfs/etc/dhcpcd.conf # Example static IP configuration: interface eth0 static ip_address=192.168.x.xxx/24 #static ip6_address=fd51:42f8:caae:d92e::ff/64 static routers=192.168.x.x static domain_name_servers=192.168.x.x 8.8.8.8 fd51:42f8:caae:d92e::1
6. edit Raspberry Pi OS configuration file config.txt
These lines below we need to add to "config.txt" to configure 5 inch HDMI LCD. The best is to add lines to the end of the file.
max_usb_current=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 hdmi_drive=1
7. insert micro SD to the target machine, boot OS, and login over SSH
Now we can insert an SD card into Raspberry Pi, connect the power supply and boot into OS.
8. update Raspberry Pi OS
sudo apt update sudo apt upgrade
9. reboot Raspberry Pi OS and login over SSH
10. start raspi-config tool
sudo raspi-config change default password set boot options -> console autologin set language and regional settings set keyboarad layout set time zone
11. reboot Raspberry Pi OS and login over SSH
12. install xorg, xinit, x11-server-utils
sudo apt -y install --no-install-recommends xserver-xorg sudo apt -y install --no-install-recommends xinit sudo apt -y install x11-xserver-utils
13. install openbox, lxterminal, lxtask, lxappearance
sudo apt -y install openbox obconf obmenu lxterminal lxtask lxappearance
14. install PyGObject
sudo apt -y install python-gi python-gi-cairo python3-gi python3-gi-cairo gir1.2-gtk-3.0
15. create .bash_profile file and add a line below
touch ~/.bash_profile && sudo nano ~/.bash_profile if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx; fi
16. create openbox autostart file and add lines below
mkdir ~/.config && mkdir ~/.config/openbox && touch ~/.config/openbox/autostart && sudo nano ~/.config/openbox/autostart # disable screen saver xset s off & xset s -dpms & # run python digital clock python ~/Projects/python/digital_clock/digital_clock.py
17. create directories for projects and get projects via wget
mkdir ~/Projects && mkdir ~/Projects/python && mkdir ~/Projects/python/digital_clock && cd ~/Projects/python/digital_clock wget https://raw.githubusercontent.com/ebaketa/digital_clock/master/digital_clock.py
18. reboot Raspberry Pi OS
And that's it with the next boot you should have a Raspberry Pi digital clock. If you find any mistakes in commands, please let me know, so I can correct them!
Github repo: https://github.com/ebaketa/digital_clock
Till the next time!
No comments:
Post a Comment