Images

Arduino and Raspberry Pi Mars Rover

Arduino and Raspberry Pi Mars Rover

This is our very own mars rover built by Ray using Arduino and Raspberry PI, programmed in NodeJS.

Our main goal was to make programming our Rover as easy as possible and the obvious choice was Javascript, or more specifically NodeJS, however these all rely on a serial connection which meant wireless programming was a bit of a challenge. Here’s how we did it!

OK, so we cheated a little.. Controlling an Arduino board wirelessly using Javascript was quite challenging, however controlling a computer remotely is something we do every day and this is exactly where the Raspberry PI comes in.

We mounted our PI on the Arduino board and used a USB cable for the standard serial connection you’d use when programming Arduino with one of the many NodeJS libraries out there. We also set up SSH on the PI and equipped it with a £5 wireless adapter.

Now this may seem like adding to the cost of your Arduino project, but at £30 – £40 for two XBee boards it actually works out to roughly the same price, not to mention the amount time you’ll save trying to get the XBee’s to work!

Here’s what you’ll need set up a similar project:

  1. Arduino Board/Rover
  2. Raspberry PI. Older 256MB boards will do fine.
  3. USB cable to connect PI and Arduino. Usually USB -> Mini USB.
  4. 4GB or larger SD card to run PI OS.
  5. 5V Universal Battery Elimination Circuit (UBEC). This will allow your PI to run on AA batteries.
  6. Wireless USB adapter
  7. 4+ AA batteries
  8. AA battery pack. *optional
  9. 2000mAh+ LiPo battery. *optional

Once you have all your parts, decide on a library you’d like to use. We decided to go with Johnny-Five as it was fairly well documented and uses the Firmata protocol which comes with the Arduino IDE.

Next, install your PI’s operating system onto the SD card using one of the many installers available, and set up wireless networking and SSH access. You’ll also need to install the latest version of NodeJS on your PI to be able to use the library you decided on.

At this point you’ll be able to connect to your PI using SSH and program your Arduino via the USB (serial) connection, but the power supply remains, so the final step is to lose the PI’s power connection and run it using some AA batteries. Here is an excellent tutorial by Raspberry PI Spy on how to connect your battery pack.

That’s it! You should now have an Arduino with a battery powered computer onboard. Simply SSH to your PI over WiFi and control the Arduino using NodeJS.

Some things to consider would include adding a second LiPo/battery pack directly to the Arduino board to act as a reserve, should you be building anything that requires more than USB power.

We feel this setup is the most flexible and straight forward wireless setup available and will allow you to program your Arduino in exactly the same way you would with a wired connection, so please leave any questions in the comments and we’ll be more than happy to help.