This manual is written and tested by Kasper (kasperz@2heads.com) Do note: this document and it's scripts are still in development(!)
- Raspberry Pi 5 - 8GB + active cooling
- OLED Display (SPI) – currently SSD1309 2.42" OLED Display(Amazon: HiLetgo i2c model)
- Temporary HDMI screen + keyboard/mouse
OLED Pin | Raspberry Pi Pin |
---|---|
VIN | 3.3V (pin 1) |
GND | GND (pin 6) |
Data | GPIO3 I2C (pin 3) |
Clk | GPIO5 I2C (pin 5) |
Follow the instructions, and take time for each step. Be patient, for best result.
Do note: Use correct mode
- Wire everything up and prepare the board.
- Use the Raspberry Pi Imager to create an image for the board:
- Use the Raspberry Pi Bookworm OS (32-bit) with desktop environment.
- Do not use custom settings.
- Load the board with the image.
- Set timezone to US.
- Set username and password:
- Username:
galaxy
- Password:
separator
- Username:
- Set up WiFi temporarily with an internet connection.
- Uninstall Firefox.
- Update the system.
- Grab yourself coffee and a snack (this takes some time).
- Restart the board.
- Enable SSH and I2C in Raspberry Pi Configuration > Interfaces.
- Run the following commands(make sure you have an active internet connection):
sudo apt update && sudo apt upgrade -y sudo apt install python3-venv sudo apt install git -y
- Install the required dependencies:
when prompted enter "Y" + enter to continue
sudo apt install libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7-dev libtiff5-dev tk-dev tcl-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxcb1-dev
- Create and activate a virtual environment:
(Use
python3 -m venv oled-env source oled-env/bin/activate
deactivate
to exit the virtual environment when required.) - Check the OLED address:
(Address should be visible 0x3D or 0x3C. If not, check the display wiring.) - Make sure to set address in the script
i2cdetect -y 1
- Clone the repository:
Note: for this step: the repo must set to public temporarily, contact author for this.
run: sudo apt update pip install --upgrade pip sudo apt install -y python3-dev python3-pip python3-setuptools python3-wheel libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libwebp-dev tk-dev tcl-dev pip3 install --upgrade pip setuptools wheel sudo apt-get install python3-netifaces pip install luma.oled
git clone https://github.com/lavacode/oled.git
- If cloning fails, ensure the LAN cable is temporarily disconnected and follow these steps:
nmcli connection show sudo nmcli connection modify "<LAN Connection Name>" ipv4.never-default yes sudo nmcli connection down "<LAN Connection Name>" && sudo nmcli connection up "<LAN Connection Name>"
- If cloning fails, ensure the LAN cable is temporarily disconnected and follow these steps:
- Activate the virtual environment if not activated:
source oled-env/bin/activate
- Navigate to the cloned repository and install requirements:
when prompted enter "Y" + enter to continue
cd oled cd scripts-single / ****_dual pip3 install -r requirements.txt
- Test the setup:
This should result in "First test" on your display
python3 oled-test.py
- Test the final code:
python3 oled-src.py
- Return to the home folder:
cd
- Remove the cloned repository:
rm -rf oled
- Download the final script:
wget https://raw.githubusercontent.com/lavacode/oled/main/scripts-single/oled-src.py or, in dual mode: wget https://raw.githubusercontent.com/lavacode/oled/main/scripts-dual/oled-src.py
- Verify the script is present:
You should see the "oled-src.py"
ls
- Make the script executable:
chmod +x oled-src.py
- Create a systemd service:
Add the following content:
sudo nano /etc/systemd/system/oled.service
[Unit] Description=Autostart OLED script After=network.target [Service] ExecStart=/home/galaxy/oled-env/bin/python3 /home/galaxy/oled-src.py WorkingDirectory=/home/galaxy Environment=VIRTUAL_ENV=/home/galaxy/oled-env Environment=PATH=/home/galaxy/oled-env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin StandardOutput=inherit StandardError=inherit Restart=always User=galaxy [Install] WantedBy=multi-user.target
- Save and exit (Ctrl + X, Y, Enter).
- Reload systemd:
This should result in "enabled"
sudo systemctl daemon-reload sudo systemctl enable oled.service sudo systemctl start oled.service sudo systemctl status oled.service
- Set up static network and check priority in "General" is set to 0. Also make sure it is set to manual(!)
- Turn WiFi OFF
- Reboot:
sudo reboot
- Test, if succesful everything should work as supposed. Only then continue.
- Access the board via SSH. Use external computer linked to board. use Mac or Windows terminal
```bash
ssh galaxy@ip_address_of_pi
Enter details. For fingerprint enter "Y". *if the connection is succesful, you don't need a monitor + keyboard anymore for the Pi*
- Run:
sudo raspi-config
- Navigate to:
- System Options
- Boot / Auto Login
- Set to "Console Autologin".
- Reboot.
- Edit the config file:
sudo nano /boot/firmware/config.txt
- Add the following line at the bottom:
dtoverlay=disable-wifi dtoverlay=disable-bt
- Change the setting
update it to
camera_auto_detect=1
camera_auto_detect=0
- Save and exit.
-
sudo reboot
Destination Port: 12345
The following UDP commands can be sent to control the board:
- start: Starts the timer.
- stop: Stops the timer.
- pause: Pauses the timer.
- resume: Resumes the timer.
- DUR!###: Changes the timer duration (replace
###
with the number of seconds). - reboot: Reboots the board.
All UDP commands will reply with command_rcv
to acknowledge receipt of the command.
-
ISSUES? PERFORM A REBOOT! =)
-
Install required Python packages:
sudo apt install python3-pip python3-pil python3-smbus python3-rpi.gpio pip install adafruit-circuitpython-ssd1306 pip install adafruit-blinka pip3 install pillow pip3 install netifaces
-
Busio-related issues? Ensure SDA/SCL connections are not twisted.
-
Executing script results in "No I2C device detected" Check your screen connection and address
- In case you get an error "IDENTIFICATION HAS CHANGED"
Use the Pi directly
Then on your remote computer:
cd /etc/ssh ls sudo rm ssh_host_* sudo dkpg-reconfigure openssh-server sudo systemctl restart ssh
ssh-keygen -R <raspberry_ip>
- Open the file:
sudo nano oled-src.py
- Make changes, then save and exit (Ctrl + X, Y, Enter).
- Reboot:
sudo reboot
- Connect with ssh to the default IP of the Pi.
-
Here you can edit the connection. Still having issues? then follow the next steps
sudo nmtui
-
now you see all known connections, check which to modify and:
sudo ls /etc/NetworkManager/system-connections/
-
sudo nano /etc/NetworkManager/system-connections/'Wired connection 1.nmconnection'
- Update data and save
-
sudo systemctl restart NetworkManager
-
ip a
- To remove a known wifi connection
sudo rm /etc/NetworkManager/system-connections/'DTC-FLEX.nmconnection'
-
sudo systemctl restart NetworkManager
-
You can decide to turn the EEE off. Please refer to google. Checking eee status:
sudo ethtool --show-eee eth0
Most easy way is with monitor and keyboard/mouse, but alternatively:
Make sure wifi is allowed (in config.txt)
-
check if wifi is blocked:
rfkill list
In case: Soft blocked yes, do:
sudo rfkill unblock wifi sudo ip link set wlan0 up
-
Scan networks:
nmcli device wifi list
in case no results set correct region.
Check current region:
sudo iw reg get
Set region:
sudo iw reg set US
nmcli device wifi list
-
Connect:
sudo nmcli device wifi connect "<SSID>" password "<password>"
-
Done
-
for disabling perform the action in config.txt and also remove the known wifi connection:
sudo rm /etc/NetworkManager/system-connections/'DTC-FLEX.nmconnection'
-
After reboot, check with:
ip a
that the connection is gone.
Follow instructions step 6 to 12. Run the test script:
python3 oled-test.py
This should display "First test" on the OLED screen.
Compare with the GitHub version: oled-src.py
Having issues accessing the script? Contact: kasperz@2heads.com