Message Boards Message Boards

0
|
13781 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Anyone driven the GPIO pins of the Raspberry Pi B+ model

Posted 10 years ago

The documentation for DeviceWrite["GPIO" .. still seems exclusively for the 26 pin header of the B version. Has anyone successfully driven the pins of the new 40-pin B+ header from Wolfram?

POSTED BY: David Keith
7 Replies

I wasn't familiar with that library; will have to check it out.

POSTED BY: BoB LeSuer
Posted 10 years ago

Thanks, Bob. I'm having no trouble driving the pins and the SPI using the C library at airspayce.com. (It's a really nice library.) Also OK with Python. I only have problems from Wolfram.

POSTED BY: David Keith

I've had luck compiling wiringPi libraries using WolframLink. Granted, this is with the model B; however, the WiringPi libraries have been updated for B+ and therefore this method should be viable.

POSTED BY: BoB LeSuer
Posted 10 years ago

Hello again, Arnoud. I have been trying to access the B+ GPIO with the code you suggest above, but without success. I can write to GPIO13 using c code found at http://guillermoamaral.com/read/rpi-gpio-c-sysfs/ and it works fine. I believe it is using the same OS calls as are being called from your code. With the c code, I can write to GPIO13 in a loop and see the waveform on a scope. With the Wofram code I get nothing.

I have tried the wolfram code both by typing it in, and by executing as a script using "sudo wolfram -script myscript.wl" -- nothing happens.

Any ideas?

Best, David

POSTED BY: David Keith
Posted 10 years ago

I can also toggle GPIO13 by echoing to the sysfs class files from the command line. But with the same setup, WL does not toggle the pin, either within "sudo wolfram" or withing wolfram executed under a "sudo -i" root user session.

POSTED BY: David Keith
Posted 10 years ago
POSTED BY: David Keith

We have not yet added support for this in the device functions (DeviceConfigure/DeviceRead/DeviceWrite), but this will be supported.

But it is possible to do this yourself as well, and it isn't very difficult.

Remember to launch the Wolfram Language as root (i.e.: sudo wolfram), because the GPIO modifications require root level access:

gpioExport[n_Integer] := Put[n, "/sys/class/gpio/export"]
gpioDirection[n_Integer, dir_] :=  Put[dir, "/sys/class/gpio/gpio" <> ToString[n] <> "/direction"]
gpioValue[n_Integer, val_] :=  Put[val, "/sys/class/gpio/gpio" <> ToString[n] <> "/value"]

And then, for example, this will turn on an LED if it is properly hooked up to GPIO13:

gpioExport[13]
gpioDirection[13,out]
gpioValue[13,1]
POSTED BY: Arnoud Buzing
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract