Skip to content

array-gpio breaks I2C on Pi Zero W #7

@dkossman

Description

@dkossman

Not sure if there is something else i need to do to make this work, but using array-gpio seems to break I2C.

Configuration: Pi Zero W running latest raspberry pi OS, two I2C devices connected (OLED display and an EZO pH circuit) to the standard SDA and SCL pins (3,5).

$ uname -a
Linux neonpi 6.6.74+rpt-rpi-v6 #1 Raspbian 1:6.6.74-1+rpt1 (2025-01-27) armv6l GNU/Linux
  1. reboot the Pi
  2. run i2cdetect -y 1
    -> normal output, both devices detected
  3. run this node app:
const gpio = require("array-gpio")

// initialize gpio pins for relays - outputs, pullups, off
const r1 = gpio.setOutput(11);
const r2 = gpio.setOutput(13);
r1.off();
r2.off();

// returns a specific relay's state
//   input is a number (1 or 2)
function getRelay(relay) {
    if (relay == 1)
       return(r1.isOn);
    else if (relay == 2)
       return(r2.isOn);
    else
       return(-1) 
}

// set a specific relay's state
//   relay is 1 or 2
//   level is 0 or 1 (off or on)
function setRelay(relay, level) {
    if (relay == 1)
       (level) ? r1.on() : r1.off();
    else if (relay == 2)
       (level) ? r2.on(): r2.off();
}

console.log("relay 1: ", getRelay(1));
console.log("relay 2: ", getRelay(2));
setRelay(2, 1);
console.log("relay 2: ", getRelay(2));
setRelay(2, 0);
console.log("relay 2: ", getRelay(2));

--> This works as expected, but...

  1. now re-run i2cdetect -y 1
    --> it fails to work correctly, output of the i2c map is extremely slow, and mangled. no I2C devices are detected. applications that try to write to the I2C bus fail with write errors
    --> it is necessary to power off and power back on the Pi to correct the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions