Skip to content

Instantly share code, notes, and snippets.

@remybach remybach/
Last active Aug 29, 2015

What would you like to do?
Raspberry Pi 2 + ADC + Sharp IR Distance Sensor

When I run this with sudo node ir.js I get the following output:

1427574353828 Device(s) undefined
1427574353869 Connected RaspberryPi-IO
1427574353892 Repl Initialized
>> /home/pi/ir_test/node_modules/raspi-io/node_modules/raspi-board/lib/index.js:375
  alias = alias.toString();
TypeError: Cannot read property 'toString' of undefined
    at getPinNumber (/home/pi/ir_test/node_modules/raspi-io/node_modules/raspi-board/lib/index.js:375:16)
    at Raspi.normalize (/home/pi/ir_test/node_modules/raspi-io/lib/index.js:290:31)
    at Raspi.pinMode (/home/pi/ir_test/node_modules/raspi-io/lib/index.js:315:34)
    at Distance.Sensor (/home/pi/ir_test/node_modules/johnny-five/lib/sensor.js:61:11)
    at Distance.Controllers.GP2Y0A21YK.initialize.value (/home/pi/ir_test/node_modules/johnny-five/lib/distance.js:17:16)
    at new Distance (/home/pi/ir_test/node_modules/johnny-five/lib/distance.js:155:10)
    at new module.exports.IR.Proximity (/home/pi/ir_test/node_modules/johnny-five/lib/johnny-five.js:83:12)
    at Board.<anonymous> (/home/pi/ir_test/ir.js:9:19)
    at Board.emit (events.js:104:17)
    at process._tickDomainCallback (node.js:381:11)

... as far as I could track down it has something to do with trying to figure out which pin it needs to use (I think?). This is why I thought I was missing something that documentation might point me in the direction of (since I'm specifying the address instead of the pin which seemed to be an acceptable thing to do).

var raspi = require('raspi-io'),
five = require('johnny-five'),
board = new five.Board({
io: new raspi()
board.on('ready', function() {
var proximity = new five.IR.Proximity({
address: '0x68',
controller: '2Y0A21'
proximity.on('data', function() {
console.log('cm: ',;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.