Simple Python wrapper and demo
Boom! Works perfectly!
Just for newbies like me (@Dan-L correct me if I am wrong but this is working for me):
Make sure to nano and save pyhelper.py in this directory: /usr/lib/python2.7/importlib
change <from gpiohelper import GPIOHelper> to <from pyhelper import GPIOHelper>
FYI, I named your files the same as the first line with the hash
Thanks again, Dan!
I'm not really a Python coder myself so no idea if putting stuff in
/usr/bin/python2.7/importlibis best practice or not. But if it works it works!
@Dan-L I don't think it is best practice haha. Hopefully, someone will chime in and tell us where it goes. What did you end up doing with it?
I just had both files as:
Written directly with Nano
@Dan-L. : thanks for sharing.
how have you connected the LEDs? do you use any pull-up resistors or do you go directly from IO-pin to GND?
Thanks @Dan-L Will give the Arduino Dock a go tonight and maybe will manage to figure it out.
Basically connecting a GPIO pin to a 330ohm resister, then the resister to the LED (longer leg), then the LED to ground. For my example code though, I was using 6 LEDs with 6 resisters, with the ground pin of each chained together and linked to a single ground pin on my expansion dock.
I also set up a button using an Arduino guide I found here.
Nice one @Romans-Bermans!
@Romans-Bermans: thanks for the picture!
@Dan L.: thanks for the info & links!
Hey @Dan-L , finally got some components to play around with!
Although I'm getting the following error when trying to read the input of a button using your helper,
fast-gpio read 8works perfectly though, any ideas?
Traceback (most recent call last): File "script", line 19, in <module> button_input = helper.getPin(8) File "/root/first_script/gpiohelper.py", line 26, in getPin fd = open(self.pinDirectionPath.replace("$", str(pin)), 'w') IOError: [Errno 13] Permission denied: '/sys/class/gpio/gpio8/direction'
@Jamie-Street Know what? I have the same problem with pin 8. If you try a different pin does it work?
I also have trouble with pin 13, but it doesn't actually give errors, it just doesn't do anything.
BTW You can test easily with the command line too.
echo out > /sys/class/gpio/gpio5/direction
echo 1 > /sys/class/gpio/gpio5/value
echo in > /sys/class/gpio/gpio6/direction
Cheers for the heads up, upon inspection it looks like the
directionfile is missing for pin 8, pretty strange.. perhaps the helper should create the file if it doesn't already exist?
@Jamie-Street The helper doesn't specifically create those files individually, it triggers the export functionality. I'd say it's a bug with the Omega firmware...
@Dan-L @Romans-Bermans we're still working on the drivers for the Arduino Dock, its a little more complicated than we anticipated. Should be out soon tho!
As for pin 8, I'll be looking into that, we might have made it output only for some reason. I'll double check.
Thanks for the clear example.
Is there a reason I can't access pins 15-17 (extension board RGB led)?
I can update the values using (b)ash fast-gpio commands
root@Omega1:~# ls /sys/class/gpio/
export gpio1 gpio13 gpio18 gpio23 gpio6 gpio8 unexport gpio0 gpio12 gpio14 gpio19 gpio26 gpio7 gpiochip0
@Dan-L. Thank you for sharing that implementation.
I used your implementation, then added support for pin 8 ( via fast-gpio ). I also set it up so it could run on my mac in a simulated way.
Here is a link to a video showing it all work.
Steve Fister last edited by
@Romans-Bermans So for the pushbutton, how is that wired? It's hard to tell from the photo. It looks like the green leg is connected to 2V and the black leg is connected to RST? Please confirm. Thanks!
@Steve-Fister Probably not. Reading the code the button is connected to pin 26, the other side probably is connected to +5V. Although this might work, it is good practice to also connect a resistor (like 10kOhm) between pin 26 and ground, to ensure pin 26 is at 0V when the button is NOT pushed.
@Peter-Peters Logic voltage on the Omega is 2.8V. So the other side should be connected to 2.8V.