Yes. Buses again.
I had a Raspberry Pi and a PiLite lying around begging for a project to be done. So I bought some four char alphanumeric displays with I2C backpacks from Adafruit and built a bus time indicator with them all. It works perfectly and looks good inside a custom made laser cut enclosure.
I suppose the project started with the code to get the bus time data from the internet. I initially wrote this to put the bus times on my pebble. The important part is a PHP script that scrapes a web page that displays the information. This is then served in JSON form. this step just makes reading the data easier.
I had the PiLite lying around from Derby mini maker faire. It looked good so I bought it but then took a while to get around to doing a project with it. I only had the Pi because it was a christmas gift.
The first step in this project was wiring up the I2C LED displays. These are four character alphanumeric displays from Adafruit. I had to write a library for them myself, I was surprised that Adafruit hadn't done this as they are usually good at writing these things quickly. They had one for Arduino and so adapting it wasn't difficult. If anyone wants it my library is on github. Anyway, back to wiring. I did take photos of the process of wiring up these displays but somehow they got lost. They weren't anything super exciting, just photos of some wires soldered on to the I2C pins on the PiLite. The PiLite exposes all of the pins on the RPi header. This is a useful feature, it makes it easy to expand it like this. The wires split into two and feed into the two displays. I did of course need to make sure the displays had different addresses and so the A0 jumper is soldered on the red one.
Once this was done it was a case of writing the software for the Pi. Now, I don't really like python, but it has its uses. Unfortunately python was ideal for the job. Libraries were available for the I2C for the LEDs, the serial needed for the PiLite, http client for getting the data and JSON for parsing the data. If any other language already had all of these, I'd use it instead. Especially if it was pascal. I like pascal, pascal does good things, more on that later perhaps.
If you want to get your hands on the software for the BusPi, that is also on github. The bus_display.py script is the main script. I added this into /etc/rc.local so that it would start on boot. It works perfectly. Internet is provided by a tiny USB wifi dongle that is set up to connect to my home wifi.
With everything working electrically, I decided to design a custom laser cut case for it. The design is made of lots of layers. There is a back layer that has mounting holes for the pi, this is followed by five hollow layers and then there is a clear acrylic layer to which I added a sheet of paper to diffuse the PiLite and then there is the front face with some stuff on it.
When designing the hollow layers, I decided to try and avoid wasting too much acrylic by making the these layers out of four small strips. A pair of side strips which have holes to mount alongside the other layers support the top and bottom strips using small notches cut in the plastic. This worked fairly well but could have been better.
You'll have to forgive the bed sheets background. Often the bed is the biggest free space available to me.
These are all of the laser cut parts...
(Click any image for a bigger shot) On the left is the pi with PiLite on top, wifi plugged in the right and four char displays wired in near the left edge. If you look closely at the front face you will see the bus has no windows, the design file did however, I'm not sure why this happened. The company that did it was razorlab I have had stuff from them before and it isn't the first time they have got the raster etch wrong. Also, somehow, on the back plate there are eight holes missing. These were going to mount the four char displays. Hmmm. I found a way around it though. On the right is the used acrylic. you can see that it is well worth putting the effort into making the hollow layers smaller, especially as I needed five. By doing it this way I had room for a spare for very little price difference.
Assembly went fairly smoothly although it was rather awkward getting the top and bottom bars in place for the middle layers. There was too much play in the holes for the bolts that keep everything together and so until these were tight the top and bottom bars were loose.
The power cable was a little bit of a problem for the design. Power has to go in through the USB on the Pi. To avoid having a hole in one of the side bars (making some mid layers less rigid) I had a hole in the back plate and sourced a USB cable with a right angle micro B connector. This was fairly cheap on ebay.
Photos of the Pi going in...
Once that was in it was simply a case of plugging in the PiLite and lining up the four char displays. I didn't photograph this bit. Too fiddly.
To get the four char displays to fit, I had to fold over the header pins a little.
After that it was a case of blutac and sections of sponges wedged behind to keep the displays in place.
With that done, the BusPi was ready.
You may notice in the video that the word 'min' only takes up two chars on the display. I noticed this was possible and so made this a feature so that you could fit a time like '12min' on to a single four char display without truncating it. Comments in the code show how that is done. The red display on the left shows the service number of the bus, the blue display on the right shows the estimated time until it arrives. This can be a clock time or a number of minutes or simply the word 'Due'. The live timing service will give you a clock time as per the timetable if a particular bus doesn't have a tracker installed. Most of them do however.
Time for a video;