Category Archives: LEDs

Duff lights

corn lightsAs everyone in here is into technology – and as that means you’re more than likely to buy LED lighting for your home, I thought I’d take this opportunity to issue a helpful warning – especially for those in 240v AC areas.

While I have generally had great success with modern LED lighting – there is a particular style of light I’d like to flag up here. See the photo – these are often referred to as CORN lights. They come in different sizes and from different suppliers, some Chinese, some home-grown – but from what I’ve seen they all look so similar that they must surely be made by possibly one manufacturer. I could be wrong.

I’ve purchased perhaps a couple of dozen of these over the past couple of years – and EVERY LAST ONE of them has ended up in the bin.  I thought at first I’d just had a bad batch and bought from a separate supplier…then I thought I must be using them in too enclosed an environment as we all know LEDs don’t like heat.

But no, this last one came out of an outside lamp – and right now it is cold in Britain – there is no way this overheated.  My suspicion is that the LEDs are not well matched and being wired in series, it only takes ONE dead LED to bring the whole lamp to a standstill. I assume they’ve done the power this way to save cost.

Either way these are not, as it were, worth a LIGHT. See the picture, you’ll note on a couple of the lights a little black dot in the middle – that is the beginning of the end.

They’re all gone now and I won’t be buying more. I hope that with this short write-up I’ll save others the hassle. They may well last a couple of weeks or a few months – but that in my experience is about it. Meanwhile the little GU-10 lights with three LEDS and proper power supplies I’ve had running 8 hours a day for well over 2 years now with not the slightest degradation – so it’s not LED as such  - it is just down to rubbish design. maybe if you’re on 220v you might get longevity out of these – I can’t say – but at 240-250v – avoid!

Facebooktwittergoogle_pluspinterestlinkedin

ESP826 + Pi + MQTT + Node-Red Heaven

NetioIf you’ve been following the blog you’ll note I’ve spent a lot of time getting to grips with the Raspberry Pi, Node-Red, the ESP chips using C and of course my earlier home control attempts with NETIO, the NRF24L01 boards and Arduino clones (all of which are working 24/7 – I’m just getting more ambitious).

Well, it’s all starting to come together now. This morning I just put together all the pieces I’ve discussed earlier. On my workbench I have an ESP-01 based board controlling a mains light, I have the Pi with a couple of LEDs on it and I have an ESP-12 based board with some RGB LEDs and a MOSFET driving a PWM channel.

Now, I have to tell you that I’ve discovered something I’d rather not have… the PWM output is , it would seem, driven by software, NOT by hardware. I say that as I’ve realised that if I turn on the PWM output and then start fading RGB LEDs – there is some temporary interference to the PWM – and it is visible. It goes away when the RGB LEDs stop changing however.  This does suggest that it would be better not to run both at once – or indeed palm off the PWM to a serially-driven Arduino-Micro or similar from the serial output of the ESP..  I turn off the interrupts when handling RGB and this no doubt is the cause. It’s not a big deal, it’s just slightly annoying.

However I’ve now put NETIO in charge of this lot and I have to say it’s working a treat. Here is my current test screen on the Samsung S4. I was going to use the NETIO text input box but the author doesn’t seem to have finished this off as it looks awful (it works, it just looks awful) so I’ve missed that off for now.

You can see the S4 screen over on the right. The RGB wheel works a treat, the slider controls the PWM, the LEFT on-off buttons control the LEDs on the Pi, and one of the rightmost pairs controls the mains light on another board.  Node-Red acts as the arbitrator for this lot. TCP in from the NETIO app on the phone is sent through a function block in Node-Red in which I parse the incoming data and make sure I sent back the appropriate response. It’s trivial actually once you get familiar with Node-Red.  For now I’m storing the Pi Pin states in a database but ultimately I’ll store the lot. By and large I’m just sending a message back to NetIO and then sending off an MQTT message to the relevant device as dictated to by the NETIO message.

Node Red

 

var newMsg = { payload: msg.payload.trim() };
var myMsg=newMsg.payload.split("|");

if (myMsg[0]=="gpio") {    newMsg.payload=myMsg[2];
        switch (myMsg[1]) {
            case "0":

newMsg.topic="Update pins set gpio0=" + myMsg[2];
                context.global.gpio0=myMsg[2];
                return [newMsg,null,null,null,msg,null];
            case "1":
                newMsg.topic="Update pins set gpio1=" + myMsg[2];
                context.global.gpio1=myMsg[2];
                return [null,newMsg,null,null,msg,null];
            case "2":
                newMsg.topic="Update pins set gpio2=" + myMsg[2];
                context.global.gpio2=myMsg[2];
                return [null,null,newMsg,null,msg,null];
            case "3":
                newMsg.topic="Update pins set gpio3=" + myMsg[2];
             context.global.gpio3=myMsg[2];
              return [null,null,null,newMsg,msg,null];
        default: 
                return [null,null,null,null,msg,null];
        }
}   
else if (myMsg[0]=="gpio?")
    {
    switch (myMsg[1]) {   
        case "0":
              msg.payload=context.global.gpio0+"\n";
              return [null,null,null,null,msg,null];
        case "1":
              msg.payload=context.global.gpio1+"\n";
              return [null,null,null,null,msg,null];
        case "2":
              msg.payload=context.global.gpio2+"\n";
              return [null,null,null,null,msg,null];
        case "3":
              msg.payload=context.global.gpio3+"\n";
              return [null,null,null,null,msg,null];
     default: 
              return [null,null,null,null,msg,null];
        }   
    }

else if (myMsg[0]=="mqtt") // message and topic passed
    {
    msg.topic=myMsg[1];
    msg.payload=myMsg[2]+"\n";
     return [null,null,null,null,msg,msg];
    }

return [null,null,null,null,msg,null];

Facebooktwittergoogle_pluspinterestlinkedin