Not your question exactly, but...
the tutorial you used is more complicated than it needs to be. There is now a device tree overlay (dtoverlay
) that requires no code. It's described in the documentation for gpio-shutdown
:
This overlay only handles shutdown. After shutdown, the system can be powered up again by driving GPIO3 low. The default configuration uses GPIO3 with a pullup, so if you connect a button between GPIO3 and GND (pin 5 and 6 on the 40-pin header), you get a shutdown and power-up button. Please note that Raspberry Pi 1 Model B rev 1 uses GPIO1 instead of GPIO3.
You can use any momentary pushbutton switch, and the gpio-shutdown
overlay also gives you the option of a debounce
function on the switch if contact bounce is an issue - or if you simply want to delay the shutdown for a short period.
As for your question:
In addition to the "bit-banging" software i2c
suggested in joan's answer, you may also be able to use the "hardware-based" i2c0
channel on the RPi 3. AIUI, i2c0
may be unavailable for alternative assignments if you use the HDMI port, or the Pi camera (?), but otherwise it should work fine. I am using i2c0
for the Realtime Clock on my RPi 3B+, and have encountered no issues - click the link for configuration details.
Another potential complication: As is typical of Amazon's vendors, their specifications are sketchy and unreliable. The vendor you referenced states:
Embedded driver IC: Communication: I2C/IIC Interface, only need 2 I/O ports; Compatible with MMDVM, Pi-Star, and it is compatible with Raspberry pi
If you know what this means or have some experience with this device, pay no heed, but if you need a RPi driver, it may simplify your integration to learn which one it is.
In any case, wrt the i2c0
configuration and hookup, that can all be done in your /boot/config.txt
file. Know first that i2c0
is a (now deprecated) synonym for i2c_vc
. Here are the changes/additions you'll need to make when editing /boot/config.txt
:
dtparam=i2c_vc=on
i2c_vc_baudrate
: default is 100,000; otherwise set dtparam=i2c_vc_baudrate=<value>
Alternatively, use the dtoverlay
(ref the Info
section for this overlay in the documentation):
dtoverlay=i2c0
After rebooting, you should be able to use i2c0
on GPIO 0 & 1 (physical pins 27 & 28) to communicate with your display. Note that if you find you need to use a driver from the RPi distro, that may require a different overlay, which may or may not support i2c0
.
FWIW:
The RPi 4 offers many more options for i2c
support than prior versions. In addition to i2c0
, i2c1
and software i2c
, you will find i2c3, 4, 5 & 6
(4 additional).
Finally note that it may be possible to relocate i2c1
to another pair of GPIO pins by changing the default pin configuration. I'll leave that for another day as I've not actually tried that myself as yet - and it's more difficult than simply invoking a pre-configured dtoverlay
.