One of the problems with my Arduino-powered dawn clock was that 10 LEDs just don’t put out enough light. I wanted a lot more for the Mk.II, but that then raises the issue of how they are controlled. Cascading shift register ICs would be one way to go. I decided, instead, to go with I2C port expanders.
I selected the MCP23017 which I bought from Adafruit. This has a configurable address so you can use more than one on the same I2C bus.
I thought for a long time about how to mount the LEDs. I’m fairly challenged when it comes to mechanical things, so opted to go for a number – actually four – discrete panels. Each would host 16 LEDs controlled by their own MCP23017.
Back to Adafruit, this time for its lovely Perma-Proto PCBs. If you’re not familiar with these, they’re basically prototyping boards, but laid out in the same pattern and with the same connections as a classic breadboard. They’re not cheap but, from my point of view, had one advantage over normal trackboard in that they’re white, and thus nicely reflective.
As mentioned in the previous post, in order to simulate dawn, the first eight LEDs to come on are red, the next eight yellow, then alternating red and yellow, then alternating yellow and white. The remaining 32 LEDs are all white.
The boards look quite neat from the front. But there’s lots of paddling going on at the back.
I used two pieces of aluminium strip to mount the boards on. With all four mounted, the interior of the clock looks like this.
I figured I might be using other I2C devices, too, and I wanted to be able to use them at 5V logic, so I created a breakout board providing multiple headers to plug in I2C devices, with a bidirectional level shifter to connect safely to the Raspberry Pi’s 3V3 logic.
I also broke out a couple of the RPi’s GPIO pins. One of these is connected to a PIR motion sensor, mounted just below the clock’s LCD panel. Incidentally, the LCD panel is another I2C device, this time from Devantech.
I also thought I’d want at least a couple of analogue inputs, so I installed an ADC chip on the board. I’d bought a bunch of these 10-channel I2C devices from HobbyTronics, so used one of those. In the end, I’m only using one analogue sensor – a basic light resistor – so a 10-channel ADC is definitely overkill. Oh well, at least there’s plenty of scope for expansion. The light resistor is used to measure ambient light levels – ie, to decide when it’s dark. It’s mounted inside the both, at the top of one of the metal strips on which the LED panels are mounted. That way it’s behind the front panel, which acts as a general diffuser. Of course, the software for the clock doesn’t take ambient light readings when any lights are switched on!
The pic shows the breakout board. If you value your sanity, don’t try to make sense of it. As an electronics naif, I have a bad habit of designing boards as I solder. There are, therefore, bits of this board that were never used, especially in the lower third…
The other analogue device I thought I was going to use was a temperature sensor. In the end, however, I opted for the BMP085 I2C breakout board that provides both a nicely calibrated thermometer and at atmospheric pressure sensor. It’s not cheap, but what price perfection?
I positioned this near the top of the box, at the side, with a hole to the outside world. Once I started using the clock, I found that the measured temperature was rising by about a degree during the period the lights were on. Obviously, the inside of the box was heating up & skewing the measurement. I made the hole to the outside world bigger, moved the sensor closer to it & stuck some foam behind the board as crude thermal insulation. But the problem persists, so there’s more work to be done.
The RPi used is a revision 1 board – so no mounting holes. In order to mount it, I butchered a ModMyPi case. The bottom half of the case was screwed to the case. I cut a big hole in the top of the case, partly to give access to the GPIO pins but also as a cooling measure. This RPi is left running 24/7 so overheating was a concern. To that end, I also mounted heatsinks on the main chips. In the following pic, you can also see the audio amplifier – but more on that in a subsequent post.
Network connection is provided by a Netgear N150 USB wifi dongle. This has proven to be remarkably reliable, especially given that the wifi AP is one floor down. It worked without any configuration with the current Raspbian build. I have configured the home router to assign this device a fixed IP (based on its MAC), so that I can easily SSH into the RPi and also connect to its web server. The only problem with the dongle is that it has a built-in LED that flickers to indicate network traffic. This would be very annoying in a darkened bedroom, but some black gaffer tape soon sorted that. (This would become a common theme.)
The next step was to provide power. As we’ll see in the next post, my original plan for the audio output was to use the innards of some Logitech PC speakers. The power supply that came with them output 12V, so I figured I might need a 12V supply for the dawn clock, in addition to the 5V required by the RPi and breakout board. It just so happened that I had a couple of these devices from DFRobot.
In addition to providing a switched 5V (or variable) output, this board will also pass through what is supplied to it. With an external 12V, this would easily allow me to power everything in the clock.
In the end, I decided against the Logitech kit and went with a USB-powered sound card. For reasons I’ll explain later, I may replace this power board with a power distribution board of my own, outputting just 5V.
Anyway, with the light panels removed, here’s how the interior of the dawn clock looks ->
Next time I’ll talk about the audio stuff…