Skip to content

Instantly share code, notes, and snippets.

View industrialinternet's full-sized avatar

Lawrence Griffiths industrialinternet

View GitHub Profile
// tsio App proerties Advanced/External JavaScript Libraries Add
// http://code.highcharts.com/highcharts.js
// JSON payload for real time
// sending a len = 1 adds single point to chart series
// v always an array
{ "lng": 1, "sn": "ENO-Temp-Test", "v": [ 1456330983567, 17.7 ] }
// creates a new sereries as lng >1
{ "lng": 10, "sn": "ENO-Temp-Test", "v": [ { "value": 19, "jts": 1456057196556}, { "value": 19.1, "jts": 1456058242342}..]}
// lng calc coudl be done client side
// a very simple mDot LoRaWAN connection manager
var tx_wdog = {intv: 60000, counter:0, flag: false, sendingFlag: null, ts:null, tid:null};
var con = {state:0, statePrevious: 0, cmd: null, msg: null, status: null, rx_msg: null, sendInt: 60000};
var tx_string = '';
var rx_string = '';
var log = true;
function cLog(logMsg){
var d = new Date();
dumpping ground for freagments
@industrialinternet
industrialinternet / 1_Node-Red EnOcean functions
Last active August 29, 2015 14:02
Node-Red EnOcean Radio telegram functions
These are very basic Node-Red funtions I will in time convert to NR nodes.
They require the ENO300 USB module and use nr-serail-in
57600 8 None 1
Split input: after fixed timeout 50ms
and deliver: binary buffers
I've done all my testing on Raspberry PI.
Please note the send switch funtion need you to set a Base ID to support 128 ID else it will only use the chip ID which means only 1 channel. That said any EnOcean-ers out thier that can help get chip ID working would love your help :)
@industrialinternet
industrialinternet / nr_node_enocean_in.js
Last active August 29, 2015 14:02
Node-red EnOcean in Node
// v0.1 added else for testing
// expects binary lines like 55000A0701EBA500005B080088E4C20001FFFFFFFF4F0034
if (msg.payload.length > 20) {
var m = msg.payload;
console.log("ping",m.length,m.toString('hex'));
if (m.charCodeAt(0) == 85) {
var l = m.charCodeAt(2) + m.charCodeAt(1)*256;
console.log("Len =",l);
var type = m.charCodeAt(4);
console.log("Type=",type);
@industrialinternet
industrialinternet / node-enocean.js
Last active August 29, 2015 14:01
node-enocean basic enocean telegram handler used with USB300
// node-enocean v0.0
CRC8Table = [
0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15,
0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d,
0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65,
0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d,
0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5,
0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85,
0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd,
//T5 Analog Outputs
const ON=1
const OFF=0
// Array that holds the state of each pin
pinState <- [ 0, 0, 0, 0, 0, 0];
// Pins array channel 1 is channelPin[0] in array
Pins <- [ hardware.pin1, hardware.pin2, hardware.pin5, hardware.pin7, hardware.pin8, hardware.pin9 ];
// Register imp
// AGENT
server.log("Monitor MK2 Agent - release 3 v1.1 - Boot");
// Holds imp config & status data
impObj <-{
"sid": 42,
"lid": 50,
"t": "",
"tEng": "C",
"rh": "",
@industrialinternet
industrialinternet / TX_AprilDigital_Out_SCADA_1intro
Last active December 18, 2015 13:39
TX_AprilDigital_Out_SCADA
// This is a bit of fun to show how device and sensor state is typical displayed on commercial SCADA
// systems used in manufacturing, process control and electricity grid control rooms.
// But using the Electric imp and HTML5
//Imp & Agent are written in squirrel-lang.org They should have a .NUT extension.
//but I've used .js so the editor will use colour highlighting.
// Tutorial 3: T1 & T2 combined Electric imp April inputs & outputs from JQM web app
//Imp & Agent are written in squirrel-lang.org They should have a .NUT extension.
//but I've used .js so the editor will use colour highlighting.