Jump to content

OrangePi5 OLEDStats


allatutti

Recommended Posts

If someone is interested can easy setup OledStats for OrangePi5 and SSD1306

 

Hardware:
Orangepi5
SSD1306 OLED display

Software
Armbian Jammy KDE Neon 6.1.43
Files attached in ZIP archive
device.py

PixelOperator.ttf
setup.py
stats.py


How to:

1) add overlay

wget https://raw.githubusercontent.com/orangepi-xunlong/linux-orangepi/orange-pi-5.10-rk3588/arch/arm64/boot/dts/rockchip/overlay/rk3588-i2c5-m3.dts
sudo armbian-add-overlay rk3588-i2c5-m3.dts
reboot


2) connect OLED display to I2C5 M3 Pins SDA + SCL (pins 1(VCC),2(SDA),3(SCL) and 5(GND))
check connection

sudo i2cdetect -y 5

must be detected 3c value

 

3) install needed libs
 

sudo apt-get install i2c-tools python3-smbus python3-pip python3-dev python3-pil


4) download main karabek project

git clone https://github.com/karabek/OrangePi-OLED
cd OrangePi-OLED

rename old setup.py

mv setup.py setup_old.py

 

4) create new setup.py or copy from ZIP archive

nano setup.py
#!/usr/bin/env python

from setuptools import setup

setup(
    name="ssd1306",
    version="0.1.0",
    author="Richard Hull",
    author_email="richard.hull@destructuring-bind.org",
    description="A small library to drive an OLED device with either SSD1306 or SH1106 chipset",
    license="MIT",
    keywords="raspberry pi rpi oled ssd1306 sh1106",
    url="https://github.com/rm-hull/ssd1306",
    packages=['oled'],
)

 

5) Start setup.py

sudo python3 setup.py sdist


6) copy generated folders to python3 dist packages
 

sudo cp -r OrangePi-OLED/oled/ /usr/local/lib/python3.10/dist-packages/
sudo cp -r OrangePi-OLED/ssd1306.egg-info/ /usr/local/lib/python3.10/dist-packages/

 

7) replace device.py file with file in ZIP archive in dist-packages oled folder

cd /usr/local/lib/python3.10/dist-packages/oled
mv device.py device_old.py

 

9) copy stats.py and font file PixelOperator.ttf from ZIP archive


start stats.py file

sudo python3 stats.py


result should be same as on RPI device
picture


 

Orangepi5_OLED.zip

Link to comment
Share on other sites

Posted (edited)

"OLED stats working also in debian, you need to activate I2C5 M3 overlay in orangepi-config"

 

By doing above, do you still need to execute point #1 (add overlay) from original instructions?

 

 

Edited by habro
Link to comment
Share on other sites

Thank you for your detailed instructions!

 

It works for me on my Orange Pi 3 LTS! (but I have to update my port to port=0) in both device.py and stats.py

 

has anyone ever tried it with crontab too?

 

my crontab code is:

@reboot cd /home/[user]/ && /usr/bin/python3 /home/[user]/stats.py &

 

When i run the script in crontab, it looks like that it couldn't  the font file PixelOperator.ttf if it is run from crontab; my ssd1306 screen lights up, but it only shows gibberish.

 

I even copied PixelOperator.ttf to /usr/share/fonts and /usr/local/share/fonts (and of course there is one in /home/[user]) but it still does not work...

 

 

Link to comment
Share on other sites

I have just managed to get my error log
 

Traceback (most recent call last):
  File "/home/sqms/stats.py", line 97, in <module>
    main()
  File "/home/sqms/stats.py", line 89, in main
    stats(oled)
  File "/home/sqms/stats.py", line 79, in stats
    draw.text((0, 0), hostname(), font=font2, fill=255)
                      ^^^^^^^^^^
  File "/home/sqms/stats.py", line 36, in hostname
    ip_address = output.split()[0]
                 ~~~~~~~~~~~~~~^^^
IndexError: list index out of range
 

Link to comment
Share on other sites

After reading a few more and getting to understand what the errors were I've realised what was the reason.

from the error log of my post earlier, it seems that the problem comes from the line for getting my ip, but the code seems fine.

So it gave me to feeling that my error was caused as crontab code runs before an ip was captured by the system after reboot

 

so instead of my above crontab code, my new code is:

 

Quote

@reboot sleep 15 %% /user/bin/python3 /home/sqms/stats.py & >> /home/sqms/error.txt 2>&1

 

and it works with no issues.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines