You need to install Meteor first (if you haven't already).
Then:
git clone https://github.com/CommonGarden/Grow-IoT
cd Grow-IoT
meteor npm install
meteor
And that's it! Visit http://localhost:3000 with your browser of choice; you should now have the application running.
Create a new device (click the '+' button) and take note of the device uuid
and token
. Then run (in a seperate terminal):
node tests/test-grow-hub.js
Paste in the uuid
and token
and presto! You've connected your first thing to Grow-IoT.
You can find then component for this device in imports/examples/GrowHub.jsx
.
A helper library for creating and connecting new devices.
npm install Thing.js
You can interact with the Grow-IoT api using the Distributed Data Protocol. There are DDP Clients available in many different programming languages, see http://meteorpedia.com/read/DDP_Clients for a list.
We are also slowly adding support for connecting devices over the CoAP protocol. See the experimental server in imports/api/coap.js
.
Checkout Grow.js! It extends the Thing class with a bunch of useful things for growers like scheduling, registering listeners and alerts, etc.
TODO: better example... with ui
Include Thing.js
:
const Thing = require('Thing.js');
Make a new thing and pass in an object.
const Light = new Thing({
// Properties can be set by the API
properties: {
state: null,
},
turn_light_on: function () {
console.log('light on');
Light.set('state', 'on');
},
turn_light_off: function () {
console.log('light off');
Light.set('state', 'off');
}
});
// Things are an extension of the node EventEmitter class
// Thus have the same API
Light.on('property-updated', function(key, value) {
console.log('Light turned ' + value);
});
// Calling a method emits an event
Light.call('turn_light_on');
// light on
// Light turned on.
The connect method takes a configuration object.
The host
property is where the device will connect to a Grow-IoT instance. By default the host
is set to localhost
and the port is set to Meteor's standard of 3000
. This works nicely for usb devices like Arduino.
For connecting over wifi, connect your device to wifi and set the host
to the IP address where the Grow-IoT instance is running. Pass the options to the connect()
method like so:
grow.connect({
"host": "YOUR_IP_HERE"
})
You can connect securely to our Grow-IoT alpha instance on https://grow.commongarden.org, or see the Grow-IoT repo to easily start your own IoT network locally or hosted on Meteor Galaxy.
SSL is supported though will require a bit more setup. If you are hosting your instance off a computer with a dedicated IP address pass the following the connect()
method.
grow.connect({
"host": "YOUR_IP_HERE",
"port": 443,
"ssl": true
})
If you are hosting on a cloud instance such as Meteor Galaxy, you might need specify the servername. The example below shows you how to connect securely to the instance at grow.commongarden.org:
grow.connect({
"host": "grow.commongarden.org",
"tlsOpts": {
"tls": {
"servername": "galaxy.meteor.com"
}
},
"port": 443,
"ssl": true
});
To do so:
- Make a new
CustomComponent.jsx
file in `imports/things/' - Open
imports/things/index.js
. import CustomComponent from './CustomComponent'
- Lastly, add
CustomComponent
to the exportedcomponents
object.
In the repo you'll find the following directories and files:
File/Folder | Provides |
---|---|
.meteor |
Meteor stuff, well documented in other places. |
.sandstorm |
Sandstorm.io stuff (can) |
client |
Imports things and starts the React app. |
imports |
API, UI, and thing examples live here |
public |
Fonts and other static, public assets live here. |
tests |
Unit and Thread conformance tests |
server |
Imports the server code. |
tests |
Hmmm.... |
We have a few different repos for alternative (perhaps non-Meteor) stacks:
- Graph-QL api and schema
- Rest API (using Express)
- Mongoose models
Our wiki also contains a growing assortment of useful info, including:
Grow-IoT is released under the 2-Clause BSD License, sometimes referred to as the "Simplified BSD License" or the "FreeBSD License".
Thank you to these forward looking companies that have sponsored us so far:
If your interested in sponsoring this work, or perhaps owning a piece of Common Garden, then please reach out: jake at commongarden.org