This project is the first step towards using the SPI with Onion Omega 2. It does not yet use SPI, only controls the shift register by simple GPIO commands.
-
Node JS (min. version: 4.0)
-
Install Onoff Node
opkg update
opkg install onoff-node
-
Upload the
index.js
file to your Omega 2. -
Run the Node application
node index.js
According to this wiring diagram.
- SN74HC595 data sheet
- Power dock spec
- Article on Bildr.org about the 74HC595
- Using the GPIOs on the Omega 2
- MediaTek MT7688 Datasheet
This is the next level using the shift register. This time we are controlling it with the Omega's SPI module.
-
Python
-
SPI Python Module
opkg update
opkg install python-light pyOnionSpi
- GPIO multiplexing setup properly
omega2-ctrl gpiomux set spi_cs1 spi_cs1
omega2-ctrl gpiomux set spi_s spi_s
# verifiy with the command below
omega2-ctrl gpiomux get
Note: You will not be able to use GPIO 6-9 as standard GPIOs until you set this back to GPIO mode. Read more here.
-
Upload the
index.py
file to your Omega 2. -
Run the Python application
python index.py
You will see the binary counter working (see the LEDs) and reading the last input back from the shift register (on the console).
According to this wiring diagram.
# Read the direction for pin 7
fast-gpio get-direction 7
# Read the value of pin 7
gpioctl get 7
# or
cat /sys/class/gpio/gpio7/value
# Set the value for pin 7 and the direction to `output`
fast-gpio set 7 0
# Read the multiplexing setup
omega2-ctrl gpiomux get