Finally the long awaited official m3pi is here, and it's looking good!


Its home page, with loads of linked resources are available at the offical Pololu m3pi page

The m3pi robot consists of an mbed connected to the Pololu 3pi robot

The 3pi contains a low level MCU that takes care of motor control, optical sensors and other hardware oriented functions. When the 3pi is programmed with the stock "slave" firmware, will make this functionality available through an API over a serial port.

The m3pi consists of an mbed Microcontroller running the high level functions and control algorithms, implemented by API calls to 3pi hardware. The mbed Microcontroller is then free run protocol stacks and communications interfaces (bluetooth, Zigbee, Wifi and so on) as well as control algorithms, mass storage for preprogrammed routines and so on.

Hello World!

This simple program will drive the m3pi forward, spin it left, reverse it and spin it right.

Import programm3pi_HelloWorld

Hello world program that just gets the m3pi moving

You Tube Clip


There is very little connectivity required between the mbed and the 3pi to make it all work.

p8RST to the 3pi
p9 (from mbed)RXD (to the 3pi)
p10 (to the 3pi)TXD (from the 3pi)

Library and API

Import library

Public Member Functions

  m3pi ()
  Create the m3pi object connected to the default pins.
  m3pi (PinName nrst, PinName tx, PinName rx)
  Create the m3pi object connected to specific pins.
void  reset (void)
  Force a hardware reset of the 3pi.
void  left_motor (float speed)
  Directly control the speed and direction of the left motor.
void  right_motor (float speed)
  Directly control the speed and direction of the right motor.
void  forward (float speed)
  Drive both motors forward as the same speed.
void  backward (float speed)
  Drive both motors backward as the same speed.
void  left (float speed)
  Drive left motor backwards and right motor forwards at the same speed to turn on the spot.
void  right (float speed)
  Drive left motor forward and right motor backwards at the same speed to turn on the spot.
void  stop (void)
  Stop both motors.
float  pot_voltage (void)
  Read the voltage of the potentiometer on the 3pi.
float  battery (void)
  Read the battery voltage on the 3pi.
float  line_position (void)
  Read the position of the detected line.
char  sensor_auto_calibrate (void)
  Calibrate the sensors.
void  calibrate (void)
  Set calibration manually to the current settings.
void  reset_calibration (void)
  Clear the current calibration settings.
void  leds (int val)
  Write to the 8 LEDs.
void  locate (int x, int y)
  Locate the cursor on the 8x2 LCD.
void  cls (void)
  Clear the LCD.
int  putc (int c)
  Send a character directly to the 3pi serial interface.
int  getc ()
  Receive a character directly to the 3pi serial interface.
int  print (char *text, int length)
  Send a string buffer to the 3pi serial interface.


Useful numbers

  • Speed of rotation: 720 degrees per second at half speed
  • Forward/Backward: 470mm per second at half speed

Hardware design prototype

1 related question:


05 Nov 2010

Amazing work! Glad to see the Eagle library is working - time to change the message [http://mbed.org/cookbook/m3pi-Development|here]? (# The 3pi Eagle library - Note, this isnt tested properly yet)

13 Nov 2010

This was a lot of fun at Arm Techcon. I got third place in the races and scored a robot. Now that I'm home, I set up a track with electrical tape on my hardwood floor. It works fantastically! I do have one question though: In all the videos on this site, the ISP cable is plugged in, but if I try to run the line follower code above with the ISP cable plugged in, the motors twitch immediately on boot and the robot doesn't work after that. If I unplug the cable, it works fine though. Is there some fuse or jumper I need to set to be able to leave the cable plugged in?

16 Nov 2010

Hi Eric,

The little ISP cable is so that we can flash the AVR on the Pololu 3pi from the mbed. For the m3pi's at the show this isn't necessary, so I took it off. The reason I took it off is because of the motor twitches you are seeing. The pins on the AVR that are used for ISP are normally used for motor control, and when both the mbed and the AVR are in reset when you first power on the m3pi, the motors are momentarily activated. The m3pi is a prototype, and this is one of the things we'll investigate moving forward.

Glad you liked the show and the m3pi!

Cheers, Chris

19 Nov 2010

Thank you Chris! Is the android app/source that you used to drive the robot posted anywhere? Some instructions on how you set that up would be great. Looks like you used the RPC above over bluetooth.

20 Nov 2010

Today i was in a seminar and worked with the m3pi. Nice stuff but where can i buy a complete one?

24 Nov 2010

Hi, where can I get a m3pi?

24 Nov 2010

Chiki, the m3pi is not yet available, but it might be a good idea to contact pololu at http://www.pololu.com/ and register your interest.

26 Nov 2010

Thanks for your answer Dan! I'll follow your advise.

01 Jan 2012

I have a pair of BTA6060 Cirago Bluetooth USB adapters. Could I use the USB connector on the m3pi for 1 adapter and the other adapter plugged into PC? Would the setup work for this device instead the RN42?

PLEASE DISREGARD! I have should have posted the above in the RPC section.

12 Mar 2012

The documentation above indicates that the nRST signal to the 3pi base is on p23. The m3pi class also uses p23 as the default for nRST. But according to the pololu m3pi user guide, it is actually on p8. p23 goes to the ISP header nRST pin. I've just buzzed out my m3pi board and confirmed that the pololu documentation is correct (nRST for the 3pi should be p8). So, not that I've tried it, but I expect m3pi.reset() doesn't achieve a great deal...

26 Nov 2012

Andrew is right.

26 Apr 2013

Hi! someone used the fuzzy logic controlled m3pi?