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 just orded my RPI a while ago (Haven't recieved it yet), and this is just completely out of curiosity, but will I be able to connect some sort of IR receiver, and get it's input in Node?
Or is this something I'll have to learn python for? I've read quite some articles about the RPI, and most of them seems to be using python...

Ps. I'm a JS-guy, and never tried python nor any GPIO related things at all.

share|improve this question
2  
At worst you could use fs library and write to proper files (as it's linux env). Check 'GPIO Driving Example (Bash shell script, using sysfs, part of the raspbian operating system)' section in following link: elinux.org/RPi_Low-level_peripherals –  Bartosz Dec 13 '12 at 12:37
add comment

4 Answers

up vote 6 down vote accepted

If you can program, you can pick up python amazingly quick and get useful stuff done almost right away. There is an impressive library of stuff available as well. But it shouldn't be absolutely required for any pi related work.

You can attach many sorts of IR receivers to a PI, from demodulating detectors (like used with TV remotes) on GPIO to somewhat specialized USB dongles and irda modules. What you use depends on what you're trying to receive. There are also less communication-oriented IR uses in e.g. PIR sensors, light beams, and raw "morse code" style flashers that are all accessible as well.

Which ever task you want to do, you should try to find a receiver that looks like a standard device of some sort to avoid having to hunt for drivers. A USB serial port type might be handy for the pi. There's a logic level UART on board (might not be avilable/easy for this) and you can get bot LL and EIA232 voltaged serial dongles for USB for more ports. These do your classic cellphone-laptop-printer style communications, not TV remote style.

For on-off signals, GPIO might be the way to go. It's harder to do fast signals with the roundabout way these are accessed in common operating systems. Accessing GPIO without breaking system security is another challenge.

How you get to these from Node, or js, is another matter. There may be a library/binding for accessing some devices. Others you can access through device files or by running some kind of middleman program (this might be a natural spot for Python) that will handle the device and that you can talk to from js.

If it all seems unfamiliar, think of this as some pointers and keywords to a lot of interesting reading :)

share|improve this answer
    
Thanks! Even though lot of the names seem a bit unfamiliar, but you answered my question about python :D –  Mobilpadde Dec 14 '12 at 13:46
add comment

I've just found out what could be the simpliest way to access gpio from node.js (note that I haven't tried it yet):

  • build libpigpio shared library as described here
  • use node-ffi to setup bindings to native library without having to write any extension code
share|improve this answer
    
I think I'll go with github.com/EnotionZ/GpiO instead... –  Mobilpadde Dec 19 '12 at 16:05
    
Aye, this talks directly to device files, like I suggested in my first comment on your question. –  Bartosz Dec 20 '12 at 9:31
1  
However, now when I recalled that you want input, I wonder how it performs in such situation, as it seems to generally be based on file watching (will probably incur some lags). –  Bartosz Dec 20 '12 at 10:02
    
Oh, I still haven't got my rpi yet... But I think I'll try both methods. :D –  Mobilpadde Dec 20 '12 at 13:27
add comment

Update on Feb 24th: I've finished and released two open source projects called lirc_node and lirc_web to facilitate getting NodeJS to work with LIRC. I've also written a blog post that describes how to set everything up. This helped me get my own web based universal remote project going, hopefully it helps someone else.

http://alexba.in/blog/2013/02/23/controlling-lirc-from-the-web/


You may want to look at the LIRC project (Linux Infrared Remote Control). It handles IR sending and receiving and gives you the ability to execute programs when certain IR commands are received using the irexec application. You could write a script in JS (Node) / Python / Ruby that gets called whenever a certain button on a remote is pressed.

The latest builds of Raspbian have a LIRC driver included by default. I've also written a guide to getting LIRC setup on your RaspberryPi in case you do want to check it out:

http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/

share|improve this answer
add comment

Would this be of any use?

https://github.com/fivdi/onoff

GPIO based I/O and interrupt detection with Node.js on Linux boards such as the BeagleBone or Raspberry Pi.

share|improve this answer
    
Hmm, it might... But I think I like this one a bit more github.com/EnotionZ/GpiO D: –  Mobilpadde Dec 19 '12 at 16:04
add comment

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.