mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 15:34:26 +01:00
Destroyed ReadMe Raspberry Pi (markdown)
@@ -1,63 +0,0 @@
|
||||
#Raspberry Pi - Simple
|
||||
This version of working with the Raspberry Pi uses the pi-gpio node.js libraries so gives
|
||||
simple GPIO support for the standard connector.
|
||||
|
||||
##Installation
|
||||
|
||||
pi-gpio - download, install, configure and test pi-gpio as per the website - https://github.com/rakeshpai/pi-gpio .
|
||||
Note especially the bit about quick2wire's gpio-admin and root access.
|
||||
|
||||
Node-RED - as per main INSTALL file, or... in the Pi terminal
|
||||
|
||||
cd ~
|
||||
wget https://github.com/node-red/node-red/archive/master.zip
|
||||
unzip master.zip
|
||||
cd node-red-master
|
||||
npm install
|
||||
npm install pi-gpio
|
||||
|
||||
Then start Node-RED,
|
||||
|
||||
cd node-red-master
|
||||
node red.js
|
||||
|
||||
then browse to http://{your-pi-address}:1880
|
||||
|
||||
You should see a rpi-gpio input node and output node in the left palette under Advanced.
|
||||
|
||||
##Blink
|
||||
|
||||
To run a "blink" flow that toggles an LED on Pin 11 on the header, you will need to connect up an LED - as per Gordon's blink sketch.
|
||||
https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/
|
||||
|
||||
Import the following flow, by cutting the lines below into your clipboard.
|
||||
|
||||
[{"id":"12c3cae6.ed3c35","type":"debug","name":"","active":true,"x":561,"y":119,"wires":[]},{"id":"d4b2ed80.2b4d1","type":"rpi-gpio out","name":"","resistor":"no","pin":"11","x":561,"y":59,"wires":[]},{"id":"5e5e53c0.a1a1ac","type":"inject","name":"tick every 1 sec","topic":"","payload":"","repeat":"1","once":false,"x":121,"y":59,"wires":[["63dad785.9c2528"]]},{"id":"63dad785.9c2528","type":"function","name":"Toggle 0/1 on input","func":"\ncontext.state = context.state || 0;\n\n(context.state == 0) ? context.state = 1 : context.state = 0;\nmsg.payload = context.state;\n\nreturn msg;","outputs":1,"x":321,"y":59,"wires":[["12c3cae6.ed3c35","d4b2ed80.2b4d1"]]}]
|
||||
|
||||
Then in the Node-RED browser - Use Options (top right) - Import From - Clipboard, or the shortcut Ctrl-i, and paste in the text, Ctrl-v.
|
||||
|
||||
Hit <b>Deploy</b> - and the flow should start running. The LED should start toggling on and off once a second.
|
||||
|
||||
##Making Node-RED autostart on boot (optional)
|
||||
|
||||
The easiest way to autostart Node-RED is to use screen so you can easily get to the console at any time.
|
||||
To install screen - if not already there.
|
||||
|
||||
sudo apt-get install screen
|
||||
|
||||
Then edit the etc/rc.local file to include the lines
|
||||
|
||||
cd /home/pi/node-red-master
|
||||
screen -dmS red node red.js
|
||||
|
||||
This assumes that you have installed Node-RED to the default (pi) user's home directory.
|
||||
|
||||
Once you reboot you should then be able to type
|
||||
|
||||
screen -ls
|
||||
|
||||
and see red listed.
|
||||
To get to the terminal type
|
||||
|
||||
screen -r red
|
||||
type Ctrl-A-D to detach and leave it running
|
||||
Reference in New Issue
Block a user