These are chat archives for CommonGarden/Grow-IoT

20th
Jun 2016
Jake Hartnell
@JakeHartnell
Jun 20 2016 01:24
More to come! Let me know what other info you would like to see on these wiki pages. Feel free to create pages with any links to sensors you're using. : )
JF
@cloudzombie
Jun 20 2016 01:27
Beautiful! Will sit and check it out here after dinner.
Just been doing some deconstruction to do reconstruction of rooms within rooms all day. Tomorrow is finish the floating floor deck and drywall.
I'm beat
Jake Hartnell
@JakeHartnell
Jun 20 2016 01:29
Sounds like a lot of work!
I've been staring at screens all day. : | #timetogooutside
JF
@cloudzombie
Jun 20 2016 01:38
Hahaha
Yes it's about that time
Blockchain - Smart Contract Development
@EdwardKepler
Jun 20 2016 02:47

// Require the Grow.js build and johnny-five library.
var GrowInstance = require('Grow.js');
var five = require('johnny-five');
var ascii = require('ascii-codes');

// Create a new board object
var board = new five.Board();

// When board emits a 'ready' event run this start function.
board.on('ready', function start() {
// This must be called prior to any I2C reads or writes.
this.i2cConfig();

var DO_reading;

// Create a new grow instance.
var grow = new GrowInstance({
    name: 'PH sensor', // The display name for the thing.
    desription: 'Atlas Scientific PH sensor',
    username: 'jake2@gmail.com', // The username of the account you want this device to be added to.
    // properties: {
    //     state: 'off'
    // },
    actions: {
        log_do_data: {
            name: 'PH Sensor', 
            template: 'sensor',
            type: 'PH', // Currently needed for visualization component... HACK.
            schedule: 'every 1 second',
            function: function () {
                // Request a reading
                board.i2cWrite(0x61, [0x52, 0x00]);
                // Read response.
                board.i2cRead(0x61, 0x00, 14, function (bytes) {
                    var bytelist = [];
                    if (bytes[0] === 1) {
                        for (i = 0; i < bytes.length; i++) {
                            if (bytes[i] !== 1 && bytes[i] !== 0) {
                                bytelist.push(ascii.symbolForDecimal(bytes[i]));
                            }
                        }
                        PH_reading = bytelist.join('');
                    }
                });

                // // Send value to Grow-IoT
                grow.sendData({
                  type: 'PH',
                  value: PH_reading
                });
            }
        }
    },
    events: {
        check_PH_data: {
            name: 'Check PH data',
            on: 'log_do_data', // Adds Listener for action event.
            function: PH_range (ph_Reading) {
                If PH reading under min_range
                   Call Doser PH-up()
              else if PH reading over max_range
                   Call Doser PH_down()
              Else
                   return
Jake Hartnell
@JakeHartnell
Jun 20 2016 20:34
@EdwardKepler, a good start! We're going to have a ph-balancer example soon. : )
That code example has the right addresses in it for communication over I2C, though I don't have the atlas ph sensor with me at the moment to test.
Blockchain - Smart Contract Development
@EdwardKepler
Jun 20 2016 23:57
I have a shielf
i
I can send you a shield if that would help.
Gr