Pinkybot

In late 2015, I got interested in the Raspberry Pi - the single board computer that everybody was talking about. The idea of a small cheap computer intrigued me and I just had to get one to play with. Once I got one in early 2016 and got it all connected up and working, I realised that it was not much use to me as a regular computer because I already had bigger and faster computers.

However, this cute little computer just sat there begging me to make something using it so I searched the web to see what other people were building to get some ideas. The robots that others had built looked really cool so, while I waited for the parts for my smart home project to arrive, my thoughts turned to building a robot army and mad schemes for world domination! Sadly, I quickly realised that I didn't have a clue about where to start so, like any modern-day arch-villain, I turned to Google.

After doing a lot of research and exploring the expensive kits available I opted to start small and got myself a cheap robot car chassis kit and a L298N motor controller board. When these arrived in kit form with no setup guide at all I realised that now I not only had to work out how to connect the electronics and program the robot but I first needed to figure out how to assemble the physical bits!

Connecting it all up

Fortunately, there are a lot of resources on the web that explain how to connect motors and a Raspberry Pi to a L298N board so getting that far only took one weekend! Not knowing any better, my setup used 4 AA batteries to power the motors and used an emergency USB charger for cell phones to power the Pi.

Assembly

Once I had the connections done, and could control the motors using Python I turned to the challenge of assembly. Mounting the Pi, controller board and battery packs directly on the chassis I had bought was beyond my making skills. Luckily I had an empty box with a "shelf" in it that was just the right size so I chose to put everything in the box and stick the box on the chassis. This turned out to be a good design choice as I was later able to easily add a USB camera and a small speaker into the build.


Using the box also gave the kids an opportunity to get involved and do what they love - arts and crafts! Their artistic skills really brought the robot to life and gave it a personality. They also insisted on naming her...

Pinky...bot

The code

From the beginning I had wanted Pinkybot's web interface to show the feed from the camera I'd mounted to the front of it. My research led me to Motion, a great application for streaming video over a network, and this guide to get Motion installed and running on the Pi.

That was the easy part. Being an absolute beginner at coding and web development I had to learn a lot of new technologies to figure out how to create the web interface that I wanted my robot to have. Matt Richardson's excellent article on using Flask on the Raspberry Pi gave me a great start. A lot of people have shared their projects and code online but none of them had the look or functionality I wanted. After reading their articles and looking at their code, I was, after a lot of trial and error, able to get close to the interface I wanted using Apache, WSGI, Flask, Python, JavaScript and Twitter's Bootstrap library. My solution is not particularly elegant and I'm sure the code could be greatly improved, but it works!

The code isn't great but I've uploaded it to GitHub in case anyone wants to look at it.

This was a challenging but fun project. Buying an expensive kit would have made the project easier but I got a lot of satisfaction in building the robot from scratch, and I think I learnt more by doing it the hard way.

Comments

Popular posts from this blog

Welcome

Smart Home

Pi-Touch