A brief introduction to BreakfastSerial

Introduction

In my post on Y-Hack I touched upon a Python based technology called BreakfastSerial. Some of you Arduino fans out there may already be familiar with it, but for those who are not I have provided  short guide below.

BreakfastSerial is a Python based library that allows you to write Python code that can be run on the Ardunio.

The technology

The library runs on top of a technology called Firmata.

Firmata is a generic protocol for communicating with Microcontrollers from software running on a host computer.

You can read more about the Arduino implementation of Firmata at the Arduino.cc website:

http://arduino.cc/en/Reference/Firmata

BreakfastSerial works by allowing you to interact with Firmata loaded onto your Arduino by writing Python code.

You simply upload Firmata to your Arduino board, and then can start writing Python applications that use it.

We will look at an example next.

Setting up Firmata

In this post I will only be covering the steps for the older boards such as the Uno. There is a separate post in the works for the YUN. I will also be assuming you are using a Linux like environment (Ubuntu, Mac terminal window, Cygwin etc.)

To start with you will need to open up the Arduino IDE sketch pad, if you haven’t download it already you can find it at:

http://arduino.cc/en/Main/Software

Note, that depending on your Arduino model (e.g. Uno versus YUN) there are different versions of the IDE.

Once you have the IDE installed, you can find the Firmata software under:

File -> Examples -> Firmata -> StandardFirmata

Next connect your board up to your computers USB port and upload the sketch.

Once uploaded you can then move onto the testing out BreakfastSerial.

Installing BreakfastSerial

Open a terminal window on your machine and using pip grab the latest version of BreakfastSerial from PyPi
pip install BreakfastSerial
I tend to work in a virtual environment when using Python. If you wish to do the same, you can create a virtual environment as follows
virtualenv --system-site-packages Ardunio
This will create a new directory called Arduino with a Python virtual environment in. From within this, you can activate it using
./bin/activate

If you don’t have virtualenv on your machine you can grab it using pip:

pip install virtualenv

Next we can create a test project using Python. Before we do this though, take an LED and attach it to digital Pin 13 and Ground on your Arduino – yes you guessed it we are going to make the LED blink.

Once you have your hardware hooked up, create a new Python file called blink.py for example:

vim blink.py

Inside this file we are going to add the following code:
from BreakfastSerial import Arduino, Led
Here we are importing Arduino and Led from the BreakfastSerial library.

Next let’s add the following code:
board = Arduino()
pin = 13
led = Led(board, pin)

This sets up a variable board with an instantiation of Arduino and a
pin variable set to 13 (where you attached your LED). Finally the
led variable is declared with a copy of Led(), which we pass board
and pin to as arguments.

Once you have added the above, we can include the final piece of code that creates the blinking action:
led.blink(200)
the above is pretty self explanatory. The led is switched on, we wait two seconds and then it is switch off.

Save the file and exit.

We can now test our application. From the command line run:

python blink.py

You should now see your LED blink.

And that’s all there is too it really.

There are a host of examples you can try located on the BreakfastSerial site:

https://github.com/theycallmeswift/BreakfastSerial/tree/master/examples

have fun!

 

Robots for home automation – The Mint

The Mint

While visiting Best Buy one day we noticed they had a sale on in the vacuum cleaner area. It was here I spotted an Evolution Robotics Mint for sale (the box had been damaged).

Since the price had been reduced by a a decent amount (it is normally around $240.00 USD) we decided to purchase it and give it a try.

The Mint is a robotic floor sweeping and washing device that uses either Swiffer pads or Microfiber cleaning clothes. You hook the pad up to the front of the device, and using a North Star GPS system the robot will then navigate around your floor cleaning as it goes.

There are two cleaning options to choose from, either dry or wet (to mop the floor). These can be selected via button on the top of the device.

Mint floor sweeper

Mint floor sweeper

The robot has sensors built in as well so that when it reaches a ledge it knows there is a drop and pulls back.

The Mint comes with a rechargeable battery and wall wart so you simply plug it into the wall when finished so it is charged and ready for your next use.

You can see an example here including the device specs on Amazon:

http://www.amazon.com/Evolution-Robotics-Mint-Automatic-4200/dp/B00408PCEW

Review

So what do I think of it?

Unlike regular swiffering the device is pretty slow, however if you plan to just turn it on and leave it in a room while you do something else, this shouldn’t be a problem.

Obviously due to its shape it can have problems reaching certain areas, so you may need to still manually clean them. One nice benefit though is that it is small device so can fit under couches and tables far easier than a regular vacuum cleaner or mop. This saves having to move furniture around which is nice.

The battery life seems to be pretty good so far. It takes a rechargeable AA style battery pack so theoretically should be easy to replace if the batteries stop holding a charge.

An issue many people may find annoying is that it ‘bangs’ into things. So if it is attempting to clean under your dining room table, you can expect it to hit a lot of chair legs as it goes.

How would I rate it?

Useful! If you have an areas of the house where you can just put it down and leave it to go, it is a great benefit. The price tag though is a little steep compared to just using a regular Swiffer.

If you can get it on discount I would recommend it though.

Conclusion

Since purchasing the Mint it looks like iRobot have bought the brand out and now sell it under the iRobot Braava name:

http://store.irobot.com/family/index.jsp?categoryId=23314286&s=A-ProductAge

iRobot already offer a number of other robotic home cleaning devices, including pool cleaners, gutter cleaners and vacuums.

Devices such as these are starting to show that there is a market for home automation with regards to cleaning. I believe this market will continue to grow and we should start to see some real innovation emerge over the coming years.

Yale Hack-a-thon (Y-Hack)

Y-Hack

This weekend I had the opportunity to be a mentor at Y-Hack. Y-Hack was Yale University’s first (inter)national Hack-a-thon event that saw teams from all over the US, Canada and England gather for a 24 hour coding battle.

The prizes included the chance to present your software to Google and Microsoft, cash, gadgets and books.

Hosted in Yale’s West Campus, over a 1000 students gathered into teams of four and grabbed any free office and cube space going. From 6pm on Friday through 6pm Saturday teams battled away at building original software and hardware projects.

I staid at the event from 6pm until 6am – the overnight shift – and got the chance to see some great talks on the various frameworks and APi’s out there. I also had my first taste of Google glass which was interesting.

One talk in particular that caught my eye was BreakfastSerial – a Firmata based Python toolkit for interacting with Arduino over serial. I’ll be following up on this in more detail in my next blog post.

A team from NYU (Laser Lock) also built a project using Arduino and LEDs (and won four copies of my book!) and another group were using Arduino to build a breathalyzer, so lots of fun projects for the judges to review on the Saturday when it came to prize time.

Hopefully the team at Yale will host this again next year.

I also have special shout out to the team from Rose Hulman for using HTSQL to build the PIXL site and winning the HTSQL prize:

https://pixl-rhccdc.rhcloud.com/

The list of winning teams can be found on TechCrunch:

http://techcrunch.com/2013/11/09/yale-adds-another-stop-to-the-college-hacker-circuit/

And a list of entries can be found at Hacker League’s website:

https://www.hackerleague.org/hackathons/y-hack-at-yale/hacks/

All in all a great event!