Bright Pi v1.0 Code Examples
To get the Bright Pi working on the Raspberry Pi, you need to enable I2C. You can find a great guide on setting up I2C on the Adafruit website here.
Once I2C is all set up, then from command line to turn only all white LEDs on:
sudo i2cset -y 1 0x70 0x00 0x5a
To turn only all IR LEDs on:
sudo i2cset -y 1 0x70 0x00 0xa5
To turn all LEDs on:
sudo i2cset -y 1 0x70 0x00 0xff
Then you need to turn the gain up to full using:
sudo i2cset -y 1 0x70 0x09 0x0f
Then you need to turn brightness of individual LEDs up. For white:
sudo i2cset -y 1 0x70 0x02 0x32
sudo i2cset -y 1 0x70 0x04 0x32
sudo i2cset -y 1 0x70 0x05 0x32
sudo i2cset -y 1 0x70 0x07 0x32
For IR:
sudo i2cset -y 1 0x70 0x01 0x32
sudo i2cset -y 1 0x70 0x03 0x32
sudo i2cset -y 1 0x70 0x06 0x32
sudo i2cset -y 1 0x70 0x08 0x32
If you need to turn all the LEDs off:
sudo i2cset -y 1 0x70 0x00 0x00
The above instructions assume you have a Rev 2 (or newer) Raspberry Pi. If you are using an original Rev 1 Model B Raspberry Pi then you will need to change the “-y 1” part to “-y 0” as the Rev 1 Model B Raspberry Pis (with 256 MB of RAM) use I2C port 0, whereas the newer models use I2C port 1.
That’s it really! You can vary brightness either by changing overall gain down, or by changing each individual LEDs brightness down. This can be done from within Python too and we will make guides up for this very soon. We are also intending to create an easy to use Python library as well as hopefully introducing support in Scratch.
For those that would like a bit more information about the exact operation of the pre-assembled LED driver chip on the board, it is a Semtech SC620 part. You can find the product on the Semtech website here and the full datasheet here. You may notice from the datasheet that there are only 8 controllable channels on this driver chip, and 12 LEDs in total. Each white LED is individually controllable, whereas the IR LEDs are controllable in banks of two. The banks of two IR LEDs correspond to the two LEDs closest to each white LED at the corner.
For information on how to assemble the Bright Pi, please visit the assembly guide page and to purchase the Bright Pi you can visit the product page here. In the pictures the Bright Pi is mounted on a Pimoroni Raspberry Pi Camera Mount which is the perfect addition to the kit.
How do you turn all the LEDs off again? 😛
To turn all the LEDs off the following code should work:
i2cset -y 1 0x70 0x00 0x00
I will add this to the code above shortly.
These code examples don’t work at all for me. http://f.bonk.io/s/YzgyNWMx.png
Anybody has a clue what I’m doing wrong?
What operating system are you using? And is this a model B rev 2 Pi?
I’ve tried both Raspbian and Arch Linux. It’s a model B rev 2 (512 MB RAM).
Try with sudo in front of the commands, just realised you didn’t have that.
Will update code examples to reflect this.
On the screenshot I’m logged in as root.
What happens if you run sudo i2cget -y 1 0x70 0x00 0x5a ?
This happens: http://f.bonk.io/s/Njk4MmZk.png
Just assembled mine, works great! Waiting for that Python code/library.. 😉
Fantastic, glad to hear it is working nicely. Python code coming soon. Python library will be a little longer.
How can i verify that I have got the IR led’s soldered correctly?
The white lights illuminate, but when I illuminate the IR led’s and then take a picture I get nothing 🙁
What voltage should be across the LED’s? and are they in series? (i.e. one bad connection would stop all from lighting?
M
Are you taking the picture with an IR camera like the Pi NoIR?
To the naked eye or a camera that isn’t IR sensitive all you would really see from the IR LEDs is a faint red glow when on full power.
Thanks
Hi,
Is there anyway to control Bright PI without using sudo? I want to be able to control the light via webpage.
If you want to use i2c without using sudo you need to add the pi user (or whatever your username is of you changed it) to the i2c group using the following command from a terminal session:
sudo usermod -a -G i2c pi
This worked for for running as pi in ssh so then I gave the www-data user that apache users the same access but didn’t work.
They way I have it setup is that by clicking on an icon on my webpage it runs a cgi script which has the i2c commands. I use this same method for controlling my pan tilt and it works great.
Any suggestions?
Hi,
I’ve soldered the board up and connected as instructed and followed the “Configuring I2C” tutorial but I can’t get any of the LED to light up. I’m running a 256MB Raspberry Pi Model B so I’m making sure I send the comments to port 0 instead of port 1. When I send the command to see the connected devices (sudo i2cdetect -y 0) I can see that I have a devices connected to address 0x70. When I send any of your commands above I get no error messages and no lights either.
Should I check my soldering? Would 1 bad solder joint cause no lights to light? Any clues or steps to debug would be greatly appreciated.
Thanks
It sounds like you may have soldered the LEDs in backwards.
Do you have a multimeter to see if the voltage between one of the LED prongs and ground changes when you turn the LEDs on and off?
If the voltage is correctly changing but LEDs do not turn on, this implies they are the wrong way round.