Has anyone managed to use a mini oled screen for i2c-4 using Python, with a 3w radxa? Can you please contact me? Another thing, how can it be that I install libraries with pip or with ./**.sh and when I import them into python it tells me that the library does not exist? Has anyone managed to use it with mraa, or luma.core with i2c-4, activating it with rsetup, in python? Thanks, share the code that worked and explain steps like pip install luma.core, add to the path # Add your exports and aliases here export PYTHONPATH=$PYTHONPATH:/path/to/your/site-packages # Other aliases or configurations alias ll=‘ls -la’ Please put the installation path, necessary installed libs and functional example, thank you.
Use i2c in python, mini oled example
I have already gotten it to work by following these steps.
ls /dev/i2c-*
sudo apt-get install i2c-tools
sudo i2cdetect -y number # my case number 4
pip install luma.core
pip install luma.oled
pip install smbus2
pip install Pillow
Git clone https://github.com/Jodels2002/Rock5b_SSD1308.git 28
For some reason that I don’t know, only if I run the script in the folder where I installed pip install luma.oled the scripts find luma.core
another way to use the oled screen
pip install adafruit-circuitpython-ssd1306
simple example
import board
import busio
import adafruit_ssd1306
from PIL import Image, ImageDraw, ImageFont
Configura el bus I2C
i2c = busio.I2C(board.D4_B3, board.D4_B2)
Inicializa la pantalla OLED SSD1306
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)
Limpiar la pantalla
oled.fill(0)
oled.show()
Crear una imagen con PIL
image = Image.new(“1”, (oled.width, oled.height))
draw = ImageDraw.Draw(image)
Dibujar un mensaje en la imagen
draw.text((0, 0), “Hola, Mundo!”, font=ImageFont.load_default(), fill=255)
Mostrar la imagen en la pantalla OLED
oled.image(image)
oled.show()