Page 1 of 1

Raspberry pi to turn 64 lights on and off through web app

Posted: Fri May 13, 2016 3:33 pm
by Geezup
Hello Pi community,

I would like to start a project related to an art installation.
It would involve to have a reasonable sized touchscreen (ipad/mini-ipad size) for interaction with the public and a raspberry pi controlling 64 lights individually. Those lights would be turned off by default but would be switched on via a web app accessible on the pi and its touchscreen when the user does a specific action.

I've got an idea about the front end stuff, the web app would be a mix of flask/angularJS and I guess I'll be able to control lights through an API. Now for the hardware bit, I'm a bit lost. I've read about GPIO to control sensors or switch on a light but not how to proceed for an amount such as large as 64 lights.
That link seems promising but it is still not clear: ... -gpio-pins
It mentions that "64 LEDs for example can be done with ONE 16 bit I/O extender".
Not sure what to investigate, is it possible with just GPIO boards? or I need an I/O extender?

So, summary:
- raspberry pi (got that covered)
- touch screen (what brand, where to buy in the UK, etc...)
- 64 lights connected through GPIO boards? I/O extender?
- software (can deal with front-end, need to get familiar with API to control hardware)

I've mostly read about people testing leds, I might need something a bit more powerful but I need to do some tests before being sure.

Many thanks for your time and suggestions in advance,

Re: Raspberry pi to turn 64 lights on and off through web ap

Posted: Fri May 13, 2016 3:58 pm
by nick.mccloud
What are the lights - single LEDs, LED arrays (i.e. one light made up of several LEDs) or something else, possibly mains switching?

Single LEDs can be controlled using something called Charlieplexing (Google will help).

However the SE answer gives a simpler answer by using the MCP23017. How's your hardware hacking abilities?


Re: Raspberry pi to turn 64 lights on and off through web ap

Posted: Sun May 15, 2016 4:58 pm
by Geezup
Hi Nick,

Thanks for the prompt reply.
Single LEDs for now, might look into LED arrays.

So I guess the MCP23017 I/O expander is the way to go, thanks for confirming.
My hardware hacking abilities are quite thin, I hacked a camera on a pi once with a python API so hope I'll be okay.


Re: Raspberry pi to turn 64 lights on and off through web ap

Posted: Sun May 15, 2016 5:04 pm
by cacti
With 8 x Mcp23017's you can switch 128 devices (without additional multiplexing). I have developed a Web interface to switch and schedule the switching.

Re: Raspberry pi to turn 64 lights on and off through web ap

Posted: Wed May 18, 2016 1:05 pm
by IanS
If you use a 23017 watch out for the power requirements. Each individual output can only source (or sink) 25mA, and the total chip is limited to 125mA. The output is also 5V, so you need a resistor inline with the the LED, or to use LEDs designed for 5V connectivity which have the resistor already built in.
To calculate the value of the resistor, find the voltage drop of the LED from the tech spec (typically 1.5-2V). Subtract this from the supply voltage (5V) and divide what remains by the required current.
e.g. For an 20mA LED with a 1.7V drop, the required resistor would be around (5-1.7)/0.02 = 165 ohms, then find the nearest easily available value.
I have used ... reId=10180 which allow me to directly control 8 lights per 23017, although at 11.5mA you should be able to drive 10 LEDs. These are bright enough to see in daylight from a few feet away. High brightness LEDs obviously require a higher current, often above the 25mA single output limit of the 23017, so you would need a transistor per LED acting as a switch to allow the LED to be driver by a more capable power supply.

Re: Raspberry pi to turn 64 lights on and off through web ap

Posted: Wed May 18, 2016 1:14 pm
by PiGraham
You could consider using smart pixels such as WS2812. These are addressable from a single GPIO. You can find strings or strips of these LEDs online for low cost and you can chain them. Some, such as WS2812, require precise timing which can't be done with user code but There are reliable libraries to drive them using SPI, UART or DMA hardware in the Pi SoC. ... spberry+pi

Example driving 60 LEDs:
Rob Kent wrote:Raspberry Pi driving 60 Adafruit Industries #‎NeoPixels (WS2812 RGB LEDs) without an interim controller via the wonders of the Pi's DMA controller. The LEDs are being powered by the new Pololu Robotics and Electronics D24V90F5 regulator which is capable of kicking out [email protected]!! Show me the 7805 that can do that! Obviously, there is a 3.3V-5V level converter between the Pi and the LEDs data in pin and a couple of big ass capacitors straddling the power rails to make sure everyone behaves themselves.