ESP8266 and RB Serial LEDS

rgb ledsWell, it looks like everyone and their auntie have figured out how to get Arduinos to listen to ESP8266s sending out messages and control RGB serial LED strips – not surprising as there are several Arduino (and for other boards) serial libraries out there. I’m not talking about old fashioned 12v RGB strip but the more modern 5v variety with serial control, which, when (if) they get the price down, HAS to be the future of lighting.

I was at a hotel in Blackpool a few weeks ago and they’d just modernised and had the serial LED strip EVERYWHERE. If you’re not familiar with this stuff, each LED has a serial controller and can accept RGB settings – and once set can simply pass the info to the next LED. All of this is done with blindingly fast serial, so fast they build huge TV displays at airports using the stuff. Why is this stuff so much better than the old PWM red then green then blue LEDS? Because all 3 chips are in one housing you can create REALLY subtle lighting – you want daylight? No problem Tungsten? No problem? Nice warm candle-light? No problem.

Grab a strip, fasten it to an Arduino, provide plenty of 5v and a library and you’re up and running. You tell the library how many LEDS you have and it builds an array of 3 bytes for each LED. You populate the RGB info for the LEDS, call a function and BANG – they all get updated in an instant. with that array at hand it is trivial to write code to drive a colour wheel through it and by updating at regular intervals, create a moving colour change along the strip that is nothing short of stunning.

Right – that’s the easy way and also the larger and more expensive way. Now when is some clever person going to provide us with the same library (in C, not Lua please) for the ESP8266. Should not be a problem as the chip is way faster than an Arduino. I am not familiar enough with the chip to do this yet but I’m hoping someone else is – or has already done this – any takers?

Add this to the current MQTT code and you have an instant WIFI lighting controller. If antone has this or can make this I’m quite happy to put an article together – once I have my hands on a library (preferably working with GPIO0 or GPIO2 on the ESP-01 as that’s the cheapest and smallest solution out there but is pin-challenged).. it’ll take me no time to get that under message control.

100,000 Hours Bollocks

As someone who’s used LEDs both professionally and for my hobby since, oh, the 80s, I’ve always had my suspicions about WHITE LEDs.

As you may know, WHITE LEDs differ from the rest in that there is no such thing as white – it’s a combination of wavelengths, unlike blue or green or red… so in order to make white LEDs you can either:

1. Put a phosphor on a blue/UV led

or

2. Make a die with red, green and blue close together on the same chip and run them together with the right proportions

Mostly we chose (1) and for some time now manufacturers have been belting out WHITE LEDs en-masse without regard to lifespan – merely quoting the ideal-case figure of 100,000 hours in most cases.

But a trip to MAPLIN or any lighting store (B&Q) where demo white LED spotlights are running will reveal – duff or dim LEDS.. why is that?

Well, it seems that coloured LEDs, as long as they don’t overheat really CAN manage obscene lifetimes – but the whites? That’s nowhere near as clear.  My gut feelings tell me they don’t last anywhere NEAR as long – but that’s all it’s it – or was – take a look at this link and read for yourself – this kind fellow has taken the time to do a little research of his own.

http://www.nickhill.co.uk/white_LED_life_expectancy.html

What’s the answer? Well my answer – I plan to use the new RGB LED strip (WAY more expensive than the one-colour-per-LED stuff) with 3 colours in one chip – as much as possible.. and the added advantage…   you can chose what white temperature you want – think there’s only one WHITE? Think again.  Warm white, Cool white, Cold white – it’s all down to the mix of colours and with modern LED strip you can have any mix you like – without using phosphors!!

Bright LEDS

tmp3061Just for the sake of it I bought 10 LEDS from China from Ebay, not your normal run of the mill type but the new ultra-bright types they use on mains lighting. I think I paid about 20p each if that and had to wait a couple of weeks – but they are amazing.

As you can see in the photo they are meant for surface mounting but they’re not too small to simply wrap a thin wire around each end. Anyone with ANY soldering skills should be able to make use of these around the house – but the power requirements are a little more interesting than, say a filament light. Like all other LEDS these are current-driven, not voltage-driven so you have to be a little careful – never connect them to low-voltage power without a resistor or you will send them to their maker.

tmp7444The operating voltage is around 4v but the key thing is to ensure they get no more than maybe 250ma. I have a power supply with current limiting so I simply set the voltage to 6v with maximum limit of 250ma (which means the voltage will drop accordingly to ensure no more than 250ma). With 3 in series they’ll run off 12 volt with a simple resistor or preferably a current limit circuit.

The results – amazing – they do get slightly warm and I guess they should be mounted on a board with a little copper or aluminium underneath for constant operation but I can see lots of uses for these! The photo on the right really does say it all – blinding white light. At 4v, 250ma you’re looking at around 1 watt – which is exactly what they’re supposed to take – typical GU10 lights might use 3 of these – but I’m thinking SAD LIGHTING. Imagine what a row of 50 of there would look like in a row – certainly get you up in the morning for a mere 50w!

There is now widely available LED strip in a range of colours- it’s bright but not super bright – what would it be like to see a strip using these babies! The day of halogen car lights must surely be near it’s end?

There are of course no shortages of people trying to sell expensive supplies for this “new” lighting – which has in fact been around for over 40 years – just not so bright – but in fact there are simple ways to drive these – as usual, Instructables has something to say on the subject… http://www.instructables.com/id/Power-LED-s—simplest-light-with-constant-current/  though personally I think it would be cheaper to use 2 diodes (base to ground), a pull up resistor  of maybe 1k (base to +), a BC337 and a 3r emitter resistor (to ground)– but there you are…

The Mighty 1284p

The 1284p is the next step up from the ATMega328 chip powering many of the “Arduino” type microcontroller boards and their many clones.

Why another chip? Well, anyone who has used the ATMega328 knows that it’s a great controller chip but the lack of RAM soon gets very tiring. Also if you’re messing with things like Ethernet and maybe you want a Real Time Clock, perhaps access toSD memory, the libraries have a habit of filling your FLASH memory much faster than you’d like.

1284p chipWhy the 1284p? That’s simple – there are only so many of these chips in DIP format – that is the old 0.1” pin format that is easy to use for prototyping – the other upgraded chips are surface mount and a PAIN to solder.

The 328 chip has 32Kbytes of FLASH (for your programs), 1K of EPROM (for storing data permanently) and 2K of RAM (for variables). The likes of the Ethernet code EATS up the RAM in no time. Finally, it’s also quite easy to run out of Interrupts and port bits.

Don’t get me wrong, the 328 is a great general purpose chip but it has it’s limits. A  problem with many other chips is the cost – by the time you’ve finished you may as well have bought a Raspberry Pi and the idea surely is to keep costs low.

Well, the 328 can be as cheap as a couple of pounds or so… and the 1284p can be had for double that. What do you get for your money?

  • 128K Flash (ie 4 times as much)
  • 16K RAM (ie 8 times as much – MOST welcome)
  • 4K EEPROM(4 times as much)
  • 32 pins as against 23
  • 3 interrupts as against 2
  • 8 analog ports as against 6
  • 2 UARTS as against 1

As you can see in the diagram above, putting together a prototype board is a snap (provided you have a TTL-USB converter which I use for all my kits.)

Here is the information you need. If you’re starting from scratch you need the Arduino IDE, the TTL to USB converter (for programming) and a few bits and pieces for your prototype – information for that is all here.

tmp4AFFFollow instructions and you get this on your IDE bottom right when you’ve set the right board..

The standard BLINK test which flashes a LED once a second, when modified to use output 16 – will flash physical pin 22 on and off as per my photo demo above.

Thanks here to Aidan Ruff for pointing me in the right direction and supplying the test chip – which will soon end up in some long-abandoned project (because I ran out of room in the ‘328). Magic.

Annoying Police Lights

Sunday morning, not in the mood for anything complex but I’d just purchased a pair of ATTINY85 chips and I was looking for a quick test project. To explain, the ATTINY85 is an 8-pin mini-processor, a kind of toy Arduino chip. Easily programmed from the free Arduino IDE with a handy Arduino (no need for a special programmer) the chips are ideal for simply flashing lights and possible more complex projects but due to lack of memory and interrupts don’t think you’re going to be able to make something really complex with these.  On the upside however they need NO external components to operate – i.e. no crystal, no reset, nothing.  They can quite happily operate at around 8Mhz from an internal oscillator.

Of course you’re going to want to see for yourself – hence the policy flashing light project. Now if someone were evil enough once could have a whale of a time catching speeding motorists out with this but I would not recommend it as it’s probably illegal and you’re likely to get punched… but it’s a nice thought. This little project from a distance will look all the world like it’s mounted on a policy car.

Rather than rant on here I’ve put the whole lot into a short video. You’ll need a PC with Arduino IDE1.0 or better, an Arduino of some sort and the bits to make the project up i.e. 2 or 4 LEDS, a battery and an ATTINY85 chip. All the details are in the video as is the code near the end.

You could go up to a maximum of 3 BLUE and 3 RED LEDS – OR of course if you REALLY want to go to town, just use 2 of the outputs, stick a couple of BC337 transistors on the outputs (via 470r base resistors) and feed 2 LED STRIPS – one RED, ONE BLUE…from 12v.   Hey… you could make a REAL police car (well, not quite)..

 

ATTINY85 driving LEDs in a format like Police Car strobes.

Solar Led Circuit

It’s not very often I bring you a circuit – but this is quite fun to play with and simple. I don’t claim to have come up with the original design – but then the original was only 3 components….

Here we see a circuit that a first glance should do very little.  the circuit is a little misleading in that actually we’re looking at 2 or 3 white LEDS in series such that the turn-on voltage is higher than the battery voltage. Imagine (in conventional terms which of course is wrong) juice coming out of the + of the battery, through half of the coil, through the LED – except no – the battery is not high enough voltage so essentially nothing happening there and in any case, the second (rightmost) transistor is turned on so you’d still not get any LED lighting up – you’d just drain the battery and probably blow the transistor.

Ok, but that doesn’t happen because the FIRST transistor is holding the second one OFF due to light from the solar cell generating a voltage into the base of the first transistor.

Of course that’s all wrong – in fact, the coil, 1k resistor and second transistor form a reliable oscillator when not held off – I might be wrong but I seem to recall it’s called a Colpitts oscillator!

So during the day, the solar cell is charging the battery, the 47k resistor is turning on transistor one which is holding off transistor two. Result, very little current flowing – battery gets charged.

Comes night-time, the solar cell generates nothing, the first transistor turns off – the second transistor starts oscillating like mad. Because there is a coil involved, there is a back voltage caused by the oscillation – which generates pulses of MORE than the battery voltage-  and the LEDS light up brightly.

Where this circuit would normally not do too well – and variations of this are common on cheap Chinese solar garden lamps- is that at twilight the LEDS would partly come on – and they end up flashing and all sorts.  the 330k resistor provides positive feedback to arrange a snapping action – ensuring the LED does not come on until it’s REALLY dark, then stays on until it’s reasonably light – no dim lighting or half-way house – the only issue being – the current coming back from transistor 2 comprises pulses – which we don’t want – hence the solitary capacitor on the circuit!

Simple solar circuit

Try it – works a treat.  The coil, well, I had one of those ferrite rings, maybe an inch diameter, you can see it in the photo below – it’s blue. I simply wrapped thin wire 20 times, brought out the centre-tap – another 20 times… that’s it.  Solar cell is around 5” square and generates 6 volts off load – a bigger one would be nicer.. the battery is merely 3 1.2v AA 2500MAH NIHI batteries in series and for LEDS I used some 10mm whites – in total I had 6 of them (2 sets of 3 in series) – lights up part of the garden a TREAT for several hours. I was planning on trying again to night but guess what – it rained overnight!

 

Simple solar circuit - soaked

If Only Advertisers were Honest!

tmp77FD

Special Solar Lights – Not WORTH a Light

Specifications:

  • Fairly bright white LED for 5 minutes
  • Powered by the sun if there is any
  • No-where NEAR weatherproof
  • Auto-sensor – turns on FAR too early
  • Cheap plastic construction, will fade and crack
  • Old-fashioned NICAD battery inside
  • Rubbish Chinese junk

Please note: Output depends on sun, as these are pointing up and the UK sun is NEVER directly overhead, we waste most of the sunlight so don’t expect much.

The Humble Light Bulb, the Compact Fluorescent the myth of the long-lasting white LED

I’m one of those retentive types that ensures they have low energy lightbulbs all over the house, purely and simply because having a background in electronics I’m very much aware of just how grossly inefficient incandescent (standard) light bulbs are. We generate all that CO2 and heat in order to produce more electricity – to pipe it into your homes – to power bulbs that, by and large, just generate more heat. The amount of actual light compared to heat is tiny.

So it was with great delight when B&Q first started selling low energy compact fluorescents that I bought a couple to try – but due to the absolute rip-off price at the time – I waited until IKEA started selling the 11w versions at about £1.99 before completely kitting the house out. They’re now down to something like £1.00 but even then there are those diehards who aren’t too good at math who say “why would I want to spend £1.50 on a bulb when ordinary ones are less than 30p.

Well, that argument just went straight out of the window folks – I was at Morrisons a couple of weeks ago (this is a UK-based blog for anyone reading outside of the UK – sorry – but I’m sure the USA will have similar bargains) – and I was blown away. They’re selling packs of TWO of these bulbs – for 49p.

Yes, that’s less than 25 pence for an electronic low-current bulb. Needless to say – I bought a few. Even in Spain where they are generally WAY more expensive (we’re talking 6 euros or more) I spotted at Carrefour twin-packs of 20w lamps for a couple of euros which isn’t at all bad. Hopefully now we can see those horrible old filament lamps resigned to history – where they belong. Until the LED housing manufacturers decide to look past the end of their incredibly greedy noses – CFLs it is! (White LED lights themselves are typically under 20p for decent bright diodes – but somehow once 3 or more of them end up in a light fitting – the price seems to go up by many, many times – that will change eventually. There is a building in London near Victoria who’s entire front lighting is in multi-colour LEDS – it is incredibly bright – so it’s only a matter of time before we’re all using them.

Beware however – not ALL modern lamps are a god-send. Current white LED technology simply does not last no matter WHAT the claims are.  Resellers blindly repeat the general claim of LEDS lasting countless thousands of hours – but WHITE leds are not ordinary leds. Make sure you keep the receipt!