I'm wondering about accessing the GPIO of the Edison in high-level languages such as Python or Node.
So far I've found MRAA but wondered if there are other options?
I'm wondering about accessing the GPIO of the Edison in high-level languages such as Python or Node.
So far I've found MRAA but wondered if there are other options?
If you can access the gpio through the standard linux filesystem method it should be possible to write out the bash commands in Python using os.popen
e.g.
import os p = os.popen("echo 1 > /sys/class/gpio/export") p.close()
would export pin 1 of the gpio for use in the file system.
so once the pin is exported to the filesystem you would do
p = os.popen("echo out > /sys/class/gpio/gpio1/direction")
to set gpio pin 1 to be an output pin and then
p = os.popen("echo 1 > /sys/class/gpio/gpio1/value")
to set gpio pin 1 high
and
p = os.popen("echo 0 > /sys/class/gpio/gpio1/value")
to set that pin low.
This method should work for all devices that can access the gpio through the linux filesystem.
--------------------------
I should mention that you probably need to run the Python script with sudo or as root for this to work. If this is a problem for your project you can get around it by adding the user account to the gpio group
MRAA should be the way to go. Looks like they have Python interface.
Check out this link:
Getting Started With Intel Edison - Python Programming - All
I cannot wait to play with Python and Node on the Edison. Plans are to make that an early write up.
I was wondering if Firmata would work or how does the Arduino and Atom systems communicate?
Cheers Lucie, yes using the filesystem is always my fallback approach when I can't get something working.
According to the hardware guide you can even control PWM that way.
http://www.intel.com/content/dam/support/us/en/documents/edison/sb/edison-arduino-hardware-guide.pdf
I really hate the whole needing to run as root thing for GPIO access. It seems a common problem across different platforms, would be nice to see if it's solved on the Edison.
For my BeagleBone project I've resolved the problem with a C Daemon that listens on NamedPipes. That can run as root but the client apps can run as the user.
https://github.com/Workshopshed/musicController/blob/master/servoDaemon/servoDaemon.c
MRAA does seem like the natural choice given that it was provided by one of the competition sponsors. Libsoc could also be a possibility https://github.com/jackmitch/libsoc
Firmata does seem to be a possibilityhttps://github.com/rwaldron/galileo-io
I believe that in the Edison the Atom communicates to the hardware at the chip level so there's NO serial communication like in the Yún.
try using
useradd -G {group-name} username
in a terminal to add the user account to the gpio group, doing this will allow the user account to work with gpio without needing sudo etc.. it took me a while to work it out but its obvious when the group is there ready and waiting to add users to it. There's usually groups for i2c spi etc..
just type "groups" into a terminal to see which groups are available
mcb1 can you test this on your Edison?
You'd need to be root for the following:
echo 1 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio1/direction
But can you run the following as a regular user?
echo 1 > /sys/class/gpio/gpio1/value
This article suggests you'd need to be root to run things that access MRAA
if you add the user account to the gpio group you can do export, direction, value and anything else available as a regular user. I add the www-data user to the group to allow webserver software to interact with gpio for control over network.
Andy
Your request worked right up until doing it as a normal user ...I'm going to need to do soem searching for that.
So I picked GPIO 48, as it wasn't PWM and already set by the Arduino sketch that was trying to run.
root@MyEdison:/sys/class/gpio# echo 48 > export root@MyEdison:/sys/class/gpio# cd gpio48 root@MyEdison:/sys/class/gpio/gpio48# ls active_low device direction edge power subsystem uevent value root@MyEdison:/sys/class/gpio/gpio48# echo out > direction root@MyEdison:/sys/class/gpio/gpio48# cat direction out root@MyEdison:/sys/class/gpio/gpio48# echo 1 > value root@MyEdison:/sys/class/gpio/gpio48# echo 0 > value root@MyEdison:/sys/class/gpio/gpio48#
I followed the Sparkfun guide (to try to understand what your were trying to achieve )
https://learn.sparkfun.com/tutorials/sparkfun-blocks-for-intel-edison---gpio-block
I found a few other references.
https://communities.intel.com/thread/57506
they are linking to this document
https://emutex.com/emutexlabs/76-intel-edison-gpio-pin-multiplexing-guide
https://communities.intel.com/thread/81616
https://communities.intel.com/thread/53340
Sounds like you should be our technical assistant
Perhaps jwatson can send you one so you can help with the difficult queries.
Mark
There's an article here that is worth reading (the second part) if you want to detect pin changes.
https://www.linux.com/learn/intro-to-Linux/2017/3/intel-edison-linux-maker-machine-matchbox
Mark