During the summer months I love flying and testing out my UAV projects. But duing the winter months, the lack of day light and the bad weather really doesn’t let you get outside as much as you would like to. Thus, I started this project, the FI-ApartmentBot. The Goal from the start was to create a robot that would roam around my apartment controlled by a driver via an remote internet connection. The driver would get a live video and audio link to the robot.

Source Code

The FI-ApartmentBot source is hosted on GitHub.

FI-ApartmentBot

Note: The ApartmentBot runs on any Arduino compatible microcontroller. Thus, you will need the Arduino IDE to compile and load the code to your board. The ApartmentBot also uses the Digi Xbee wireless modems to communicate to the host controller. I use a Sparkfun Xbee USB Explorer to connect the host Xbee module to my server. The Xbee communicates over a serial connection at 9600 baud, be sure your baud rate is set properly.

Parts List

Remote Control

Controlling the robot remotly can be done in a couple of different ways. The easiest is to simply pass serial commands to the robot.

Serial Command Index

The user based commands and code is located in the UserControl.pde file. The following is how to properly construct a command to get the rover moving.

Directions
f = forward
b = backwards
l = left spin
r = right spin
Power – 1 – 255

Example Command: “f200#”

Be sure to terminate every command with a #. This is to verify that the command is complete due to the fact that command can be written with multipule line returns.

Autonomous Roving

I built autonomous control into the ApartmentBot based off a ultrasonic sensor and accelerometer. The ultrasonic sensor is used to detect the distance the robot from a obsitcal and the accelerometer is used to detect if the rover is prone to tipping over.

Usage

By default the roving system is deactived until actived by the user.

You can easily change the way the rover acts on boot and have it rove by defaut. The main sketch file in the source code has a boolean value that can ge changed named roveMode.

boolean roveMode = false;

Setting rove mode to true will allow the roving to be initialed on boot. You can also turn on rove mode from manual control mode. Passing roveMode=true# via serial command on a baud rate of 9600 will activate roving untill the boolean is set back.

Rover Tip Protection

I use a ADXL335 Triple Axis Accelerometer onboard the rover to calculate if the rover is driving on a valid angle that will not allow it to tip over. The ADXL355 allows for fast polling which is needed for when the rover is quickly moving in any direction. The sooner that a potentional tip can be calculated the better.

Lessons Learned

Battery Indicators via Voltage Division

The LIPO batteries onboard the robot carry 3.7V with 2amp of power per battery. In series the batteries produce a 7.4V output which unfortunetly to high to wire into a Arduino analog I/O. A simple voltage divider can cut the voltage in half and allow us to compensate the division with software.

To do this we can simply wire 2 10K resistors in the following way:

Voltage Divider

These two 10k resistors (R1 and R2) will cut the voltage directly in half and we can then connect the Vout to Arduino analog pin 0. Using the code example below, we analogRead(0) to get the divided voltage calculation. Reading pin0 as a 10bit value mean we would calculate the real voltage as: pin0 * 0.            0048828125 begin_of_the_skype_highlighting 0048828125 end_of_the_skype_highlighting mV * 2.

 

 

 

 

The code below is an Arduino sketch written to do just that, the voltage result will be sent via serial at 9600 baud once every second.

const int voltageReadPin = 0;
const int voltageUnitValue = 0.0048828125;
 
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  int voltageVal = analogRead(voltageReadPin);
  int batteryVoltage = voltageVal * voltageUnitValue * 2;
  Serial.println(batteryVoltage);
  delay(1000);
}

Leave a Comment