Both for the tool i2cdetect and for Python 2.7 the bus 0 has to be addressed with its ID 7. Otherwise it works quite well. I connected the character OLED NHD-0420CW from Newhaven Display to I2C as a test.
linaro@rpi4b:~$ mraa-i2c list
Bus 0: id=07 type=linux default
Bus 1: id=02 type=linux
Bus 2: id=06 type=linux
linaro@rpi4b:~$ sudo mraa-i2c detect 0
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3d -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
linaro@rpi4b:~$ sudo i2cdetect -y 7
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3d -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Example lcd_showtime
# shows time and date in first tow rows of LCD
# Date: Dec 8th, 2017
#
import os
from I2cCharDisplay import I2cCharDisplay
# import locale # https://help.ubuntu.com/community/Locale
from time import strftime
import threading # I do not like to use sleep(1) to wait a second, not even in an example
OLEDADDRESS = 0x3d # i2c address for the oled display
busnum = 7
# locale.setlocale(locale.LC_ALL,'de_DE.utf8') # Set locale for a nice date, to date french girl, change to fr_FR.utf8
oled = I2cCharDisplay("OLED", OLEDADDRESS, 4) # create an oled object for a 4 line display
def getCpuTemperature():
tempFile = open( "/sys/class/thermal/thermal_zone0/temp" )
cpu_temp = tempFile.read()
tempFile.close()
return float(cpu_temp)/1000
oled.clear()
oled.setBrightness(4)
def show_time():
threading.Timer(1.0, show_time).start() # Show time and date every second
oled.cursorMove(col=7,row=1)
oled.writeString(strftime('%H:%M:%S')) # Hour:minute:second
oled.cursorMove(col=3,row=2)
oled.writeString(strftime('%a %d. %b %Y')) # Weekday as locale’s abbreviated name, Day of the month,
# Month as locale’s abbreviated name, Year with century
oled.cursorMove(col=4,row=3)
oled.writeString("CPU temp ")
oled.writeString(str(round(getCpuTemperature(), 1)))
oled.writeString("C")
show_time()