2

I have the following 128 x 128 OLED display: http://www.lcdwiki.com/zh/1.5inch_OLED_Module_SKU:MC01503 which is driven by a SSD1327 module.

I'm trying to use this with a Pi 4 and the Luma.oled python repository of rm-hull, which supports SSD1327: https://github.com/rm-hull/luma.oled

The installation of the libraries was carried out according the the instructions here: https://github.com/rm-hull/luma.examples

everything installed with no problems. However, whenever I try to use any examples, or run the library from my own code, it always throws an error that it can't find the OLED display. The traceback is as follows:

File "/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py", line 622, in write_i2c_block_data ioctl(self.fd, I2C_SMBUS, msg)

OSError: [Errno 121] Remote I/O error

However, running i2cdetect shows the device exactly where expected.

error from luma.example, plus output of i2cdetect

I have previously successfully communicated with an ADS1115 ADC converter using I2C from this same Pi, so it shouldn't be a problem with the pins or the Pi itself.

Does anyone have any experience with running this display who could shed some light on why i2cdetect can see the chip, but the python library can't?

roger-reject
  • 133
  • 6
  • I usually "pip install" a python library/package and then find python3 could not find the package. My lesson learnt is that if I am going to use python 3, I must used "pip3 install", otherwise python 3 cannot find the package which is installed in the default python 2 directories. Perhaps you might also that some sort of python2/3 compatibility problems. – tlfong01 Jul 13 '20 at 02:58
  • 1
    But your problem seems to be I/O related. You can find your LED at 0x3c does NOT guarantee you can write to it. Perhaps you can lower you I2C speed from standard 100kHz down to 50kHz, or even 10kHz, to see if problem disappeared. Other troubleshooting tricks include: (1) Use short wires, say less than 30cm, (2) remove all SMD 4k7/10k pullups from I2C modules. This helps reducing total equivalent pullups impedance exceeding the I2C's 400pF limit (Rpi4 I2C pins already have strong 1k8 pullups, too many external pullup might make pullup too strong for I2C pin to handle at high speed. – tlfong01 Jul 13 '20 at 03:06
  • 1
    thanks for the suggestions! The wires are already short (~10cm), and there's no external pullups. I'll try lowering the i2c speed and see what happens. – roger-reject Jul 13 '20 at 04:29
  • Almost a year ago I did successfully tested displayed "Hello World" in a OLED. You might like to check if my writeup helps: "Rpi3B SSD1306 OLED I2C Interface Problem - 2019dec21": https://raspberrypi.stackexchange.com/questions/106482/rpi3b-ssd1306-oled-i2c-interface-problem/106487#106487. – tlfong01 Jul 13 '20 at 05:11
  • I vaguely remember I used the following python Library to test the Hello World python program. https://indibit.de/raspberry-pi-oled-display-128x64-mit-python-ansteuern-i2c/7/#Beispiel_1_Hallo_Welt. But I forgot all the details, or actually not much details. I just loaded the library and ran the demo program. One thing to remind is that if your OLED module has an built in 3-leg LDO, then you should power it with 5V. The module might still work with 3V3 power, but might not be that stable. – tlfong01 Jul 13 '20 at 05:19
  • Another thing is placed one or more other I2C devices on the same bus at the same time when testing, and use python to ping the devices' registers, to make sure you can write and read back the register of at least one the I2C devices you once found already working. PS - If from time to time you get the I/O Error #121 (not sure if I remember the number correctly), then the I2C bus might be not in a good condition. – tlfong01 Jul 13 '20 at 05:28
  • Where is the error message? That normally says what is wrong. – joan Jul 13 '20 at 05:46
  • @joan the error is a communication error, where python is not able to communicate to the device on 0x3c, despite it being detected by i2cdetect. edited the question to show the specific error. – roger-reject Jul 13 '20 at 07:53
  • @tlfong01 3v3 and 5v both give the same error, and lowering the i2c baudrate doesn't help. the i2c bus was able to read and write from a ADC converter previously without any problem, so I tend to think it's not a hardware issue. – roger-reject Jul 13 '20 at 07:57
  • Is that the full traceback? Usually the line in your program would be indicated. – joan Jul 13 '20 at 08:27
  • Please don't post pictures of text. Instead paste the text direct into the question. – Ingo Jul 13 '20 at 08:51
  • Ah, so your problem is I/O Error #121. Let me tell your my experience with Error 121. I had so 15 or 16 I2C MCP23017 GPIO extenders. I checked that everyone works independently, by itself like write a device register and then read back. I was happy and so added one by one to hopefully to 8 MCP23017s on the same bus, with or without other I2C ddvices. Then I sadly found that though I could get all 8 on the same bus, the Error 121 error appear more and more often. Then I reduce one by one, then Error messages became less and less. – tlfong01 Jul 13 '20 at 09:39
  • It is clear and sharp that once I put 3, no more errors for 10 write/reads, but if I put on 4, then Error 121 all the time. I also found that some of my 15+ MCP23017s are good guys and can work smoothly together at the same time, while some are bad guys, and even one of them on their own would often get 121 errors. You like my test results, demo programs, and SMBus references in my long list of blog post on my I2C device testing:

    https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=77158&hilit=mcp23017+I%2FO+error+121+tlfong01&start=200. Ah, supper time. See you later. Cheers.

    – tlfong01 Jul 13 '20 at 09:45
  • "8 MCP23017s on the same bus, very unstable, I/O Error #121 All the time": https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=77158&hilit=mcp23017+I%2FO+error+121+tlfong01&start=375#p1362527 – tlfong01 Jul 13 '20 at 09:52

2 Answers2

1

Errno 121 means (besides using a wrong address, which is not your case) that the slave didn't expect the command you have sent and didn't acknowledge it properly. This often happens if the master transmits extra bytes or not enough bytes by mistake.

The easiest way to debug this would be to connect a logic analyzer or a scope capable of I2C decoding to the bus and looking at the actual bytes your code transmits, and an eventual response from the slave. You could then directly compare that to the datasheet or a capture made on a working system (e.g. Arduino).

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
1

I believe Dmitry's answer is correct and there is something in the I2C communication that's going wrong. However, since I'm still waiting for access to a logic analyzer, I took the easier and cheaper route of simply buying a second screen with SPI wiring. That one works flawlessly out of the box.

Thus another "answer" is to avoid purchasing OLED boards with only I2C wiring options!

roger-reject
  • 133
  • 6