Skip to content

Instantly share code, notes, and snippets.

@flaki
Created January 20, 2017 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save flaki/24928ca46b30d8f3d481d47fb0d1e702 to your computer and use it in GitHub Desktop.
Save flaki/24928ca46b30d8f3d481d47fb0d1e702 to your computer and use it in GitHub Desktop.
How to node on the PocketCHIP

How to node on the PocketCHIP?

Install node.js

Install node from NodeSource PPA

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

The default sudo password is just "chip".

Create test project

To handle basic GPIO from node on the CHIP you will need the chip-gpio npm package. For the package to work

sudo apt-get install build-essential
mkdir chipnode
cd chipnode
npm init
npm i chip-gpio --save

GPIO ports are numbered on the top of the PocketCHIP, add +1 to the number printed, when using with chip-gpio! (GPIO port number one is instantiated with e.g. new GPIO(2, "out"))

Quick test in node REPL

You probably need to start the REPL with sudo: sudo node.

G = require('chip-gpio')
l = new G(2, 'out')
l.read()
l.write(1)
l.write(0)
l.write(1-l.read())
setInterval(_=>l.write(1-l.read()),500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment