One of the issues I've had with previous robots (and other contraptions) is managing to plug cables in the wrong way round, something that's especially easy to do when using jumper leads as they are typically not joined together and can get mixed up in oh so many ways (Not to mention the fact there's 40 pins on the Raspberry Pi to actually connect them to).
To try and avoid this happening I try to add dedicated connectors for each component, preferably of the kind that can only be plugged in one way. So last night I grabbed an Adafruit Perma-Proto Pi HAT board out of the box its been living in for the past few months and began to prod it with a hot stick (well a soldering iron).
With such small components it can be difficult to rectify an error so its best to take some time to work out what you need connecting up, and where. For OptimusPi pretty much everything connects via I2C, some components using the regular I2C pins, and the rest using GPIO pins 5 and 6. However I also need to have the SenseHAT connected, and it needs to be on top so I can get at the joystick and use the LED matrix. Due to the ways that the pins connect up on the Adafruit board that just left the one side I could easily bring connections out to.
After moving things around, trying out different connections and seeing how things looked when connected to the RPi itself I decided to have the 'external' I2C connector in the bottom right corner (above the AV connector) and the OLED in the middle (covering the HDMI port, but I don't plan on using that) which leaves room in the bottom left corner for future expansion (Maybe my RTC will end up there).
Constantly checking the connections to make sure I don't wire things up backwards I added the necessary wires to connect the GPIO pins to the correct locations on the lower half of the board and, before plugging it in, uses a multi meter to double check everything was connected as expected.
As I didn't have too many right-angled connectors in my box of bits I had to modify one of the 'straight up' connectors by lowering the pins (heating them with the soldering iron and pulling them through the plastic) and bending them with a pair of pliers. So adding the I2C connector took a little longer than it needed to. However everything was finally connected, so time to apply the power.
A couple of checks using 'i2cdetect' to make sure the OLED and SenseHAT were being correctly detected and I fired up the OptimusPi binary and was happy to see the OLED working. Of course with it mounted on the side I have to go and tweak the code so the joystick works as expected. But where does that other wire go?
Well one of the other components I picked up recently was the Grove I2C hub. which I've mounted underneath the Raspberry Pi (I may move this as, whilst its nicely hidden, its a bit of a pain to reach). This replaces the I2C 'expander' I'd home-made previously, with the added benefit of ensuring you can't connect the cables backwards.
With the Raspberry Pi all connected up I turned my attention to the Arduino controlling the motors. This time it was an Adafruit ProtoShield I soldered up, and so far only the I2C connection that I've soldered in. I actually need to go and revisit this and use a proper connector (Not sure why I didn't... was getting late!) but for now this makes it a little easier to wire everything up.
I have a few other items I want to connect up to the Arduino, if I have time that is, but for now I need to make sure all the basics are working again before adding extras.
As a reminder of how little time there is left my PiWars timetable turned up today, and about the only challenge I'm ready for is the Obstacle course!