Skip to content

Instantly share code, notes, and snippets.

@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 / 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
// 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 / 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
/**
* 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 / 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
@dexterlabora
dexterlabora / NodeMCU_WiFi_LEGO_train-aREST-lights.ino
Created March 30, 2016 09:16
WiFi Controlled LEGO Train - NodeMCU with REST interface using Arduino IDE
/*
This program provides a WiFi connected REST interface for a LEGO Power Functions motor and lights.
Written in 2016 by Cory Guynn under a GPL license.
www.InternetOfLEGO.com
*/
// Import required libraries
#include <ESP8266WiFi.h>
@dexterlabora
dexterlabora / WiFi-Controlled-Train-Node-RED-UI.json
Last active February 26, 2017 01:34
WiFi controlled LEGO train using NodeMCU and aREST - This the Node-RED UI, to be run on a local server such as a Raspberry Pi.
[{"id":"1e952328.aa7cbd","type":"mqtt-broker","z":"a073730a.79863","broker":"52.19.148.133","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"50bfec48.165834","type":"ui_tab","name":"Train","icon":"dashboard","order":"1"},{"id":"36934f45.9d7e","type":"inject","z":"a073730a.79863","name":"Forward","topic":"motor","payload":"1023","payloadType":"str","repeat":"","crontab":"","once":false,"x":120,"y":80,"wires":[["55863283.b31b3c"]]},{"id":"8413bbda.0048b8","type":"inject","z":"a073730a.79863","name":"Stop","topic":"motor","payload":"0","payloadType":"string","repeat":"","crontab":"","once":false,"x":110,"y":160,"wires":[["55863283.b31b3c"]]},{"id":"a640c6b2.71bec8","type":"inject","z":"a073730a.79863","name":"Reverse","topic":"motor","payload":"-1023","payloadType":"string","repeat":"","crontab":"","onc
@dexterlabora
dexterlabora / gist:df109bf67c554dd23bd4cb078bd98f23
Created April 8, 2016 13:36
WiFi Controlled train - Node-RED Master Dashboard
[{"id":"b1a4b956.4e5b48","type":"ui_tab","name":"Train","icon":"dashboard","order":"1"},{"id":"7609358c.89f6cc","type":"mqtt-broker","z":"","broker":"52.19.148.133","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":"1a2d0774.e5d2f9","type":"inject","z":"8e58674f.71a798","name":"Forward","topic":"motor","payload":"{\"command\":{\"motor\":1024}}","payloadType":"json","repeat":"","crontab":"","once":false,"x":117,"y":3088,"wires":[["bd88d388.42773"]]},{"id":"b8189f3c.47e76","type":"inject","z":"8e58674f.71a798","name":"Stop","topic":"motor","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":107,"y":3168,"wires":[["bd88d388.42773"]]},{"id":"b18313d0.4e7cf","type":"inject","z":"8e58674f.71a798","name":"Reverse","topic":"motor","payload":"-1000","payloadType":"num","repeat":"",
[{"id":"24f5738f.cbf0ec","type":"mqtt out","z":"d4b3d624.664fe8","name":"","topic":"/trains/horizonexpress/motor","qos":"","retain":"","broker":"","x":947.4999694824219,"y":661.6666259765625,"wires":[]},{"id":"8f1263f4.60953","type":"trigger","z":"d4b3d624.664fe8","op1":"0","op2":"1000","op1type":"val","op2type":"val","duration":"5","extend":false,"units":"s","reset":"","name":"Pause train 5s","x":712.9999694824219,"y":662.6666259765625,"wires":[["24f5738f.cbf0ec","6f4b984.8d42b68"]]},{"id":"8fd852b1.276e8","type":"delay","z":"d4b3d624.664fe8","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":534.9999694824219,"y":662.6666259765625,"wires":[["8f1263f4.60953"]]},{"id":"6f4b984.8d42b68","type":"debug","z":"d4b3d624.664fe8","name":"Reed: Pausing Train","active":true,"console":"false","complete":"payload","x":926.9999694824219,"y":713.6666259765625,"wires":[]},{"id":"53d90812.d397d8","type"