Skip to content

Instantly share code, notes, and snippets.

@dexterlabora
dexterlabora / Train Track Switch Automation - Node-RED flow.json
Created March 6, 2016 22:39
Node-RED Flow to automate a LEGO Train Track Switch
[{"id":"e33ec540.1cc138","type":"ui_tab","z":"","name":"IoL","icon":"dashboard","order":"1"},{"id":"904e0cc3.6fb1f","type":"pubnub-keys","pub_key":"","sub_key":""},{"id":"3e17c7ef.c1e838","type":"pubnub-keys","pub_key":"","sub_key":""},{"id":"a0f49a5c.5f0b68","type":"pubnub-keys","pub_key":"","sub_key":""},{"id":"38e603df.c719fc","type":"pubnub in","z":"11e87d2f.ee1783","keys":"a0f49a5c.5f0b68","channel":"iol","x":110,"y":2040,"wires":[["78eddfd0.87122"]]},{"id":"78eddfd0.87122","type":"switch","z":"11e87d2f.ee1783","name":"filter","property":"payload.trainCrossing","propertyType":"msg","rules":[{"t":"eq","v":"activated","vt":"str"},{"t":"eq","v":"deactivated","vt":"str"}],"checkall":"true","outputs":2,"x":243.0632553100586,"y":2039.9999885559082,"wires":[["1c1a4db2.e3e5b2"],["fb1a6548.04e598"]]},{"id":"70e3647c.8f1c9c","type":"function","z":"11e87d2f.ee1783","name":"msg.topic = \"safety\";","func":"msg.topic = \"safety\";\nreturn msg;","outputs":1,"noerr":0,"x":598.7888717651367,"y":2188.6197032928467,"wires
/**
* Internet of Lego - Train Schedule Display
* This program connects to WiFi, utilizes MQTT and displays the local train schedule on an OLED screen
* The OLED graphics library is slimmed down to only text for memory efficiency
* https://github.com/greiman/SSD1306Ascii
*
* Hardware: Cactus Micro Rev2 - http://wiki.aprbrother.com/wiki/Cactus_Micro_Rev2
* Written by: Cory Guynn with some snippets from public examples ;)
* 2016
*
@dexterlabora
dexterlabora / trainschedule-nodered
Last active February 11, 2016 16:19
Train schedule and automation with Node-RED
[{"id":"b1d8d4eb.4e2728","type":"mqtt-broker","z":"e60e9052.19f17","broker":"aws.internetoflego.com","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"ba1ad5cc.45e528","type":"pubnub-keys","pub_key":"","sub_key":""},{"id":"4419e8c7.bbe618","type":"http request","z":"e60e9052.19f17","name":"API Call","method":"GET","ret":"txt","url":"","x":534.5,"y":105,"wires":[["9cb083cd.634f8","2ddf34e0.d220cc"]]},{"id":"4bf1e239.b40e1c","type":"inject","z":"e60e9052.19f17","name":"","topic":"","payload":"910GLONFLDS","payloadType":"string","repeat":"1","crontab":"","once":true,"x":106.5,"y":109,"wires":[["110734c1.eef8cb"]]},{"id":"9a4a5cb0.65b5a","type":"function","z":"e60e9052.19f17","name":"Request URL to TFL","func":"msg.stationid = msg.payload;\nmsg.url = \"https://api.tfl.gov.uk/StopPoint/\"+msg.station
// traintrackswitch.js
/****************************
// Lego Train Track Switch
// This app uses the Johnny-Five.io framework to control a servo and lights
// The servo will switch the track to the desired location and update the direction lights
// Commands can be sent from the "iol" PubNub channel
// {"command":"track_straight"}
// {"command":"track_turn"}
// {"command":"track_toggle"}
@dexterlabora
dexterlabora / CactusMicro_Weather_Station_LCD_MQTT_JSON
Created December 31, 2015 03:15
This weather station program uses a CactusMicro Rev2 (ArduinoLilyPad USB + ESP8266) to send data to an MQTT network.
/**
* This program sends weather data to an MQTT broker, and displays the messages onto the attached LCD screen
* Hardware: Cactus Micro Rev2 - http://wiki.aprbrother.com/wiki/Cactus_Micro_Rev2
* Written by: Cory Guynn with some snippets from public examples ;)
* http://www.InternetOfLego.com
*/
// Global Variables
unsigned long time; // used to limit publish frequency
@dexterlabora
dexterlabora / excap.js
Last active July 17, 2018 14:45
Cisco Meraki ExCap API for customer hosted WiFi captive portal - requires supporting HTML files for proper operation
// excap.js
// ################################################################
// Overview
// ################################################################
/*
External Captive Portal (ExCAP) for Cisco Meraki MR access points and MX security appliances.
This application provides a basic click-through and sign-on splash page where the login will complete on a success page.
@dexterlabora
dexterlabora / Node-RED example flow
Last active April 10, 2017 10:36
An example of how PubNub messages can be sent and received to interact with the IoL City. www.InternetOfLego.com
[{"id":"a0f49a5c.5f0b68","type":"pubnub-keys","pub_key":"XXXX","sub_key":"XXXX"},{"id":"490810ab.b6f7f","type":"pubnub in","keys":"a0f49a5c.5f0b68","channel":"iol","x":94,"y":86,"z":"11e87d2f.ee1783","wires":[["1e0d1490.e1f2eb","1bd186c1.e42e79"]]},{"id":"965d4cc1.69a2b","type":"pubnub out","keys":"a0f49a5c.5f0b68","channel":"iol","x":656,"y":405,"z":"11e87d2f.ee1783","wires":[]},{"id":"1e0d1490.e1f2eb","type":"debug","name":"PubNub raw data","active":false,"console":"false","complete":"payload","x":337,"y":44,"z":"11e87d2f.ee1783","wires":[]},{"id":"e91c1b55.16e3e8","type":"inject","name":"","topic":"","payload":"From node-red, Hello World!","payloadType":"none","repeat":"","crontab":"","once":false,"x":140,"y":301,"z":"11e87d2f.ee1783","wires":[["20132ddb.dfecd2"]]},{"id":"fe4f5cf0.01b0a","type":"inject","name":"","topic":"","payload":"{command:lights_off}","payloadType":"none","repeat":"","crontab":"","once":false,"x":142,"y":365,"z":"11e87d2f.ee1783","wires":[["40213340.bfdecc"]]},{"id":"20132ddb.dfecd2",
// circuit-master.js
// This program uses multiple microcontrollers in the same app to control a living Lego city.
// ~~ IoL City ~~
// www.InternetOfLego.com
// ~~~~ CIRCUIT ~~~~~~~
// Includes
var five = require('johnny-five');
var Raspi = require("raspi-io");
// server-pubnub.js
// www.InternetOfLego.com
// This app provides a multi-functional server for which a "circuit file" is spawned from the process.
// Child process communication example: circuit.send({'command': 'led_on'});
// The server provides support for the following communication options
// RESTful API using express example: http://192.168.0.15:8080/command/led_on)
// Websocket using Primus example: spark.send('command', 'led_on')
// Messaging using PubNub example: pubnub.publish({channel :'iol', message : {"command":"led_on"}})
@dexterlabora
dexterlabora / elevator.js
Created September 26, 2015 23:26
Operate an elevator with a web API using a 5v motor and an ultrasonic sensor for positioning.
// elevator.js
// This program will use an Adafruit motor shield v1 (http://www.adafruit.com/products/81) clone to power a small 5v motor
// and an ultrasonic sensor for positioning
// The ultrasonic sensor requires PingFirmata on the Arduino (http://johnny-five.io/api/proximity/#pingfirmata)
// Dependencies
var five = require('johnny-five');
var board = new five.Board();