Adafruit PiOLED 128x32 Monochrome OLED - Could not open file i2c-1


#1

Hi guys,

I’m getting an error when trying to use the Adafruit PiOLED 128x32 Monochrome OLED. I’ve set everything up as per the instructions here and enabled I2C. I’m getting the following error when running i2cdetect -y 1:

Error: Could not open file/dev/i2c-1’ or /dev/i2c/1': No such file or directory

When I run ls /dev/i2c*, I get the following:

/dev/i2c-3

I can run i2cdetect -y 3 but this doesn’t work with the PiOLED and I get the following output (despite the hat being attached to my Pi Zero W).

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   

Any help would be greatly appreciated!


#2

There may be something further down in your /boot/config.txt disabling i2c. Have you used, or are you using a HyperPixel on this Pi? That’s one of the few reasons why you’d have an `i2c-31.

What does your /boot/config.txt look like?


#3

Hi @gadgetoid,

Thanks for your quick reply. Yes, I was the one you were helping on another thread about the Hyperpixel4 not firing. I’ve got a Hyperpixel4 attached to this Pi so that explains the i2c-3.

My config.txt is as follows. I’ve been messing around with i2c settings here based on things I’ve read on other forums but still no luck.

# For more options and information see

# http://rpf.io/configtxt

# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode

#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible

# and your display can output without overscan

#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console

# goes off screen, and negative if there is too much border

#overscan_left=16

#overscan_right=16

#overscan_top=16

#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus

# overscan.

#framebuffer_width=1280

#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output

#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)

#hdmi_group=1

#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in

# DMT (computer monitor) modes

#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or

# no display

#config_hdmi_boost=4

# uncomment for composite PAL

#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.

#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces

dtparam=i2c_arm=on

dtparam=i2c1=on

device_tree_param=i2c_arm=on

#dtparam=i2s=on

#dtparam=spi=on

# Uncomment this to enable the lirc-rpi module

#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)

dtparam=audio=on

# NOOBS Auto-generated Settings:

hdmi_force_hotplug=1

dtoverlay=hyperpixel4

overscan_left=0

overscan_right=0

overscan_top=0

overscan_bottom=0

framebuffer_width=800

framebuffer_height=480

enable_dpi_lcd=1

display_default_lcd=1

dpi_group=2

dpi_mode=87

dpi_output_format=0x7f216

display_rotate=3

hdmi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6

#4

You’ll need to connect the OLED to the i2c breakout connector on hyperpixel4 - which places it on i2c3 - in order for it to work with HyperPixel. The normal i2c pins on the Pi are used for two of the most important signals for driving the display itself, so they can’t function as i2c or be shared in any way.


#5

I’m looking to use the two independently of each other but on the same Pi board - so basically use the Hyperpixel for some work and then unplug before plugging on the OLED onto the board. Can this be done? Can the i2c be switched? Possibly via 2 different config files?


#6

In theory yes- two config files should do the trick but it’d be a heck of a fiddle every time you want to switch from one thing to the other! You could probably write a little shell script to keep track of them, though.

I’d create a folder - /boot/configfiles/ and store each config in there, loading it by copying it to /boot/config.txt


#7

Works like a charm, thank you! A bit of fiddling but we got there.