Skip to content

Instantly share code, notes, and snippets.

@c7h
Created September 6, 2018 11:08
Show Gist options
  • Save c7h/d72522802deb0b878e99ae70f3a18326 to your computer and use it in GitHub Desktop.
Save c7h/d72522802deb0b878e99ae70f3a18326 to your computer and use it in GitHub Desktop.
Read an I2C Portexpander
#!/bin/bash
ADDRESS=0x27
printf "76543210 76543210\n"
while :
do
v=$(i2cget -y 0 $ADDRESS 0x00 w)
echo ${v: -4:4} | xxd -r -p | xxd -b | awk '{split($0,a," "); printf "%s %s\r", a[2], a[3]}'
done
@c7h
Copy link
Author

c7h commented Sep 6, 2018

Reads a 16 bit I2C portexpander like the PCF8575 and displays the result in bit representation.

$ ./read_portexpander.sh 
76543210 76543210
11111111 10011111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment