Electronics

Adding bluetooth control to Clumsy the robot

Aside from the autonomous function of the robot, I wanted to be able to control it with my smartphone. The electronic guy at work pointed me toward those very cheap modules, saying that they were crap and a pain to solder but that it was alight considering the price. 3 weeks later, here they were !

BT1
BT2

I burned one module trying to solder the ridiculously tiny pins but the feeling when I blinked a led for the first time via my cellphone was worth it ! The only pins I needed were the VCC, GND, RX and TX. I read something about one pin that needs to be put HIGH in order to activate the AT Mode…Honestly, I have no idea what it’s all about, just that it worked out fine for me with these 4 pins (if anyone want to shine a line on that part in the comments, you are more than welcome !). VCC is tied to the 3.3V output of the Arduino Uno, RX and TX to pin 0 and 1.

HC-05
BT4

Following this tutorial, I used the MIT App Inventor which proved incredibly easy to use. It took me an hour or two to conceive an control-panel with direction, speed and mode control without a single line of code. Don’t get me wrong, I usually think that the code is all the fun but this time it’s enjoyable to be able to play around with the robot right away without having to worry about learning another language.
What the app does is simply send two bytes to the robot via serial communication; the first indicates which type of instruction is sent (D for direction, S for speed and M for mode). The second byte is the corresponding value.

Screenshot_2014-12-25-14-19-03
Screenshot_2014-12-25-14-20-45

The robot receives the first byte via Serial, reads the second one accordingly to its expected type (char or int) and executes the command.

It works really well and I was surprised to see how easy it is to use Bluetooth as a communication protocol. I have 3 (4 if I didn’t burn one….) spare modules. I don’t know yet how I’m going to use them. Probably something to do with a led matrix or annoying my room-mate.

BT5

Next steps are : coding the app myself and making it look a bit smarter…, expanding the routines available for the automated mode and implementing the PID retro-control.
As always the code is available on the repository!

2 Comments

  1. Nice application of interfacing the HC module. The AT mode is used to reflash the BT unit with an arduino, allowing to change password, data speed, name of the module, etc. There’s more info in this instructable: AT command mode… or just googleing a bit. Cheers.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.