NXT Brick remote control over Bluetooth

Version 1.1, 02.01.2008

This is a quick 2 days hack on Bluetooth based NXT remote control for J2ME compatible mobile phone.

So, we have the following:

I've run all tests on Nokia 6131 and Nokia 6230, therefore all used tools are for Nokia.

First, you need an applet. You can download it from:

You can install the applet to you phone via:

If you want to build an applet from the source, you need Nokia 6131 NFC SDK 1.1. Also, if you want to run the applet on your PC with Bluetooth support, you can use BlueCove Bluetooth stack for Windows and J2ME emulator for Windows. You may want to install the applet onto your phone over Bluetooth via BlueCove OBEX Push J2ME application, make sure your Bluetooth dongle drivers are supported by BlueCove. Currently BlueCove supports Mac OS X, WIDCOMM, BlueSoleil and Microsoft Bluetooth stack found in Windows XP SP2.

Now I will describe the content of the archive. Everything is based on batch files, as this is my favorite way to work. If you have any questions about using IDE for Java, such as Eclipse, for example, I will not be able to help with it. If something goes wrong, first thing is to check the paths settings in batch files. The good thing about batch files is clarity and simplicity.

This archive includes everything for playing with applet on the PC:

Subfolder phone

build.cmd - Build the applet project. Correct your own settings of paths of the installed Nokia NFC SDK and Java.

clean.cmd - Clean-up temporary files.

src/*.java - Applet source files.

Subfolder brick

btrc.nxc - Demo program, which receives the commands from the phone and draws the arrows on the brick's screen. It is really simple. Most difficult part of it is about drawing the arrows on the screen. The protocol between the applet and the NXT is pretty simple - it uses just the strings up to 80 characters long.

btio.nxc - Very popular Bluetooth library for NXT by Daniele Benedettelli. I've made modified it a little bit.

tools\nbc.exe - Command line NXC compiler by John Hansen. Version 1.0.1.b32.

tools\nexttools.exe - NXT command line tool management tool by John Hansen. Version

compile.cmd - Build NXT demo program.

download.cmd - Download NXT demo program to the brick over USB.

run.cmd - Run NXT demo program on the brick over USB.

clean.cmd - Clean-up temporary files.

Subfolder lib\bluecove-2.0.1

BlueCove Bluetooth JSR-82 DLL and BlueCove OBEX Push J2ME application.

Subfolder lib\microemulator-2.0.1

J2ME Micro Emulator.

Root folder of the archive

run-microemulator.cmd - Run the applet in Micro Emulator with Bluetooth support.

run.cmd - Run the applet in Nokia NFC Emulator. Bluetooth will not be emulated normally until you activate Nokia BT driver from Nokia Connectivity Framework which is included into Nokia NFC SDK. Be careful - Nokia BT driver can affect your real Bluetooth driver. Instead I recommend you use Micro Emulator because it uses BlueCove DLL which does not substitute Bluetooth driver but only uses the current stack.

download-bluetooth.cmd - Install the applet to the phone over Bluetooth. It requires BlueCove OBEX Push J2ME application installed - a useful and handy tool because you do not need the monster like Nokia PC Suite installed. Make sure your Bluetooth driver is supported by BlueCove.

Basic steps to playing with applet:

  1. Pair your NXT brick and your phone via Bluetooth.
  2. Install Nokia 6131 NFC SDK, if you want to build the applet from the sources.
  3. Build the applet. Go to subfolder 'phone' and run 'build.cmd'.
  4. Run 'run.cmd' or 'run-microemulator.cmd' if you want to run the applet in the PC emulator.
  5. Run 'download-bluetooth.cmd' if you want to install the applet via Bluetooth OBEX Push, or use Nokia PC Suite.
  6. Run the installed applet on your phone (or emulator).
  7. Make sure that brick is powered on.
  8. Press 'Connect' in the applet. Then applet will search available Bluetooth device around, print the found device addresses first, then print the devices names. After it will discover the SPP Bluetooth service on the NXT. If everything is ok, the screen will become black with 'Command:' prompt and the Bluetooth connection indicator on the NXT screen (left top corner) will be changed from '<' to '<>'.
  9. Now you can go to subfolder 'brick'. Build the demo program by 'build.cmd' and run it on the brick by 'run.cmd'. If brick starts to beep, it means that something wrong with Bluetooth connection. Otherwise, you can press '2', '4', '6', '8', '5' on the phone. The arrows on the brick's screen will be changed accordingly.

That is it!

There is a video about how this demo works - http://youtube.com/watch?v=F0HW3Mth0Pw.

Special thanks for my brother Evgeny Demin (http://www.handshake.ru/en) for testing.

If you have any question about these, feel free to ask me.

Copyright (C) 2007-2008 by Alexander Demin