Difference between revisions of "How to enable OLED display"

From Geekworm Wiki
Jump to navigation Jump to search
 
(No difference)

Latest revision as of 20:25, 12 September 2024

It is recommended to refer to File:Oled-script-installtion-guide.pdf to install the oled script.


How to enable OLED display on Raspbian: [1]

1. Update your Pi and Install the required dependencies

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install i2c-tools python3-smbus
sudo apt-get -y install python3-pip python3-pil
sudo pip3 install --upgrade setuptools
sudo pip3 install --upgrade adafruit-python-shell
sudo pip3 install adafruit-circuitpython-ssd1306
sudo pip3 install pi-ina219
sudo pip3 show pi-ina219


2. Run the following command to check the oled i2c port

sudo i2cdetect -y 1

for X729, the I2C address is 0x3c, (In generally, the i2c address is 0x3c)

Please sure teh I2C is enable before this step, please refer to How to enable I2C


3. Installation

3.1 Download the required scripts

cd ~
# git clone https://github.com/suptronics/oled.git
git clone https://github.com/geekworm-com/oled
cd oled

3.2 Install the Adafruit CircuitPython library

sudo python3 raspi-blinka.py

This process may take tens of minutes, please be patient


3.3 Answering Y and hitting Enter when reboot prompted. Then renavigate to the oled directly by entering:

cd oled

3.4 Run the script to test the display

sudo python3 stats.py 

OR

sudo python3 x729.py 

Due to different hardware, you need to choose a different project file such as x729.py or stats.py

3.5 Run the script at Raspberry Pi boot

sudo crontab -e

3.6 Add a line at the end of the file that reads like this:

PS: we must toogle to the /home/pi/oled directory because .ttf files is required to locate in current directory,you can refer to x729.py source file, or you can also remove the 'cd /home/pi/oled &&' if you use the absolute path of the ttf file in the source code.

@reboot cd /home/pi/oled && python3 /home/pi/oled/yourd-evice-name.py &
X729-9.png

Save and exit. In nano editor, you do that by hitting CTRL + X, answering Y and hitting Enter when prompted.

References

  1. Adafruit Python SSD1306 library: https://github.com/adafruit/Adafruit_Python_SSD1306


Add your comment
Geekworm Wiki welcomes all comments. If you do not want to be anonymous, register or log in. It is free.


Anonymous user #7

4 months ago
Score 0++

Getting below error while run script "sudo python3 x729.py & sudo python3 stats.py "

OS: Volumio V3.0 Device: RPI 4B

volumio@fairviewstreamer:~/oled$ sudo python3 x729.py Traceback (most recent call last): File "x729.py", line 11, in <module> import adafruit_ssd1306 File "/usr/local/lib/python3.7/dist-packages/adafruit_ssd1306.py", line 17, in <module> from adafruit_bus_device import i2c_device, spi_device File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 15, in <mo dule> from circuitpython_typing import ReadableBuffer, WriteableBuffer File "/usr/local/lib/python3.7/dist-packages/circuitpython_typing/__init__.py", line 79 def read(self, count: Optional[int] = None, /) -> Optional[bytes]: ^

SyntaxError: invalid syntax

Anonymous user #6

4 months ago
Score 0++

Getting this error on RPi5:

Traceback (most recent call last): File "/home/caleb/oled/oled/x729.py", line 85, in <module> GPIO.setup(TACH, GPIO.IN, pull_up_down=GPIO.PUD_UP)

RuntimeError: Cannot determine SOC peripheral base address

Anonymous user #6

4 months ago
Score 0++
stats.py runs ok, but x729.py gives that error (yes I have the x729).

Harry

4 months ago
Score 0++
What OS?

Anonymous user #4

5 months ago
Score 0++
As per other user requests, please update these instructions and ensure compatibility with Raspberry Pi OS Debian 12 bookworm. A successful installation is not possible when following the current instructions.

Anonymous user #5

5 months ago
Score 0++
I tested it based on bookworm a few months ago and found no problems

Anonymous user #3

5 months ago
Score 0++
Can you please update your instructions. There are many python problems

Anonymous user #5

5 months ago
Score 0++
I tested it based on bookworm a few months ago and found no problems

Anonymous user #2

7 months ago
Score 0++

you say: Hi, you can ignore python-smbus package I ask: How

Instructions do not work at all. Many failures.

Lisa

7 months ago
Score 0++
Hi,could you please tell us more details? Please try to test the LED screen alone.Does the screen light up?

Anonymous user #1

25 months ago
Score 0++

Could you please update this page according to actual Raspberry OS release?

No python-smbus package there and couple errors coming on install adafruit-circuitpython-ssd1306

Harry

21 months ago
Score 0++
Hi, you can ignore python-smbus package.