OLED Module White Color 128X64 LCD

1.3 Inch OLED Module White Color 128X64 OLED LCD LED Display Module 1.3 IIC I2C SPI Communicate for arduino Diy Kit


25 ₪

الناشر: متجر القطع الالكترونية

القسم: شاشات ولمبات ومصابيح ولدات

تاريخ النشر: 2025-03-19





connect to RPI:



interface pin:



Step 1: Enable I2C communication

code
نسخ
اقتباس
عرض
تنزيل
	
								
sudo apt update sudo apt install python3-pip sudo raspi-config #==============> shown in image below sudo apt install i2c-tools








code
نسخ
اقتباس
عرض
تنزيل
	
								
sodo reboot


Step 2: Find OLED I2C address and update it

code
نسخ
اقتباس
عرض
تنزيل
	
								
sudo i2cdetect –y 1


If you’ve got an original Model B Rev 1 Pi then type the following command instead :



code
نسخ
اقتباس
عرض
تنزيل
	
								
i2cdetect -y 0




This was good news as it showed the device had been detected with an address of “0x3c”. This is the default hex address for this type of device. I’ve got no idea why the device PCB suggests the address is “0x78” when it is clearly “0x3c”.



code
نسخ
اقتباس
عرض
تنزيل
	
								
sudo apt-get update


Step 3: Install luma.oled library

code
نسخ
اقتباس
عرض
تنزيل
	
								
sudo pip3 install luma.oled


test code1: print text

code
نسخ
اقتباس
عرض
تنزيل
	
								
from luma.core.interface.serial import i2c from luma.core.render import canvas from luma.oled.device import sh1106, ssd1306 from PIL import ImageFont, ImageDraw, Image import time import psutil serial = i2c(port=1, address=0x3C) #=========================== device = sh1106(serial) #or #device = ssd1306(serial) #=========================== while True: #Calculate memory information memory = psutil.virtual_memory() #Convert Bytes to MB (Bytes -> KB -> MB) available = round(memory.available/1024.0/1024.0,1) totalm = round(memory.total/1024.0/1024.0,1) mem_info = str(available) + 'MB free / ' + str(totalm) + 'MB total ( ' + str(memory.percent) + '% )' # Calculate disk information disk = psutil.disk_usage('/') # Convert Bytes to GB (Bytes -> KB -> MB -> GB) free = round(disk.free/1024.0/1024.0/1024.0,1) totald = round(disk.total/1024.0/1024.0/1024.0,1) disk_info = str(free) + 'GB free / ' + str(totald) + 'GB total ( ' + str(disk.percent) + '% )' with canvas(device) as draw: draw.text((10, 1 ),"Ram & Disk infos", fill = "white") draw.text((1, 13),"Free Ram =" , fill = "white") draw.text((78,13),str(available) , fill = "white") draw.text((115,13),"M" , fill = "white") draw.text((1, 26),"Total Ram =" , fill = "white") draw.text((78,26),str(totalm) , fill = "white") draw.text((115,26),"M" , fill = "white") draw.text((1, 39),"Free Disk=" , fill = "white") draw.text((78,39),str(free) , fill = "white") draw.text((115,39),"G" , fill = "white") draw.text((1, 52),"Total Disk=" , fill = "white") draw.text((78,52),str(totald) , fill = "white") draw.text((115,52),"G" , fill = "white") time.sleep(2)


NOTE: oled type ===> sh1106 or ssd1306

code
نسخ
اقتباس
عرض
تنزيل
	
								
device = sh1106(serial) or device = ssd1306(serial)


سلة المشتريات افراغ السلة