A Time to Dance
This is good. My project has come together and works. I like it. Now as many have said it is time to add in the extras I wanted to do. I have decided to put this device in my NEMA box at my 80' tower. Then when I have a problem, I can power cycle items. Another goal will be watchdogs to reboot radios if the tower cannot see inside my network.
Special thanks to Intel!!
Ecclesiastes 3:4-6
A time to weep, And a time to laugh; A time to mourn, And a time to dance;
A time to cast away stones, And a time to gather stones; A time to embrace, And a time to refrain from embracing;
A time to gain, And a time to lose; A time to keep, And a time to throw away;
A Time to Throw Away
Okay, I am short one item in my Upcycled PDU that I wanted. The LCD in he kit was too tall to fit in my box. Not a huge deal as I will use the other Edison to drive the LCD and some other add on items. I think I will put it in a project box and it will be the part of the project that is shown.
Forward With Time to Keep
This will be a 10,000 foot view and I will zoom in on parts to follow. The web interface is working how I want it, but I want to to look good, so I will cover that as I finish it too. Also the second Edison control and display functions will be covered with the details.
| javascript:;{gallery} My Gallery Title |
|---|
Full Inside View |
Right Side |
Left Side |
First demo showing this working from the web interface. One button toggles on and off depending on current state.
Second demo showing an external source (MQTT) controlling the outlets and web interface updating.
Node-Red Flows!
| {gallery} My Gallery Title |
|---|
Incoming WS message for outlet control and MQTT to also control the outlet. I need to change put a function so that I can send On/Off via MQTT from Home Assistant. |
Long flow that looks for GPIO status and looks for changes. Then send out a MQTT message (needs a function also for On/Off from 1/0), function that formats what outlet is sending to a WS, and update MongoDB entry. |
More detail on the last slide. |
When there is a new connection or Home Assistant starts up, we need the status of all the outlets. This flow looks for that query and sends out via MQTT and WS. |
Here is what the mongo Collection looks like:
> db.status.find().pretty()
{
"_id" : ObjectId("5922bedc0d6c8c42b1a16876"),
"device" : "eddy2",
"control" : "lcd1",
"state" : "time",
"custom" : {
"msg1" : null,
"msg2" : null,
"R" : null,
"G" : null,
"B" : null
}
}
{
"_id" : ObjectId("5922cc280d6c8c42b1a16877"),
"device" : "tower00",
"control" : "outlet1",
"state" : "off"
}
{
"_id" : ObjectId("5922ce3f0d6c8c42b1a16878"),
"device" : "tower00",
"control" : "outlet2",
"state" : "off"
}
{
"_id" : ObjectId("5922da170d6c8c42b1a16879"),
"device" : "tower00",
"control" : "outlet4",
"state" : "off"
}
{
"_id" : ObjectId("5922dd840d6c8c42b1a1687a"),
"device" : "tower00",
"control" : "outlet3",
"state" : "off"
}
{
"_id" : ObjectId("5922e3ed0d6c8c42b1a1687b"),
"device" : "tower00",
"control" : "outlet5",
"state" : "off"
}
{
"_id" : ObjectId("5922e3ee0d6c8c42b1a1687c"),
"device" : "tower00",
"control" : "outlet6",
"state" : "off"
}
{
"_id" : ObjectId("5922e3f00d6c8c42b1a1687d"),
"device" : "tower00",
"control" : "outlet7",
"state" : "off"
}
Here is my web interface system that interfaces the Node-Red flows and the front end.
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var port = 3001;
app.use(express.static(__dirname + '/public'));
const WebSocket = require('ws');
//const wss = new WebSocket.Server({ port: 3001 });
const wscTemperature = new WebSocket('ws://192.168.2.138:1880/ws/temperature');
const wscButton1 = new WebSocket('ws://192.168.2.138:1880/ws/button1');
const wscTouch1 = new WebSocket('ws://192.168.2.138:1880/ws/touch1');
const wscOutletStatus = new WebSocket('ws://192.168.2.137:1880/ws/outlet/status');
// These are outputs
const wscLED1 = new WebSocket('ws://192.168.2.138:1880/ws/led1');
const wscOutletControl = new WebSocket('ws://192.168.2.137:1880/ws/outlet/control');
const wscLCD1 = new WebSocket('ws://192.168.2.138:1880/ws/lcd');
const wscTowerStatus = new WebSocket('ws://192.168.2.137:1880/ws/status');
io.on('connect', function (socket) {
wscOutletStatus.on('message', function(data,flags) {
console.log("Outlet Status Change:", data);
io.emit('tower00Outlet', {
event: 'Outlet',
value: data
});
});
wscButton1.on('message', function(data,flags) {
console.log("Button1 is: " + data);
io.emit('eddy2', {
event: 'Button1',
value: data
});
});
wscTouch1.on('message', function(data,flags) {
console.log("Touch1 is: " + data);
io.emit('eddy2', {
event: 'Touch1',
value: data
});
});
wscTemperature.on('message', function(data,flags) {
//console.log("Data: ",data);
//console.log("Flags: ",flags);
//var dataJ = JSON.parse(data);
//var a = dataJ.payload;
var a = data;
//console.log("A: ",a);
var B = 4275;
var R = 1023.0/a - 1.0;
//console.log("R: ",R);
R *= 100000.0;
var temperature = 1.0 / (Math.log(R / 100000.0) / B + 1 / 298.15) - 273.15;
var tempC = Math.round((temperature*100))/100;
//console.log("temperature: ", tempC);
var tempF = Math.round((temperature * 9 / 5 + 32) * 100) / 100;
//console.log("or "+ tempF + " F");
io.emit('eddy2', {
event: 'Temperature',
value: a,
cel: tempC,
far: tempF
});
});
socket.on('Tower00OutletStatus', function(data) {
wscTowerStatus.send("1");
});
socket.on('button',function(data) {
console.log("data: ", data);
switch (data.button) {
case 'Tower00Outlet':
console.log("Tower00Outlet: ", JSON.stringify(data.msg));
wscOutletControl.send(JSON.stringify(data.msg));
break;
case 'led1':
wscLED1.send(data.msg);
console.log("LED1: ", data.msg);
break;
case 'lcd1Time':
console.log("Setting LCD1 to Time",data);
var myMSG = {
state: "time"
};
console.log("sending: ",myMSG);
wscLCD1.send(JSON.stringify(myMSG));
break;
case 'lcd1Temp':
console.log("Setting LCD1 to Time",data);
var myMSG = {
state: "outside temperature"
};
console.log("sending: ",myMSG);
wscLCD1.send(JSON.stringify(myMSG));
break;
}
});
});
server.listen(port, function() {
console.log('Server listening at port %d', port);
});








Top Comments