Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm working on an home automation system with the raspberry pi.

Currently I use python or C to control the GPIO and haskell/yesod for controlling everything from pc/ipad/phone... But I would like to control the GPIO without using python or C. So directly from haskell.

Is this possible?

Kind regards Joachim

share|improve this question

4 Answers 4

up vote 1 down vote accepted

One (very Unixy) approach would be to call a helper program (command) that can do the GPIO operations for you. That should be relatively easy in any language and doesn't need bindings beyond system(). The helper could be written in C, Python or something else and made to accept a few arguments for what you want done.

A more elaborate helper might run as a daemon and accept connections over sockets from programs wanting to manipulate GPIO. This may have more issues from security standpoint, but may also be better since GPIO access is already a bit hairy issue.

share|improve this answer
    
I was thinking about this approach. A C socket server that accepts something as input so it knows what to do. But i'm not familiar with c so I have to learn it first :) –  Joachim Jan 30 '13 at 10:15

If it is possible in haskell to use the GPIO through memory, I guess so, but I have never used haskell, but there are more ways to use the GPIO pins, for example the same way you can use them in a bash script, through the

/sys/class/gpio

device files on raspbian, there you can configure, read and write the individual pins. Not as elegant, and root privileges are required, but it works. Check this link for more info on using these files.

share|improve this answer
    
Thanks for the response I'll take a look at it after my exam on tuesday –  Joachim Jan 26 '13 at 8:57

It's a bit late for an answer, but you can use the HPi library for this. It currently supports manipulation of the GPIO pins and sending/receiving with the I2C protocol, all from the IO monad.

share|improve this answer

I just published this to hackage.

http://hackage.haskell.org/package/system-gpio-0.0.2

Feel free to try.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.