Rpi3B SSD1306 OLED I2C Interface Problem
Ask QuestionAsked 1 year, 1 month agoActive 8 months agoViewed 670 times3
I know there are similar questions, but none of them helped me out.
I have a
Raspberry Pi 3 Model B Rev 1.2 and
Raspbian 10 installed. I try to connect an 0.91″ Oled display (Hardware Details) which has a
ssd1306 chip on it.
I already activated i2c:
$ cat /boot/config.txt | grep i2c dtparam=i2c_arm=on
I wired it like the following, based on (a german blog) found here, like the following:
- GND -> PIN9 (Ground)
- VCC -> PIN2 (5 Volt)
- SCK -> PIN5 (GPIO3 / SCL)
- SDA -> PIN3 (GPIO2 / SDA)
i2cdetect -y 1 I get the following:
$ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
What can i do? Best regards!gpioi2cShareEditFollowCloseFlagedited May 19 ’20 at 1:49tlfong013,47633 gold badges77 silver badges2222 bronze badgesasked Dec 21 ’19 at 21:40bernhardh13133 bronze badges
- We need a clear photo showing the connections between the Pi and OLED. We need to be able to trace from Pi pin to OLED pin. – joan Dec 21 ’19 at 21:48
- 1It’s safer to power the OLED from 3V3 if you can. Feeding 5V into a Pi GPIO can destroy the GPIO and the Pi. – joan Dec 21 ’19 at 21:50
- 2added pictures. i wired it with 5V, since the docu i got from the display (which is for arduino only) says, to wire it to 5V. But i can of course change it (and tried it in first place) – bernhardh Dec 21 ’19 at 21:54
- Here you can find the wire info for arduino i.imgur.com/c2oxsRg.png – bernhardh Dec 21 ’19 at 21:57
- Unfortunately that all looks fine. Could you check for continuity from Pi pin to corresponding OLED pin? – joan Dec 21 ’19 at 22:04
add a comment | show 2 more commentsstart a bounty
I have tested a 0.9″ SSD1306 OLED and found “i2cdetect -y 1” can detect the device address 0x3c without any problem. So I guess there are two possibilities:
(1) The OLED modules you bought are bad. You might like to buy or borrow more samples to test again.
(2) Your Rpi buster is not properly configured. As I suggested, you should used another I2C device to make sure your config and i2cdetect -y 1 can indeed detect an I2C device.
I have summarized my test results below. You may like to use similar config and try again (See Appendix B for more details).
Ah, let me see. It is true that 3V3 SMD/through hole ICs/chips should be powered by 3V3.
However, most 3V3 chips with breakouts or in the form of modules are almost always designed to be powered by 5V0 for two reasons:
(1) To make breakout/module compatible to both
(a) [3V3/5V0 powered Arduino with 3V3/5V0 GPIO/logic] AND (b) [5V0 powered Rpi with 3V3 GPIO/logic],
(2) The breakout/module usually uses a LDO (Low Drop Out) regulator to step down 5V0 to 3V3 which is now more precise, regulated, and stable than directly feeding with 3V3 source which might be too low, noisy, poorly regulated (because overload with other devices, long thin cables, etc).
To play safe, I almost always look closely at the PCB for the 3 leg LDO guy (marked 562K below). Errata 2019dec24 – 565K should read 662 K, See Appendix for datasheet.
My suggestion: Go ahead with 5V0.
Warning： No guarantee no nothing would melt down or blow up.
PS1 – To troubleshoot, you can try any other I2C devices to i2cdetect -y 1 again, to make sure that your Rpi + I2C driver/software etc are updated/upgraded, correctly setup and enabled, and working. Good luck and cheers.
PS2 – The module shows three 4k7s which should be the I2C pullups. There is no need to add your own pullup in this case. On the other hand, if LATER you add more I2C devices and detection is no longer stable, you might consider removing the 4k7 pullups, because Rpi I2C pins already have 1k7 pull ups which are strong enough to do the pull up/down job. (Too many 4k7s in parallel would result a too strong (much lower than even 1k equivalent resistance.) Rpi I2C pins then need to pull harder (Ohm’s Law! :))and therefore Rpi would age faster or die sooner. [Pull down current of 3V/1k7 is much smaller than 3V/1k.]
(1) How to connect Raspberry Pi 4 to sparkfun SSD1306 / SSD1309 OLED transparent display?
(2) AliExpress SSD1306 / SSD1309 OLED Catalog
(3) Solomon Systech SSD1306 LCD Controller Catalog
(4) Solomon Systech SSD1306 LCD Controller Datasheet
(6) AliExpress SH1106 Module Catalolg
(7) TaoBao SH1106 1.3″ OLED Module
(8) TaoBao SH1106 0.9″ OLED Module
(9) Luma.OLED: Display drivers for SSD1306 / SSD1309 / SSD1322 / SSD1325 / SSD1327 / SSD1331 / SSD1351 / SH1106
(10) Luma.OLED API Doc for SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1331, SSD1351 and SH1106API OLED
(11) Rpi: Control I2C SSD1306 OLED 128 × 64 display Python – Sebastian, indibit.de 2018apr16
Appendix A – LDO
XC6206P332MR (662K) 3.3V, 0.3A, SOT3-3 Low Dropout Datasheet – SunRom
XC6206P332MR (662K) 3.3V 200mA Positive Fixed LDO Voltage Regulator in SOT-23 package – Rs9
Used in sensor modules where input voltage can be 3.3V or 5V and output will be fixed 3V to sensor IC. So if user inputs 3.3V the output is 3V due to low drop out voltage of this IC. When you input 5V the output is 3.3V. This IC is excellent where you want to design modules compitable with various input voltages.
Appendix B – How to edit config.txt to make it as simple as possible to detect SSD1306 OLED
(1) How to set up and use your brand-new Raspberry Pi – Alex Bate, rpi.org 2019dec25
Many Rpi terminal window commands giving you the power to have more control over your system, …
(2) 50 Useful Raspberry Pi Commands – A Beginner’s Guide – Parijat Dutta 2019dec23
Basic commands to backup and edit /boot/config.txt: cd, ls, cp, nano, cat, mv, rm, …
Example to edit config.txt
(1) cd /boot [change directory to /boot to find config.txt]
(2) ls – l [list files in directory]
(3) cp config.txt configtest01.txt [copy a working copy of original copy of config.txt]
(4) mv config.txt configoriginal.txt [rename original copy as a backup]
(5) sudo nano configtest01.txt [edit working copy of config.txt]
(6) cat configtest01.txt [check contents of edited work copy]
(7) rm config.txt [remove current config.txt IMPORTANT: killing current config.txt!!!]
(8) sudo reboot now [must reboot to use new version of config.txt]
(9) i2cdetect -y 1 [hopefully to find OLED at 0x3c]
(10) It is important to do sudo apt-get update and upgrade before i2cdetect. And from time to time the most recent upgrade might have teething problems， and often full upgrade can solve the problem, as summarized below.
sudo apt-get update
sudo apt-get full-upgrade -y
sudo apt-get autoremove -y
sudo reboot now
Warning: Try at your own risk. No guarantee no nothing won’t melt down or blow up!!!
Appendix C – Hello World Program
(11) Rpi: Control I2C SSD1306 OLED 128 × 64 display Python – Sebastian, indibit.de 2018apr16
ShareEditDeleteFlagedited Dec 26 ’19 at 9:02answered Dec 22 ’19 at 3:42tlfong013,47633 gold badges77 silver badges2222 bronze badges
- I am a real hardware noob, so I understand only the half of your posting ;). I tried it with both 3V and 5V on 2 different RPi and 2 different Oleds (both with 3V first). I have no other I2C device atm. – bernhardh Dec 22 ’19 at 20:26
- Ah, let me see. (1) Using another I2C device and use “i2cdetect -y 1” command to make sure I2C software/hardware/wiring OK is the most effective first line troubleshooting method. (2) Or you can use a multi-meter to check out the following: (a) The PCB’s SMD LDO’s Ground/Vcc/Output voltages are 0V/5V/3V3 (See Appendix A for more info on LDO 6600K). (b) Use multi-meter to check the SCL/SDA terminal voltages are 3V3/3V. These are the very basic “Open/Short/Ground/Vcc”. – tlfong01 Dec 23 ’19 at 13:13
- (3) Other tricks include (a) Lower I2C speed to 100kHz, or even 50/10kHz (Just in case you wiring are very long and result in total capacitance bigger than 400pF, which is the limit of I2C driving circuit. (4) Buy more OLED modules form another reputable vendor (especially if yours are form eBay! 🙂 – tlfong01 Dec 23 ’19 at 13:13
- I sometimes use more advanced tricks including (1) Use python repeated write/read a register of the modules, to make sure what is written can be correctly read back, and (2) use a scope to see if the SCL/SDA waveforms are clean and sharp. But for newbies buying more modules (may try both mode (SPI/I2C) and test SPI mode (but even more messy). – tlfong01 Dec 23 ’19 at 13:17
- Of course I don’t suggest you to get a oscilloscope to do troubleshooting. In your case using pairing/swapping approach to find out the bad guy is the most time efficient way. You have the advantage to swap test easily because you have two Rpi’s and three OLED modules. Looking back, I now think that your buster version might be too old (must be after 2019jul, best to use 2019sep26). You might have followed out of date tutorials and install bad drivers which might crash with built in I2C drivers. So one thin you might like to do is to restart everything from a fresh buster 2019sep26 version. – tlfong01 Dec 24 ’19 at 3:57
add a comment | show 1 more comment3
1) RPi I2C bus uses 3.3V levels, so connecting here any I2C device powered from 5V can damage your RPi. Additionally, your OLED module documentation shows that it is designed to be powered from 3.3V, and absolute maximum Vcc is… 4V !!!! So, it is possible that you burned-out your display 😦 So, as the first step RECONNECT the power of your module to 3.3V. (for reference: https://cdn.shopify.com/s/files/1/1509/1638/files/0.91_inch_OLED_Datenblatt_48df5c86-6edd-48d9-92ab-c3d76691ac73.pdf?91672)
2) If this abowe will not help, try adding pull-up resistors between SDA and VCC (3.3V), and SCL and VCC (3.3V) – both 3.3kOhm or 4.7kOhm (or something in the middle).ShareEditFollowFlagedited Dec 22 ’19 at 3:16answered Dec 22 ’19 at 3:02VillageTech13155 bronze badges
- Thanks. Since i have 2 RPi and 3 Oled modules, I tried it with the second RPi and the second oled (same SD card) with 3V and got the same result. So its not a hardware damage. I have no pull-up resistor atm, so I can’t try your second suggestion. – bernhardh Dec 22 ’19 at 19:59
Leave a Reply