Tuesday, February 21, 2006

How To: Use Your Phone As NXT Remote Control

Lego Mindstorms NXT has Bluetooth on board. It is likely that Mindstorms uses the Bluetooth serial port emulation mode. To understand how this works, here is a demonstration that uses a regular PC instead of the Mindstorms NXT brick. We're not going to do any programming in this demo. In this demo, I will be using Microsoft Windows XP on a computer with Bluetooth, and a Sony Ericsson T630 mobile phone.

The proposed sample "application" does the following: from the computer, I'm going to ask the mobile phone to display following menu options on the screen:
  • Forward
  • Backward
  • Left
  • Right
  • Stop

After the user has made a selection, I'd like to know what that selection was (or if the menu was cancelled).


First, let's start the HyperTerminal. HyperTerminal is a program that allows you to communicate directly with the serial port. You can find this program on
Start > All Programs > Accessories > Communications > HyperTerminal

When you start HyperTerminal, you will see the following screen:

Initial HyperTerminal Screen


You can provide any name you like, and choose any icon. Then click "OK". This brings up the following screen:


Here, it is important to choose the right communication port. Do not choose the "Standard Modem over Bluetooth Link", since that will ask you for a phone number to dial into. Rather, selected the virtual COM port that Bluetooth is mapped to. This is usually COM7 or COM8. Just select the COM with the largest number for now. You can leave all other settings as they are. Speed doesn't matter for this demo.

As soon as the selection is made, HyperTerminal will connect to the serial port. It should say "Connected" in the bottom left of the window's status bar, and present you with a blank screen. Let's first check if you selected the right COM port. If you type in the command "AT+CGMI", the phone should return you its manufacturer. If it does not, they you probably need to select another COM port.


Click image to enlarge


Great! We have a live connection with the phone. Now, let's ask the phone to show that menu we wanted. Type in the command

AT*EASM="bNXT Remote", 0, 1, 5, "Forward", "Backward", "Left", "Right", "Stop", 1




Click image to enlarge


That number 5 in the command indicates the number of menu items you use. So if you change the menu options, change that number too. Now look at the screen of your mobile.


Yes, it is really that easy. Make a selection on the phone. In my case, I selected forward. The menu on the phone disappears, and on your computer screen, you see the serial port sent back the code "*EAMI: " followed by the index of the menu item selected.


Click image to enlarge



Summary

So in summary, when you are on the NXT Brick, all you need to do is send the AT*EASM command as ASCII over the Bluetooth serial port, and listen to the port. When you receive an ASCII string result that starts with "*EAMI: ", then the next character(s) contain(s) the selection made, encoded as the sequence number of the menu item. If you receive 0 as selection, then either the user cancelled the menu, or there was another menu already active.
When the robot is ready to receive another command, just send another menu to the phone.

Have fun!

17 Comments:

At February 21, 2006 7:27 PM , Anonymous Lyrids said...

It's fantistic! BTW, where can I find more information about Ericsson's special AT command set? Some reference links are highly appreciated.

 
At February 21, 2006 7:41 PM , Anonymous Filip said...

Hello Lyrids.

For Sony Ericsson, you find them on their developer site. Here is direct link to the AT commands.

Filip

 
At May 18, 2006 7:52 PM , Anonymous Drew said...

Any idea how or where to find other companies or platforms comands? or are they all universal?
Ie I have a motorola phone and a palmpilot both with blue tooth. Would the same codes work or where could I find these?
Thanks for the great start... its GREAT!

 
At May 18, 2006 8:04 PM , Anonymous Filip said...

Hi Drew,

For Sony Ericsson, http://developer.sonyericsson.com/getDocument.do?docId=65054 is a great start. I am not sure if all commands are the same across manufacturers, but if they want to communicate with each other, then at least most commands must be the universal.

Filip.

 
At June 29, 2006 1:48 PM , Anonymous Anonymous said...

can you do that with nokia BT enabled phones?

 
At July 12, 2006 2:13 AM , Blogger Tony said...

So far as I can tell, Nokia phones don't support "extended AT command sets for menus". From the very limited info I could find, Ericsson is the only ones that support this. :(

AT Commands for Nokia phones:
http://discussion.forum.nokia.com/forum/showthread.php?t=80164&highlight=at+command

 
At August 25, 2006 12:41 PM , Anonymous Anonymous said...

How would you send the AT commands from the NXT?

 
At August 26, 2006 8:59 AM , Anonymous Filip said...

Using NXT-G, at this time, you cannot send direct AT commands.

That's because there is no direct access to the serial port interface in the Bluetooth layer.

Although NXT-G cannot do it, your NXT brick can. Adding an NXT-G brick that CAN do it, is on my wish/to do list.

Filip.

 
At September 06, 2006 8:04 PM , Anonymous Will George said...

Stupid old man here..
BUT.. how does the NXT brick know what your sending?

As I said stupid here so I connected to the brick using bluetooth and HyperTerm (using XP Home on this puter). Nothing happened? I'm the only person on earth without a cell phone?

Any comments?

 
At September 06, 2006 9:42 PM , Anonymous Filip said...

Will George,

Not stupid at all. I published this before I had a NXT. Since then, I learned NXT's Bluetooth doesn't work as I had anticipated.

Essentially, nothing happened because LEGO has implemented a special algorithm. I'm experimenting with it right now (from PC, not mobile phone). I'll publish about it when I feel I've got it more or less under control.

Filip.

 
At September 07, 2006 12:47 PM , Anonymous WIll George said...

iThanks for the reply. I thought it was just me.

 
At September 17, 2006 11:27 PM , Anonymous Anonymous said...

Hi, im trying to type some text in the hyperTerminal window, but nothing happens. The terminal dont react when i press the buttons on my keyboard. Anyone have any idea whats wrong?

 
At September 18, 2006 11:06 AM , Anonymous Anonymous said...

erm, i found out... I needed to activate the "echo typed characters locally" uder ascii settings. :)

 
At October 31, 2006 6:32 PM , Anonymous Anonymous said...

According to Lego's website one of there MDPs has manged to send AT commands using the nxt. I tried it using a Sony Ericsson phone but it didn't work. http://mindstorms.lego.com/MeetMDP/Martyn.aspx

 
At February 20, 2007 11:53 AM , Anonymous Anonymous said...

Hi,

This seems like great fun, but i am running into problems. By using the control panel, i have found my Bluetooth local COM clients should be running on COM6 and COM9. Two programs are already sharing the COM9 connection, but when i try connecting to it with HyperTerminal i get: "Another program is using the selected telephony device. Try again after the other program completes." I still can not connect after closing both the other two programs that are using COM9. By instead specifying COM6 in HyperTerm., i am able to get SOMETHING ehocing back my typed characters, but there is no response to the AT+CGMI command. Any ideas?

 
At July 09, 2007 11:50 AM , Anonymous Anonymous said...

Hi filip,

I am using a T630 and following your instructions, with all but the menu generation commands working. I tried using the commands for camera operation in your other tutorial and they work fine, but using the AT*EASM..... commands to generate the bNXT Remote menu returns nothing at all on my phone, despite hyperterminal returning OK after entering.

What am I doing wrong?

Thanks.

 
At October 23, 2007 5:41 PM , Blogger Thebuilder94 said...

same here accept i am using a T637 (man! we're outdated!). is there something you have to activate manually on the cell?

 

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home