Coder Social home page Coder Social logo

raspi-io's Introduction

Raspi IO

NOTE: This project is in maintenance mode and no longer actively maintained.

Gitter

Raspi IO is an I/O plugin for the Johnny-Five Node.js robotics platform that enables Johnny-Five to control the hardware on a Raspberry Pi. The API docs for this module can be found on the Johnny-Five I/O Plugin specification page, except for the constructor which is documented below. Raspi IO supports all models of the Raspberry Pi, except for the Model A and compute modules.

If you have a bug report, feature request, or wish to contribute code, please be sure to check out the Contributing Guide.

System Requirements

  • Raspberry Pi Model B Rev 1 or newer (sorry Model A users), except compute modules
  • Raspbian Jessie or newer
    • Node-RED works, but can be finicky and difficult to debug.
    • See #24 for more info about support for other OSes
  • Node 6.4.0 or newer

Detailed instructions for getting a Raspberry Pi ready for NodeBots, including how to install Node.js, can be found in the wiki

Warning: this module must be installed as a normal user, but run as the root user

Installation

Install with npm on a Raspberry Pi (not a laptop):

npm install raspi-io

Note: You must reboot your Raspberry Pi the first time you install Raspi IO on it!

Usage

Using Raspi IO inside of Johnny-Five is fairly straightforward, although does take an extra step compared to using Johnny-Five on the Arduino Uno:

const Raspi = require('raspi-io').RaspiIO;
const five = require('johnny-five');
const board = new five.Board({
  io: new Raspi()
});

board.on('ready', () => {

  // Create an Led on pin 7 (GPIO4) on P1 and strobe it on/off
  // Optionally set the speed; defaults to 100ms
  (new five.Led('P1-7')).strobe();

});

Then, run your code with:

sudo node index.js

The io property must be specified explicitly to differentiate from trying to control, say, an Arduino Uno that is plugged into the Raspberry Pi. Note that we specify the pin as "P1-7", not 7. See the section on pins below for an explanation of the pin numbering scheme on the Raspberry Pi, which can be a bit confusing.

Warning: this module must be run as root, even though it cannot be installed as root.

Note: This module is not intended to be used directly. If you do not want to use Johnny-Five, I recommend taking a look at Raspi.js, which underpins this library and is a little more straight-forward to use than using Raspi IO directly.

Important Notes

Pin Naming

The pins on the Raspberry Pi are a little complicated. There are multiple headers on some Raspberry Pis with extra pins, and the pin numbers are not consistent between Raspberry Pi board versions.

To help make it easier, you can specify pins in three ways. The first is to specify the pin by function, e.g. 'GPIO18'. The second way is to specify by pin number, which is specified in the form "P[header]-[pin]", e.g. 'P1-7'. The final way is specify the Wiring Pi virtual pin number, e.g. 7. If you specify a number instead of a string, it is assumed to be a Wiring Pi number.

Be sure to read the full list of pins on the supported models of the Raspberry Pi.

I2C notes

There are a few limitations and extra steps to be aware of when using I2C on the Raspberry Pi.

First, note that the I2C pins can only be used for I2C with Raspi IO, even though they are capable of GPIO at the hardware level.

Also note that you will need to edit /boot/config.txt in order to change the I2C baud rate from the default, if you need to. If you notice that behavior is unstable while trying to communicate with another microcontroller, try setting the baudrate to 10000 from the default 100000. This instability has been observed on the Arduino Nano before.

After you install Raspi IO for the first time, you must reboot your Raspberry Pi. I2C support is not enabled by default, and this module runs a script to enable it automatically and adjust a few I2C settings. These settings will not take effect until you reboot your Pi.

Finally, if you try to access a device that doesn't exist, you will get an error stating EIO, i/o error (sorry it's not very descriptive, but it comes from the operating system and I can't change it).

Serial notes

There are also a few limtations and extra steps to be aware of when using Serial (UART) on the Raspberry Pi.

As with I2C, the serial pins can only be used for serial with Raspi IO, even though they are capable of GPIO at the hardware level.

If you are not running a Raspberry Pi without WiFi:

All older versions of the Raspberry Pi enable a TTY console over serial, meaning that you can use the screen command on *NIX computers to log in to the Raspberry Pi over serial. This can get in the way of using the serial port for robotics, however. To disable TTY over serial, do the following:

  1. Run sudo raspi-config to start the Raspberry Pi configuration utility
  2. Select 5 Interface Options
  3. Select P6 Serial Options
  4. Select No when asked Would you like a login shell to be accessible over serial?
  5. Select Yes when asked Would you like the serial port hardware to be enabled?
  6. Select OK
  7. Select Finish and select Yes to reboot when prompted

WARNING: If you are running a Raspberry Pi with WiFi:

The Bluetooth module on these Raspberry Pis is controlled using the serial port, meaning it cannot be used directly while also using Bluetooth. Using this module with the default serial port will disable bluetooth!

For an in-depth discussion on why and how to work around it, read https://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3.

API

new RaspiIO(options)

Instantiates a new Raspi IO instance with the given options

Arguments:

Argument Type Description
options (optional) Object The configuration options.
Property Type Description
enableSerial (optional) boolean Enables the use of the serial port by Johnny-Five. The default is true, except on models with Bluetooth where it is false (currently the Raspberry Pi 3 Model B, Raspberry Pi 3 Model B+, and Raspbery Pi Zero W)
enableI2C (optional) boolean Enables the use of the I2C port by Johnny-Five. The default is true
includePins (optional) Array<Number|String> A list of pins to include in initialization. If specified, any pins not listed here will not be initialized or available for use by Raspi IO. If not specified, all pins will be available for use by Raspi IO.
excludePins (optional) Array<Number|String> A list of pins to exclude from initialization. If specified, any pins listed here will not be initialized or available for use by Raspi IO. If not specified, all pins will be available for use by Raspi IO.

License

The MIT License (MIT)

Copyright (c) 2014-2017 Bryan Hughes [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

raspi-io's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspi-io's Issues

Allow GPIO exclusions

I'm writing an Arduino/Raspberry Pi/Lego blog (www.internetoflego.com) and was going to include some of your work. As I was testing a project, I realized that I have a major conflict and was hoping you could point me in the right direction.

Setup:
Raspberry Pi v2
Johnny-Five
LIRC for Lego IR Power Functions control
https://github.com/dspinellis/lego-power-scratch
My Code (still needs tested)
https://gist.github.com/dexterlabora/49ab4509ca4ef5edc8fd

The issue I am having is that in order to use the LIRC infrared driver/commands directly from Linux, pins 22 & 23 are reserved for this service. As I try to run a J5 app, I'm getting the following error, likely because the pins are already in use.
(Error: Pin "22" does not support mode "2").

I had a look through the index.js file, and assume I could write some code to bypass the initialization of these pins, but before I go down that rabbit hole, I was hoping you could guide me on this. I want a clean (less hacky) way of doing this as I write my instructional blog for the general public. Currently, I have to use the Rasp Pi for only the LIRC functions and all other GPIO related stuff on an Arduino. This works, but obviously I'm limiting my self here and requiring two controller boards.

Thanks for you help and the work you've done so far. I will be sure to credit you in the blog post!

~~ Console Error ~~

1442855141613 Device(s) RaspberryPi-IO

1442855141665 Connected RaspberryPi-IO

1442855141681 Repl Initialized

Error: Pin "22" does not support mode "2"

at Raspi.pinMode (/root/IoL/node_modules/raspi-io/lib/index.js:345:17)

at new Sensor (/root/IoL/node_modules/johnny-five/lib/sensor.js:79:11)

at new module.exports.Digital (/root/IoL/node_modules/johnny-five/lib/johnny-five.js:87:10)

at Board.<anonymous> (/root/IoL/citystation.js:32:28)

at Board.emit (events.js:92:17)

at process._tickCallback (node.js:448:13)

Thanks again,

Cory

www.InternetOfLego.com

After power up,' board.io.pins[2].mode' returns 99, used to return 0.

The change has broken Xi. Is it possible to restore the initial value to 0?
Also, after starting raspi-io, am I assured that the mode for all pins will be the same value (hopefully 0).
I need a consistent mode value in board.io.pins so that I can determine if a Xi user has already assigned a pin mode to the pin. For the Arduino and BeagleBone Black, consistent values are returned.

Thanks.

raspi-pwm REPLACE_INVALID_UTF8 when installing

Steps:

  1. On a brand new Jessie install npm
  2. npm install raspi-io

Versions:
HW: Pi B
OS: Jessie
node -v v0.10.29
node-gyp -v v0.12.2
npm -v 1.4.21

Error:

[email protected] install /home/pi/node_modules/raspi-io/node_modules/raspi-pwm
node-gyp rebuild

make: Entering directory '/home/pi/node_modules/raspi-io/node_modules/raspi-pwm/build'
CXX(target) Release/obj.target/addon/src/addon.o
In file included from ../src/addon.cc:26:0:
../node_modules/nan/nan.h:328:47: error: β€˜REPLACE_INVALID_UTF8’ is not a member of β€˜v8::String’
static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
^
addon.target.mk:84: recipe for target 'Release/obj.target/addon/src/addon.o' failed
make: *** [Release/obj.target/addon/src/addon.o] Error 1
make: Leaving directory '/home/pi/node_modules/raspi-io/node_modules/raspi-pwm/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.1.13+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/node_modules/raspi-io/node_modules/raspi-pwm
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

Data bug with GY-273

This compass always reports west facing directions. At a quick glance, it looks like we're not getting numbers below 128, so I'm guessing there's a signed math bug somewhere.

Exceptions when opening up a RPi 2 Session

I have user that is now able to run on the B+ with no issues, but when he tries to open up a RPI2 session he gets the following:

module.js:340
throw err;
^
Error: Cannot find module 'es6-shim'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/pi/xipi/node_modules/johnny-five/lib/johnny-five.js:1:63)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17

Since I don't own an RPi2, I am unable to investigate.

Does the user need to do an npm install of es6-shim?

[Rpi B+] Pin "GPIO13" does not support mode "3" (PWM)

Hi, recently i have bought a Pololu Dual MC33926 Motor Driver for Raspberry Pi. (https://www.pololu.com/product/2755)

The problem is that when i want to set the speed of second motor (in the link provided above there are instructions that I am supposed to use GPIO13 to set its speed )all i get is
Pin "GPIO13" does not support mode "3"
The error occurs whenever I try to set it to PWM mode.
board.pinMode("GPIO13", five.Pin.PWM);
However, there was a python library provided for the driver i'm using, so I had to try and check if it's working properly. And it is - https://github.com/pololu/dual-mc33926-motor-driver-rpi . When i run the example script all motors are working properly. They are setting the GPIO13 into PWM with

wiringpi2.pinMode(13, wiringpi2.GPIO.PWM_OUTPUT)
So I wonder what is the problem and how to solve it. I prefer using JS over Python and I don't know the mechanics behind the raspi-io or the python library mentioned above, so i thought ill post it as an issue here.

Thanks in advance!

My config:
Raspberry Pi B+ rev 02
2016-02-26-raspbian-jessie
node v0.10.29
gpio version: 2.31

Troubles when using hypriot images and docker

Im trying to use Johnny Five as a base for my project. We are going to have a lot of raspberry Pi's so its also based on using docker with raspbian pi, by using the images from http://blog.hypriot.com/.

Unfortunalty raspi-io doesnt work even if i use an image with wiringPi and everything inside.
Its worth telling that using raspi and raspi-gpio inside the same image and top of the same stack, works perfectly. I have gotten my led to light up with these libraries.

But when i use JohnnyFive and raspi-io i recieve this error:

root@3c17965c9979:/home/johnny# node test.js 
libkmod: ERROR ../libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file '/lib/modules/3.18.11-hypriotos+/modules.dep.bin'
child_process.js:1382
    throw err;
          ^
Error: Command failed: modprobe i2c-dev
libkmod: ERROR ../libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file '/lib/modules/3.18.11-hypriotos+/modules.dep.bin'

    at checkExecSyncError (child_process.js:1339:13)
    at execSync (child_process.js:1379:13)
    at new I2C (/home/johnny/node_modules/raspi-io/node_modules/raspi-i2c/lib/index.js:116:5)
    at /home/johnny/node_modules/raspi-io/lib/index.js:147:16
    at new Raspi (/home/johnny/node_modules/raspi-io/lib/index.js:182:7)
    at Object.<anonymous> (/home/johnny/test.js:4:7)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

My Johnny-Five code is:

var five = require("johnny-five");
var Raspi = require("raspi-io");
var board = new five.Board({
  io: new Raspi()
});

board.on("ready", function() {
  var led = new five.Led("P1-11");
  led.blink();
});

And my working raspi code is:

var raspi = require('raspi');
var gpio = require('raspi-gpio');

raspi.init(function() {
  var output = new gpio.DigitalOutput('P1-11');

  output.write(0);
});

If there is anything more I can do to aid let me know. The reason we are using Johnny-Five is because we are going to have more different modules and want to try to keep the codebase very similar.

servo.sweep() only ranges about 90 degrees

Not sure if this is an issue with my hardware, raspi-io or johnny-five:

I have a servo attached to a Raspberry Pi Zero with the latest Raspbian Jessie image.
When I run Python scripts I can make the servo traval its ~180 degrees, up to the mechanical limits.
But with Johnny-Five or Raspi-io I only get about 90 degrees of sweep motion.

The servo is attached in both attempts to the RPi 5V&GND.

When I attach the same servo (I have actually 2 with the same behaviour) to an Arduino with StandardFirmataPlus, I get about 170 degrees of motion.

How can I influence the range of a servo, ideally I'd get 175 degrees. This is my first project in Node.js and I'd like to do this not with Python -- but I really need as close to 180 degrees as possible (rising marbles with a wheel).

Here is the stripped-down code:

var five = require("johnny-five");
var Raspi = require("raspi-io");

var board = new five.Board({
  io: new Raspi()
});

board.on("ready", function() {

  // board.pinMode("P1-32", five.Pin.SERVO);

  var servo = new five.Servo({
    pin: "P1-32",
    type: "standard",
    range: [0, 180],
    startAt: 90
  });

  this.repl.inject({
    board: board,
    servo: servo,
  });

});

And a quick video: https://youtu.be/x54wt5BWxC4

node --version

v4.2.4

uname -a

Linux raspberrypi 4.4.0-rc5+ #10 PREEMPT Thu Dec 24 22:52:14 EST 2015 armv6l GNU/Linux

cat /etc/os-release

PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"

cat /proc/cpuinfo

processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
...
Hardware : BCM2708
Revision : 900092

Reading back board.io.pins mode after setting the mode does not reflect proper mode

In my application I am setting a pin pin mode with: board.pinMode(pin, five.Pin.OUTPUT);

Before I go to do a digital write, I check the to make sure that the pin mode was set to output, before committing the write. I do so by checking the board.pin mode. In previous releases (I am not sure when this broke) this worked, but apparently, the pin mode is no longer being reflected properly.

I do this for all pins and modes, and the mode does not seem to be set.

I am using the latest and greatest and j5 and raspi-io (updated today). The code works fine for Arduino and BeagleBone Black, but no longer works on RPi.

Default LED seems to be broken.

Getting the board LED to flash with J5 is supposed to work with the following code, but currently doesn't:

var five = require("johnny-five");
var raspi = require("raspi-io");
var board = new five.Board({
  io: new raspi()
});

board.on("ready", function() {
  var led = new five.Led();
  led.blink(500);
});

However, it works when using Raspi.js:

var raspi = require('raspi');
var led = require('raspi-led');

raspi.init(function() {
  var statusLed = new led.LED();

  // Flash the LED twice a second
  setInterval(function() {
    if (statusLed.read() == led.ON) {
      statusLed.write(led.OFF); // Turn off the status LED
    } else {
      statusLed.write(led.ON); // Turn on the status LED
    }
  }, 100);
});

This leads me to suspect that the default LED property isn't being exposed correctly in raspi-io

Cannot run PWM0 and PWM1 Concurrently

When running


var raspi = require('raspi-io');
var io = new raspi();
io.on('ready', function() {
 var servo = 24;
 var servo2 = 26;

 this.pinMode(servo, io.MODES.PWM);
 this.pinMode(servo2, io.MODES.PWM); 

 this.analogWrite(servo, 255);
  this.analogWrite(servo2, 255);
});

I get

/home/pi/raspi/node_modules/raspi-io/node_modules/raspi-pwm/lib/index.js:19
      throw new Error('Attempted to write to a destroyed peripheral');
            ^
Error: Attempted to write to a destroyed peripheral
    at PWM.write (/home/pi/raspi/node_modules/raspi-io/node_modules/raspi-pwm/lib/index.js:19:13)
    at Raspi.Object.defineProperty.value [as analogWrite] (/home/pi/raspi/node_modules/raspi-io/lib/index.js:307:28)
    at Raspi.<anonymous> (/home/pi/raspi/test.js:8:7)
    at Raspi.emit (events.js:92:17)
    at /home/pi/raspi/node_modules/raspi-io/lib/index.js:237:10

``

Install failiure

I am trying into npm install raspi-io but getting the following error warnings when I run sudo npm install raspi-io --save

Raspberry Pi: Jessie
Node: 4.2.1
NPM: 3.5.1

[email protected] install /var/www/html/raspberry-js/node_modules/raspi-gpio
node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.2.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/www/html/raspberry-js/node_modules/raspi-gpio/.node-gyp"
make: Entering directory '/var/www/html/raspberry-js/node_modules/raspi-gpio/build'
CXX(target) Release/obj.target/addon/src/addon.o
CXX(target) Release/obj.target/addon/src/init.o
../src/init.cc:27:22: fatal error: wiringPi.h: No such file or directory
#include <wiringPi.h>
^
compilation terminated.
addon.target.mk:91: recipe for target 'Release/obj.target/addon/src/init.o' failed
make: *** [Release/obj.target/addon/src/init.o] Error 1
make: Leaving directory '/var/www/html/raspberry-js/node_modules/raspi-gpio/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.13+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/html/raspberry-js/node_modules/raspi-gpio
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.2.0
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Linux 4.1.13+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "raspi-io" "--save"
npm ERR! node v4.2.1
npm ERR! npm v3.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the raspi-gpio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs raspi-gpio
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls raspi-gpio
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/raspberry-js/npm-debug.log

Trying to access ACT LED on raspi 2B

Hi,

I'm trying to get the ACT LED on my Raspberry Pi 2B to blink. Everything I've read mentions the ACT LED being controlled via GPIO pin 47, and I've set the ACT LED to trigger on gpio using the following command:

echo gpio | sudo tee /sys/class/leds/led0/trigger

Then if I echo 1/0 to its brightness it turns on and off as expected.
Now I'm trying to use the following code to start the blinking:

var five = require("johnny-five");
var Raspi = require("raspi-io");
var board = new five.Board({
  io: new Raspi()
});

board.on("ready", function() {
  var led = new five.Led("GPIO47");
  led.strobe();
});

But raspi throws an error:

>> /home/pi/robo-interface/node_modules/raspi-io/lib/index.js:297
        throw new Error('Unknown pin "' + pin + '"');
              ^
Error: Unknown pin "null"
    at Raspi.value (/home/pi/robo-interface/node_modules/raspi-io/lib/index.js:297:15)
    at Raspi.value (/home/pi/robo-interface/node_modules/raspi-io/lib/index.js:315:45)
    at Raspi.pinMode (/home/pi/robo-interface/node_modules/raspi-io/lib/index.js:304:21)
    at Led.Controllers.DEFAULT.initialize.value (/home/pi/robo-interface/node_modules/johnny-five/lib/led/led.js:71:17)
    at new Led (/home/pi/robo-interface/node_modules/johnny-five/lib/led/led.js:185:10)
    at Board.<anonymous> (/home/pi/robo-interface/robo.js:10:13)
    at Board.emit (events.js:129:20)
    at process._tickDomainCallback (node.js:381:11)

Is it just impossible to access this pin using raspi? Please let me know if I'm doing something wrong.

support pi A+

right now the version isn't recognized and it errors on launch

PWM works but Servo does not

I am using Wiring PIN 1 and I can control an LED via PWM. When I try using PIN 1 for Servo,
I get the console dump below.

The line of code in my application that stimulates the dump is:
board.pinMode(pin, five.Pin.SERVO);

BTW, I do something similar for PWM and no problems there ;-).

The code works without issue for both Arduino and BeagleBone Black

/home/pi/xipi/node_modules/raspi-io/lib/index.js:227
      throw new Error('Unknown pin "' + pin + '"');
            ^
Error: Unknown pin "undefined"
    at Raspi.Object.defineProperty.value [as __$271828_5$__] (/home/pi/xipi/node_modules/raspi-io/lib/index.js:227:13)
    at Raspi.Object.defineProperty.value [as pinMode] (/home/pi/xipi/node_modules/raspi-io/lib/index.js:236:43)
    at Servo.Controllers.Standard.initialize.value (/home/pi/xipi/node_modules/johnny-five/lib/servo.js:87:19)
    at new Servo (/home/pi/xipi/node_modules/johnny-five/lib/servo.js:150:8)
    at addServo (/home/pi/xipi/xiserver.js:819:21)
    at WebSocketConnection.<anonymous> (/home/pi/xipi/xiserver.js:287:25)
    at WebSocketConnection.emit (events.js:95:17)
    at WebSocketConnection.processFrame (/home/pi/xipi/node_modules/websocket/lib/WebSocketConnection.js:403:26)
    at WebSocketConnection.handleSocketData (/home/pi/xipi/node_modules/websocket/lib/WebSocketConnection.js:247:14)
    at Socket.emit (events.js:95:17)

Upgrade to NAN2

We need NAN2 in order to get raspi-io to work on Node 4.

One thing to note is that, practically speaking, we need Raspbian Jesse for this due to the hard dependency on gcc 4.8. It is possible to install gcc 4.8 in wheezy alongside 4.6, but this provides a pretty high barrier to entry for people that we should avoid, in my opinion.

Part of this upgrade should be to add friendly error messages when attempting to install on wheezy.

It is also possible that NAN1 is the reason for rwaldron/johnny-five#920. Either way, that issue will hopefully be resolved once the upgrade to NAN2 is complete.

Something to consider in the process: should this cause the bump to raspi-io 5 or raspi-io 4.1? Would this be considered a breaking change?

Cannot find '../build/Release/addon'

I have a few moving parts here so bear with me... I get this error when trying to run the basic example:

root@281e58f4e6b1:/srv/pi-led-test# node led.js
module.js:338
    throw err;
    ^

Error: Cannot find module '../build/Release/addon'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/srv/pi-led-test/node_modules/raspi-io/node_modules/raspi/lib/index.js:30:29)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

I'm running this using raspi-io v5.0.0 with node v4.1.2 on a Pi Zero, inside a docker container. The OS is 4.1.12-hypriotos+, which is basically a custom Raspbian Jessie build.

The funny thing is, I managed to install all the dependencies successfully. The only thing that had a soft failure to compile natively is execSync, but the whole process was fine. The error is below.

...
npm info install [email protected]

> [email protected] install /srv/pi-led-test/node_modules/raspi-io/node_modules/raspi-i2c/node_modules/execSync
> node install.js

[execsync v1.0.2] Attempting to compile native extensions.
[execSync v1.0.2]
    Native code compile failed!!
npm info postinstall [email protected]
...

If anyone has any ideas, I'd greatly appreciate some direction.

npm install raspi-io not working anymore

Here is the output of the command. I 'm using a Raspberry Model B


root@raspberrypi:~# npm install --save raspi-io
-
> [email protected] install /root/node_modules/raspi-io/node_modules/raspi-core/node_modules/raspi-wiringpi
> sh install-wiringpi.sh

Installing I2C tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
libi2c-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

Downloading Wiring Pi...

install-wiringpi.sh: 35: install-wiringpi.sh: git: not found
install-wiringpi.sh: 36: cd: can't cd to wiringPi

Building Wiring Pi. You may be asked for your root password.

sudo: ./build: command not found

> [email protected] install /root/node_modules/raspi-io/node_modules/raspi-pwm
> node-gyp rebuild

make: Entering directory '/root/node_modules/raspi-io/node_modules/raspi-pwm/build'
  CXX(target) Release/obj.target/addon/src/addon.o
  CXX(target) Release/obj.target/addon/src/init.o
../src/init.cc:27:22: fatal error: wiringPi.h: No such file or directory
compilation terminated.
addon.target.mk:84: recipe for target 'Release/obj.target/addon/src/init.o' failed
make: *** [Release/obj.target/addon/src/init.o] Error 1
make: Leaving directory '/root/node_modules/raspi-io/node_modules/raspi-pwm/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.12.28+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/raspi-io/node_modules/raspi-pwm
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

> [email protected] install /root/node_modules/raspi-io/node_modules/raspi-gpio
> node-gyp rebuild

make: Entering directory '/root/node_modules/raspi-io/node_modules/raspi-gpio/build'
  CXX(target) Release/obj.target/addon/src/addon.o
  CXX(target) Release/obj.target/addon/src/init.o
../src/init.cc:27:22: fatal error: wiringPi.h: No such file or directory
compilation terminated.
addon.target.mk:85: recipe for target 'Release/obj.target/addon/src/init.o' failed
make: *** [Release/obj.target/addon/src/init.o] Error 1
make: Leaving directory '/root/node_modules/raspi-io/node_modules/raspi-gpio/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.12.28+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/raspi-io/node_modules/raspi-gpio
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

> [email protected] install /root/node_modules/raspi-io/node_modules/raspi-core
> node-gyp rebuild

make: Entering directory '/root/node_modules/raspi-io/node_modules/raspi-core/build'
  CXX(target) Release/obj.target/addon/src/addon.o
  CXX(target) Release/obj.target/addon/src/init.o
../src/init.cc:25:22: fatal error: wiringPi.h: No such file or directory
compilation terminated.
addon.target.mk:83: recipe for target 'Release/obj.target/addon/src/init.o' failed
make: *** [Release/obj.target/addon/src/init.o] Error 1
make: Leaving directory '/root/node_modules/raspi-io/node_modules/raspi-core/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.12.28+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/raspi-io/node_modules/raspi-core
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the raspi-pwm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls raspi-pwm
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.12.28+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "raspi-io"
npm ERR! cwd /root
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

Trying to get Ultimate GPS HAT working

So I have an Ultimate GPS HAT hooked up to a Raspberry Pi (v2 Model B). I'm able to get raw sensor data following Adafruit's guide, however, I can't seem to figure out how to hook it up with Johnny-Five.

According to the Adafruit guide:

"The Ultimate GPS uses the following GPIO pins: TXD RXD #4 and EEDATA/EECLK".

So I'm wondering how I can hook this all up??

Here's my sample app for reference:

var five = require('johnny-five'); // dtex/johnny-five#gps
var Raspi = require('raspi-io');
var board = new five.Board({
  io: new Raspi()
});

board.on('ready', function() {

  var gps = new five.GPS(['4', '4']);
  gps.on('change', function(data) {
    console.log(data);
  });

});

And when I run that, I get the following:

TypeError: Cannot read property 'SW_SERIAL0' of undefined

Any help would be much appreciated! Thanks.

Module Extension Error

Hi,
I had installed the package regular, but when I'm trying to use it with the example Code from the repository:

var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
  io: new raspi()
});

board.on('ready', function() {

  // Create an Led on pin 7 (GPIO4) on P1 and strobe it on/off
  // Optionally set the speed; defaults to 100ms
  (new five.Led('P1-7')).strobe();

});

I get the following error every time:

module.js:356
  Module._extensions[extension](this, filename);
                               ^
Error: /home/pi/nestor/node_modules/raspi/build/Release/addon.node: undefined symbol: node_module_register
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/pi/nestor/node_modules/raspi/lib/index.js:30:29)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

I run the script as sudo and node is in version 6.2.2 and gcc in version 4.9.2 on a Raspberry Pi 2 B+ with Raspbian 4.9.2 installed. Do you have an idea why this is happening and how I can fix it?

ENOENT: no such file or directory, open \'/sys/class/leds/led0/trigger\

I'm running an application inside docker on a raspberry pi 3, and I get the following error:

Error: ENOENT: no such file or directory, open '/sys/class/leds/led0/trigger'
    at Error (native)
    at Object.fs.openSync (fs.js:546:18)
    at Object.fs.writeFileSync (fs.js:1149:15)
    at new LED (/usr/src/app/node_modules/raspi-led/lib/index.js:60:21)
    at Raspi.value (/usr/src/app/node_modules/raspi-io/lib/index.js:325:34)
    at Raspi.pinMode (/usr/src/app/node_modules/raspi-io/lib/index.js:304:21)
    at /usr/src/app/node_modules/raspi-io/lib/index.js:234:17
    at Array.forEach (native)
    at Object.Call (/usr/src/app/node_modules/es6-shim/es6-shim.js:279:14)
    at Array.forEach (/usr/src/app/node_modules/es6-shim/es6-shim.js:1269:17)

I believe this is due to the Hypriot OS image being faulty- still in beta- but I'm wondering if this has been reported before, also curious on how this is being used.

Can't update raspi-io - need to remove it and reinstall

If this is difficult to fix, then a simple statement in the readme to remove and reinstall would suffice.

I first did a "sudo npm update raspi-io". After it finished and I invoked it, it appeared that it was not fully updated since the servo string pin value was still an issue.

I then did a "sudo npm rm raspi-io" and when that completed, "sudo npm install raspi-io", and all worked as expected.

RaspberryPi 3 support?

The new RaspberryPi 3 is out \o/

But is it supported? We should probably check that it is, and then either fix it or just update the documentation.

node-serialport issue

Trying to install Johnny-Five and Raspi IO on RPi following this guide https://github.com/nebrius/raspi-io/wiki/Getting-a-Raspberry-Pi-ready-for-NodeBots .
After npm install johnny-five raspi-io I get

node-pre-gyp ERR! Tried to download: https://github.com/voodootikigod/node-serialport/releases/download/3.1.2/serialport-v3.1.2-node-v46-linux-arm.tar.gz

node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v46 ABI) (falling back to source compile with node-gyp)

Is it OK?

Raspberry Pi Zero support?

Apologies if this is answered elsewhere, I didn't find mention specifically in the readme or other issues.

Does this support the RPi Zero? Could it?

Thanks! πŸ˜„

Accessing pins by physical location on raspberry pi doesn't seem to work

Gist with the code:
https://gist.github.com/motiooon/eb5be4823d3e3a133c50

Error stack:

/home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:231
throw new Error('Unknown pin "' + pin + '"');
^
Error: Unknown pin "P1-16"
at Raspi.Object.defineProperty.value as $271828_5$
at Raspi.Object.defineProperty.value as pinMode
at Raspi. (/home/pi/projects/johnny-five/start.js:16:9)
at Raspi.emit (events.js:92:17)
at /home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:204:10

Pin aliases not working

Using the Raspi2 in the following example only the WiringPi pin numbers work. With GPIO-18 and P1-12 the motionstart event is not fired and no errors occur. I have tried with other pins as well.

  // Create a new `motion` hardware instance.
  var motion = new five.IR.Motion(1); // "GPIO-18" and "P1-12" doesn't work

  // "calibrated" occurs once, at the beginning of a session,
  motion.on("calibrated", function() {
    console.log("calibrated");
  });

  // "motionstart" events are fired when the "calibrated"
  // proximal area is disrupted, generally by some form of movement
  motion.on("motionstart", function() {
    console.log("motionstart");
    intruder = true;

    sendMessage('Motion Detected!');

  });

Error: Cannot find module '../build/Release/addon'

So I saw another issue with this same problem, but it didn't seem like it was resolved. I just replaced Raspbian with Arch ARM, and although everything else seems to be working great, I get this error when I try to run the script that instantiates the board:

module.js:341
    throw err;
    ^

Error: Cannot find module '../build/Release/addon'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/home/pi/workspace/robo-interface/node_modules/raspi/lib/index.js:30:29)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)

Do you have any clue as to what might be going wrong here? Unfortunately Raspbian was giving me massive problems with streaming video, so I was really hoping there could be a solution to this error.

fully implement generic IO interface

I noticed that queryAnalogMapping() was missing, but there might be other methods.

Even if these aren't much more that no-ops executing the callbacks, i think all IO classes should have all the functions implemented

Calling "stop method" on servo crashes the Pi

The scenario: I create a continuous servo and start it in motion. If I call the stop method for that device, the Raspberry Pi crashes without any exception or error messages in the node window. Eventually the servo stops (but I think that is because the kernel is some where in the nether world).

I took a quick look at /var/log/messages and I don't see anything that might help.

ReferenceError: Symbol is not defined

Hi,
when I'm trying to run your led example I'm getting the following error:

pi@berry:~/johnny $ nodejs led.js

/home/pi/johnny/node_modules/raspi-i2c/lib/index.js:96
var devices = Symbol('devices');
^
ReferenceError: Symbol is not defined
at Object. (/home/pi/johnny/node_modules/raspi-i2c/lib/index.js:96:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/pi/johnny/node_modules/raspi-io/lib/index.js:21:17)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

I'm using a Raspberry Pi 3 B (same error on a 1 B) with raspbian 8/Jessie and the following:

  • gcc version 4.9.2 (Raspbian 4.9.2-10)
  • nodejs v0.10.29
  • npm 3.9.2

any idea what the problem could be? Thank you!

Error: Pin "9" does not support mode "3"

I'm not sure if this is the right place for it, but as far as I can tell, I'm not doing anything stupid.

I'm running a Raspberry Pi B+ with a Pololu DRV8835 motor driver board. I've tested the motor driver using the sample Python code and all the hardware works fine.

I'm using the latest versions of everything (Johnny-five, Raspi-io, wiring-pi) as of about a week ago.

When I run the following:

var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
  io: new raspi()
});

board.on('ready', function() {

  var motor1 = new five.Motor({
    pins: {
      pwm: 9,
      dir: 7
    }
  });

  var motor2 = new five.Motor({
    pins: {
      pwm: 10,
      dir: 8
    }
  });

  motor1.forward(64);
  motor2.forward(64);
});

I get this output:
pi@raspberrypinb ~/motortest $ sudo node basic.js
1433678531584 Device(s) RaspberryPi-IO
1433678533746 Connected RaspberryPi-IO
1433678533823 Repl Initialized
/home/pi/motortest/node_modules/raspi-io/lib/index.js:328
throw new Error("Pin "" + pin + "" does not support mode "" + mod
^
Error: Pin "9" does not support mode "3"
at Raspi.pinMode (/home/pi/motortest/node_modules/raspi-io/lib/index.js:328:17)
at Motor.initialize (/home/pi/motortest/node_modules/johnny-five/lib/motor.js:484:11)
at new Motor (/home/pi/motortest/node_modules/johnny-five/lib/motor.js:449:10)
at Board. (/home/pi/motortest/basic.js:9:16)
at Board.emit (events.js:104:17)
at process._tickDomainCallback (node.js:381:11)

From what I've been able to see, this happens if you try to re-assign a pin, but as you can see, that's not the case here.

The following works fine and blinks an LED on my setup:

var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
  io: new raspi()
});

board.on('ready', function() {
  (new five.Led('P1-7')).strobe();
});

Any help would be appreciated.

EIO ,i/o error

I am getting this error and tried everything to fix but no success please resolve the issue

pi@raspberrypi:~ $ cd waterpi-node
pi@raspberrypi:~/waterpi-node $ sudo node index.js
1462815306876 Device(s) RaspberryPi-IO
1462815307277 Connected /dev/ttyACM0
1462815307365 Connected RaspberryPi-IO
connect
1462815311112 Board ID: pi
1462815311114 Board ID: uno
1462815311129 Repl Initialized

ready
Temperature: 33.00C, humidity: 45.00%
fs.js:613
return binding.writeBuffer(fd, buffer, offset, length, position);
^
Error: EIO, i/o error
at Error (native)
at Object.fs.writeSync (fs.js:613:20)
at Bus.i2cWriteSync (/home/pi/waterpi-node/node_modules/raspi-io/node_modules/raspi-i2c/node_modules/i2c-bus/i2c-bus.js:340:13)
at I2C.writeSync (/home/pi/waterpi-node/node_modules/raspi-io/node_modules/raspi-i2c/lib/index.js:332:34)
at Raspi.i2cWrite (/home/pi/waterpi-node/node_modules/raspi-io/lib/index.js:559:19)
at Expander.write (/home/pi/waterpi-node/node_modules/johnny-five/lib/lcd.js:49:11)
at LCD.Controllers.PCF8574.initialize.value (/home/pi/waterpi-node/node_modules/johnny-five/lib/lcd.js:341:23)
at new LCD (/home/pi/waterpi-node/node_modules/johnny-five/lib/lcd.js:734:10)
at Boards. (/home/pi/waterpi-node/index.js:60:9)
at Boards.emit (events.js:107:17)
at Boards. (/home/pi/waterpi-node/node_modules/johnny-five/lib/board.js:1197:14)
at process._tickDomainCallback (node.js:381:11)

Default LED is not supported

There was a time that the default LED, aka activity LED was supported, but that support never made it into raspi-io 2. This probably needs to be updated to support the A+/B+/2.

Led not setting pinmode?

Running with the johnny-five example, I'm getting this error:

Error: Cannot digitalWrite to pin "7" unless it is in OUTPUT mode
    at Raspi.Object.defineProperty.value [as digitalWrite] (/home/pi/spaceJS/node_modules/raspi-io/lib/index.js:307:13)
    at Led.Controllers.DEFAULT.write.value (/home/pi/spaceJS/node_modules/johnny-five/lib/led.js:125:19)
    at Led.on (/home/pi/spaceJS/node_modules/johnny-five/lib/led.js:257:8)
    at Led.toggle (/home/pi/spaceJS/node_modules/johnny-five/lib/led.js:281:40)
    at Led.<anonymous> (/home/pi/spaceJS/node_modules/johnny-five/lib/led.js:462:10)
    at wrapper [as _onTimeout] (timers.js:261:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

Code:

var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
  io: new raspi()
});

board.on('ready', function() {

  // Create an Led on pin 7 (GPIO4) and strobe it on/off
  // Optionally set the speed; defaults to 100ms
  (new five.Led('P1-7')).strobe();

});

Add support for other OSes

I think that Raspbian is the only OS raspi-io works on, although I'm not certain. We should confirm and make sure it does work on others, especially pidora.

Board never closes

Using this library with johnny-five. However, when I finish and go to shutdown the connection to the raspberry pi I get a message in the console Board Closing but this just hangs forever.

I've been just manually going in and running a kill -9 on the process. This isn't ideal but I couldn't find other ways to more gracefully close the connection.

Any suggestions?

Raspberry PI 3 -: Symbol is not defined

Faced Symbol is not defined issue

/home/pi/code/matrix/node_modules/raspi-io/node_modules/raspi-i2c/lib/index.js:96
var devices = Symbol('devices');
              ^
ReferenceError: Symbol is not defined
    at Object.<anonymous> (/home/pi/code/matrix/node_modules/raspi-io/node_modules/raspi-i2c/lib/index.js:96:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/pi/code/matrix/node_modules/raspi-io/lib/index.js:21:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

Version installed

NodeJS code

var five = require("johnny-five");
var Raspi = require("raspi-io");

var board = new five.Board({
    io: new Raspi()
});

Pins aren’t being aliased

This raises an error

this.pinMode('GPIO17', five.Pin.OUTPUT)

/home/pi/node_modules/raspi-io/lib/index.js:231
throw new Error('Unknown pin "' + pin + '"');
^
Error: Unknown pin "GPIO17"
at Raspi.Object.defineProperty.value as $271828_5$
at Raspi.Object.defineProperty.value as pinMode
at Board.(anonymous function) as pinMode
at Board. (/home/pi/init.js:8:8)
at Board.emit (events.js:95:17)
at Board.broadcast (/home/pi/node_modules/johnny-five/lib/board.js:427:8)
at Board. (/home/pi/node_modules/johnny-five/lib/board.js:329:21)
at Raspi.g (events.js:180:16)
at Raspi.emit (events.js:92:17)
at /home/pi/node_modules/raspi-io/lib/index.js:205:10

this.pinMode(0, five.Pin.OUTPUT)

The numerical reference is OK and works

Raspi-IO broken on Node 0.10

Grrr, it turns out that Babel doesn't shim Symbol like traceur does, and of course I switched to it without testing. Node 0.12 and io.js both have native support for symbols, so I didn't even notice until now.

Raspi-IO crashes on startup in Node < 0.12 since it doesn't have support for Symbol. Need to add a shim

Servo with johnny-five won't work

If I try to initialize a pin as a servo in johnny-five then raspi-io throws an error:
Error: Pin "7" does not support mode "undefined"
stack trace points to:
raspi: 133
lib/servo.js: 87
lib/servo.js: 141

Rasberry pi B+ running johnny five and raspi-io
It is working if I set an LED to strobe, so I think everything is setup properly.

P.S Thank you so much for this awesome lib!

Reading from Analog > Digital

I'm trying to read data from 2x10k potentiometers that are wired to the 1st two inputs of an MCP3008, and then the MCP3008 is hooked up to the RPi like this:

(rpi on the left, mcp3008 on the right):

Pin 19 (MOSI / #10) -> pin 11 (Din)
Pin 21 (MISO / #9) -> pin 12 (Dout)
Pin 23 (SCKL / #11) -> pin 13 (CLK)
Pin 24 (CD0 / #8) -> pin 10 (CS)
Pin 6 (GND) -> pin 14 (AGND) & 9 (DGND)

How do I go about doing this? The only reference code I could find on johnny-five is for the Grove shield and Edison board:

var rotary = new five.Sensor("A0");

rotary.scale(0, 255).on("change", function() {
    // do stuff with this.value
});

How do I create two rotary instances (what would I use for the GPIO pins)?

Interfacing with Adafruit Motor HAT control board?

Hello again,

So my motor control board came in today (Adafruit Motor HAT) and much to my dismay, the recommended way of interfacing with it is through their Python library. While it's actually not so bad once you get everything set up, I was hoping there might be a nice way to use johnny-five and raspi-io to access the motor controls. Something about calling Python commands from node kinda rubs me the wrong way.

Anyway, if you have any experience with this board or anything similar to it, and can maybe offer some hints as to how to control it by using raspi-io functionality, please let me know. I'll keep doing research but I figured I might as well ask since you're the Raspberry Pi Javascript guy.

Thanks!

Create contributing guide

Need a contributing guide.

Things to include:

  • Open open source model
  • Architecture diagram
  • Code style, especially the new ES6 bits that people aren't familiar with
  • How to contribute to different areas
  • Others?

Getting started

Hi,
I'm trying to get started with Johnny-five. I got a Raspberry Pi 2 model B, and a RGB Led called KY-016. I've connected it to 5V, GPIO17, GPIO21 & GPIO22, and whenever I try to do:
var a = new five.LED.RGB([ 'GPIO017', 'GPIO021', 'GPIO022' ]);

.. it fails with "PIN Error: 0 is not a valide PWM pin (Led.RGB)"

I understand that GPIO17 is pin #0, but I've tried other pins as well, but all with the same result. What am I doing wrong?

var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
  io: new raspi()
});
board.on("ready", function() {
  var a = new five.Led.RGB([ 'GPIO17', 'GPIO21', 'GPIO22' ]);  
});

Thanks
Mikael

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.