Reading a GPIO
Omega Tip of the Week:
Reading a GPIO Value
The Omega2 has twelve digital General-Purpose Input/Output pins (commonly referred to as GPIOs) that can be fully controlled by you, the user. Your project may require the Omega to read sensors, signals, and other inputs attached to the GPIOs, so we’ve included the gpioctl program on the Omega to help make it easy!
The Omega can read either HIGH (3.3V) or LOW (0V) signals. Let’s try this out with an Omega, an Expansion Dock, and a male-to-male jumper wire.
First, set GPIO1 to input so we can read it:
gpioctl dirin 1
Now let’s try reading a LOW signal. Connect the wire from GPIO1 to one of the GND pins. Then run:
gpioctl get 1
You should see the following:
Now let’s try reading a HIGH signal. Remove the end of the wire connected to the GND pin and connect it to the 3.3V pin instead. Then run the command again:
gpioctl get 1
You should now see:
To use this in a program, try using the Onion GPIO Python module.
And that’s it!
Let us know what kind of stuff you would like to see featured on 2–Bullet Tuesday! Send a tweet to @OnionIoT with your suggestions!
Thanks for reading! Have a great week!
P.S. — Our Omega2 Indiegogo campaign will be ending in the near future! Don’t miss your chance to get the Omega2 for just $5!
P.P.S — We’re shipping packages on a daily basis! If you haven’t gotten yours yet, sit tight!