-
Notifications
You must be signed in to change notification settings - Fork 6
Raspberry Pi
Jake Hartnell edited this page Apr 8, 2017
·
8 revisions
This is the Grow-IoT guide for the Raspberry pi! Please help make it better.
To get started you'll need to get your Raspberry Pi setup, connected to the Internet, and running node.js. There are lot's of tutorials for how to do this, but this one from the node bots community is pretty good: https://github.com/nebrius/raspi-io/wiki/Getting-a-Raspberry-Pi-ready-for-NodeBots
Install Johnny-five, raspi-io, and Grow.js:
npm install johnny-five raspi-io Grow.js
Run the Grow-IoT meteor app on your local computer or a cloud instance. You will need an account on the instance as well as the IP address of the instance to connect the Pi.
Here's a modified example you can try to get you started. It simply turns an LED on the Rasp-pi on / off.
var raspi = require('raspi-io');
var five = require('johnny-five');
var GrowInstance = require('Grow.js');
var board = new five.Board({
io: new raspi()
});
board.on('ready', function() {
// Create an Led on pin 7 on P1 (GPIO4)
var led = new five.Led('P1-7');
// Create a new grow instance.
var grow = new GrowInstance({
uuid: 'PASTE_UUID_HERE',
token: 'PASTE_TOKEN_HERE',
properties: {
name: {
type: String,
value:'Raspberry Pi LED'
},
state: {
type: String,
value:'off'
}
},
turn_light_on: function () {
LED.high();
console.log('light on');
grow.set('state', 'on').emitEvent('Light on');
},
turn_light_off: function () {
LED.low();
console.log('light off');
grow.set('state', 'off').emitEvent('Light off');
}
});
// Connect to a Grow-IoT instance using the connect method.
grow.connect({
host: '', // The IP address of where your Grow-IoT server is running if you're on a local network
});
//// Another example, ssl on a cloud instance.
// growHub.connect({
// host: "grow.commongarden.org",
// tlsOpts: {
// tls: {
// servername: "galaxy.meteor.com"
// }
// },
// port: 443,
// ssl: true
// });