Hello,
I have been trying to setup the Digital Inputs on the PiGear to use to monitor the state of some switches. I've tried connecting the inputs on pins 12,13,14,15 to the 5V from pin 2. It has worked occasionally, on some of the pins, but it's not working reliably or consistently. I've tried rebooting, tried reading the state of the pins different, etc. without reliable success.
Is the onboard 5V not suitable for this?
Could the PCF8574 have issues?
Am I missing something?
Thanks,
Phil
Those digital inputs are 12V tolerant and you can connect Pin 2 (5V) directly to them.
Digital inputs have their dedicated PCF8574, and the chance to damage it is pretty small.
Besides checking connection reliability, you may also check pin state with I2C commands like this:
i2cset -y 1 0x20 0xff i2cget -y 1 0x20
You can find description of this register on page 30 in the user manual.
Oh! When I ran this command, suddenly the DI are reporting correctly! This was working previously, but then stopped.
i2cset -y 1 0x20 0xff
I have been trying to write python code to set the pins 8,9,10,11 to be inputs, and I'm now thinking I may have caused the DI pins at 12-15 to stop working...
Do changes to the configurations of the configurable IO persist after power-disconnection? I don't have to configure them every boot, do I?
If it persists, maybe I'll just use your command line tool to set the DIO direction and then not try that in Python.
Do changes to the configurations of the configurable IO persist after power-disconnection?
Unfortunately not. The configuration will be lost after power disconnection. You may register an auto-run script to configure them after every boot.
When setting the registers, try not touching those bits that are not relevent. Using bit masking is recommended.