Skip to content

Instantly share code, notes, and snippets.

@mako34
Created March 23, 2016 17:00
Show Gist options
  • Select an option

  • Save mako34/cec7a7c5da23f30d6890 to your computer and use it in GitHub Desktop.

Select an option

Save mako34/cec7a7c5da23f30d6890 to your computer and use it in GitHub Desktop.
mqtt + j5
// var mqtt = require('mqtt');
// var client = mqtt.connect('mqtt://localhost');
// client.on('connect', function () {
// client.subscribe('tito');
// client.publish('tito', 'Hello mqtt');
// });
// client.on('message', function (topic, message) {
// // message is Buffer
// console.log(message.toString());
// // client.end();
// });
//
var five = require("johnny-five");
var pcDuino = require("pcduino-io");
var board = new five.Board({
io: new pcDuino()
});
board.on("ready", function() {
var led = new five.Led(12);
led.blink();
client.publish('tito', 'readys');
});
@mako34
Copy link
Author

mako34 commented Mar 23, 2016

pcduino-io [Johnny5 plugin]
https://github.com/rwaldron/pcduino-io

@mako34
Copy link
Author

mako34 commented Mar 23, 2016

basic leds on node

[{"id":"33417553.ccbe8a","type":"mqtt-broker","z":"120d4a4d.edf2b6","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"d1ea6f58.2e159","type":"inject","z":"120d4a4d.edf2b6","name":"","topic":"","payload":"blue","payloadType":"str","repeat":"","crontab":"","once":false,"x":93,"y":509,"wires":[["d2ea2cf0.2d15d"]]},{"id":"d2ea2cf0.2d15d","type":"mqtt out","z":"120d4a4d.edf2b6","name":"aa","topic":"tito","qos":"","retain":"","broker":"33417553.ccbe8a","x":281,"y":510,"wires":[]},{"id":"ce494925.31b6b8","type":"mqtt in","z":"120d4a4d.edf2b6","name":"","topic":"tito","broker":"33417553.ccbe8a","x":94,"y":377,"wires":[["54b6a986.ab4958"]]},{"id":"54b6a986.ab4958","type":"debug","z":"120d4a4d.edf2b6","name":"","active":true,"console":"false","complete":"true","x":226,"y":376,"wires":[]},{"id":"41a41d18.be5be4","type":"inject","z":"120d4a4d.edf2b6","name":"","topic":"","payload":"green","payloadType":"str","repeat":"","crontab":"","once":false,"x":97,"y":584,"wires":[["4fc2c48b.b03d3c"]]},{"id":"4fc2c48b.b03d3c","type":"mqtt out","z":"120d4a4d.edf2b6","name":"aa","topic":"tito","qos":"","retain":"","broker":"33417553.ccbe8a","x":285,"y":585,"wires":[]},{"id":"916e1d6c.6e91e","type":"inject","z":"120d4a4d.edf2b6","name":"","topic":"","payload":"red","payloadType":"str","repeat":"","crontab":"","once":false,"x":95,"y":658,"wires":[["fd639c10.029c6"]]},{"id":"fd639c10.029c6","type":"mqtt out","z":"120d4a4d.edf2b6","name":"aa","topic":"tito","qos":"","retain":"","broker":"33417553.ccbe8a","x":294,"y":657,"wires":[]}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment