I’ve had a version running on the desk with jumper wires hooking everything up, but I’ve always wanted to try and do something a bit neater. So I’ve been looking at building a custom Pi pHAT to link everything together.
The design should be pretty simple
- Break out pin 18 on the Pi to drive the ws2812b LEDs.
- Supply 5v to the LED strip.
- Include an I2C RTC module so the Pi will keep accurate time, especially when using a Pi Zero (not a Pi Zero W) with no network connectivity.
I know that the Pi can supply enough power from the 5v pin in the 40 pin header to drive the number of LEDs that the clock should have lit at any one time.
Also technically the data input for the ws2812b should also be 5v but I know that at least with the strip that I have it will work with the 3.3v supplied from GPIO pin 18.
I had started to work on this with Eagle back before it got taken over by Autodesk, while there is still a free version for hobbyists I thought I’d try something different this time round and found librePCB.
Designing the Board
All the PCB board software looks to work in a similar way, you start by laying out the circuit logically before working out how to lay it out physically.
The component list is:
- 40 pin Pi GPIO connector
- ST M41T81SMY6F – I2C RTC with internal oscillator
- Keystone 500 – Battery holder
- Weidmuller PM5.08/3/90 – Terminal block
The RTC is going to need a battery to keep it up to date if the power goes out so I’m using the Keystone 500 holder which is for a 12mm coin cell. These are a lot smaller than the more common 20mm (cr2032) version of coin cells, so should take up lot less space on the board.
I also checked that the M41T81 has a RTC Linux kernel driver and it looks to be included in the rtc-m41t80 module, so should work.
Finally I’m using the terminal block because I don’t seem to be able to find a suitable board mountable connector for the JST SM connector that comes on most of the LED strips I’ve seen. The Wikipedia entry implies that the standard is only used for wire to wire connectors.
LibrePCB has a number of component libraries that include one for the Raspberry Pi 40 pin header.
But I had to create a local library for some of the other parts, especially the RTC and the battery holders. I will look at how to contribute these parts to the library once I’ve got the whole thing up and running properly.
The Pi has built in pull up resistors on the I2C bus pins so I shouldn’t need to add any.
Now I have all the components linked up it was time to layout the actual board.
The board dimensions are 65mm x 30mm which matches the Pi Zero and with the 40 pin header across the top edge.
The arrangement of the pins on the RTC mean that no matter which way round I mount it I always end up with 2 tracks having to cross which means I have one via to the underside of the board. Everything else fits into one layer. I’ve stuck the terminal block on the left hand edge so the strip can run straight out from there and the power connector for the Pi can come in to the bottom edge.
- An I2C identifier IC – The Raspberry Pi HAT spec includes the option to use the second I2C bus on the Pi to hold the device tree information for the device.
- A power supply connector – Since the LED strip can draw a lot of power when all are lit, it can make sense to add either a separate power supply for just the LEDs or a bigger power supply that can power the Pi via the 5v GPIO pins.
- A 3.3v to 5v Level shifter – Because not all the LED strips will work with 3.3v GPIO input.
- Find a light level sensor so I can adjust the brightness of the LED strip based on the room brightness.
The board design files are all up on GitHub here.
I now need to send off the design to get some boards made, order the components and try and put one together.
Getting boards made is getting cheaper and cheaper, an initial test order of 5 boards to test from JLC PCB came in at £1.53 + £3.90 shipping (this looks to include a 50% first order discount). This has a 12 day shipping time, but I’m not in a rush so this just feels incredibly cheap.
Soldering the surface mount RTC is going to challenge my skills a bit but I’m up for giving it a go. I think I might need to buy some solder paste and a magnifier.
I’ll do another post when the parts all come in and I’ve put one together.