Connecting to Arduino Robot Control Board using Bluetooth… kinda.

For the last two weeks my work with the official Arduino Robot was a blast. I decided I want to send commands to the robot using bluetooth, since it will be much easier to control it like that. The thing is… this didn’t work. After lots of research on Arduino forums, stack overflow, github issues and many more, I got fed up with making the robot work, and started looking for workarounds.

Why a workaround?

You might wonder, why I need to make a workaround for a “fully” functioning robot?

The idea

To make this work, I’ve added an additional (what I called) “transmitter board” that was basically an Arduino UNO. The board connects with my PC using the HC-05 Bluetooth component. Then using the I2C connection I connect using the Wire.h library and send data over cable to the Arduino Robot Control.

I’m not saying that my way is the best possible, but at least it works :)

Arduino UNO

This is the code I uploaded to the Arduino UNO. First I’m starting the Serial to get information from the bluetooth. Once I receive “#” from my PC Python code, I blink the test LED and pass the character through the Wire.h library to the Robot.

// Include the wire library
#include <Wire.h>

char character;

void setup() {
  // Start bluetooth serial
  Serial.begin(9600);
  // Begin wire connection
  Wire.begin();
}

void loop() {
  while(Serial.available()) {
    character = Serial.read();
    if(character == '#') {
      // Write the character to Robot Control
      Wire.beginTransmission(9);
      Wire.write(character);
      Wire.endTransmission();
    }
  }
}

Arduino Robot Control

First let’s start with the Robot Control pinout. This is pretty bad documented, but thanks to the internet I’ve got this figured out for you. Connect the GND, SDA and SCL to appropriate pins, like shown on the schematic and the image below.

And now the code you can throw into your Arduino Robot Control board. First we need to import the libraries, then setup Wire and speakers for testing. Then what is left is to receive the message and do something with it (in this case, beep the Robot).

// Include the libraries
#include <ArduinoRobot.h>
#include <Wire.h>

// This will keep the message we get
String message = "";

void setup() {
  // Start Robot modules
  Robot.begin();
  Robot.beginSpeaker();

  // Create a receive event
  Wire.begin(9);
  Wire.onReceive(receiveEvent);
}

void receiveEvent(int bytes) {
  // Get the message when available
  while(Wire.available()) {   
    char c = Wire.read();
    Serial.print(c);
    message += c;
  }
}

void loop() {  
  if (message == "#") {
    // Do a test beep!
    Robot.beep(BEEP_SIMPLE);
    message = "";
  }
}

Final image

This is how it looks before soldering. Of course in order to actually use it, you need to make the whole thing smaller (to mount it on the Arduino Robot). There are also a bit more cables than on the schematic, because I’ve added an additional LED to visualise when I get bluetooth data for test reasons.

Breadboard view during testing.

Everything mounted on a mobile robot.