NXTBee and XBee problems


I’m working on a project that works with the NXTbee and the Xbee. I need to send information from a NXT robot which is connected to a NXTbee to an Arduino Mega which is connected to a Xbee. I have the following problems:

  1. When I try to send strings, I only get the number of characters that I send, not the actual string.

  2. When I use the NXTbee block from DI in an actual program (NXT-G) telling it to send a string to the Xbee, it only allows me to send the string once. My program is to send different strings based on different buttons pressed. After I press one of the buttons, it’ll send the string corresponding to the button pressed. But when I try to click another button, it doesn’t send anything to the Arduino.

I attached both of the programs and the arduino program is shown below:

int n = 0;
int x = 0;
int y = 0;
void setup()
for (int thisPin = 11; thisPin < 14; thisPin++) {
pinMode(thisPin, OUTPUT);


void loop(){

if (Serial.available()>0) {

int inByte = Serial.read();
Serial.println( inByte);


int inByte = Serial.read();

switch (inByte) {

case 4:

while(n &lt; inByte)  {

  digitalWrite(11, HIGH);
  digitalWrite(11, LOW);
  n ++;


case 5:

while(x &lt; inByte)  {

  digitalWrite(12, HIGH);
  digitalWrite(12, LOW);
  x ++;


case 7:

while(y &lt; inByte)  {

  digitalWrite(13, HIGH);
  digitalWrite(13, LOW);
  y ++;

/*  default:
 for (int thisPin = 11; thisPin &lt; 14; thisPin++) {
 digitalWrite(thisPin, LOW);


Your help will be greatly appreciated
Thank you for your help

Attached is the NXT-G program for the NXTbee
I wasn’t able to send the actual program due to security issues
I copied it on to a excel file and attached it

It sounds like you’re getting a response from the NXTBees; are you seeing the blue light blink when you run your program?

It looks like your NXT-G code is fine for sending strings. I think the debugging needs to be done on the Arduino side.

When working on XBee projects, we find that a USB adapter is super helpful. You can have the data print out on your terminal really easily and see what’s going on. Do you have a way to connect via USB and see what sort of strings are being broadcast and to verify that you’re broadcasting the right strings?

Thank you for the quick reply,

When I download the program on the NXT robot, the blue light is blinking.

Also I already have been using a USB to connect to my laptop. I used the serial monitor to see if the NXT is sending what I want to the Arduino.

Here are my procedures for running the program:

  1. I download the NXT-G program to the NXT brick and also download the Arduino code to the Arduino board (put the jumpers on the USB side to download)

  2. I then put the jumpers to the Xbee side to run the Arduino program.

  3. On the Arduino environment(IDE), I start the serial monitor(connected to the Arduino by USB)

  4. I start the NXT-G program on the NXT

  5. So for example if I click the middle button (string “forward”), then I see the number 7 (not the string, but the number of characters) on the serial monitor. At this time I see that my LED blinks for 7 times as my program meant. Also, the number 7 will repeat itself on the serial monitor for a random amount of times.

  6. Then if I try to push another button, for example left button (send string “left”), the number 4 doesn’t show up on the serial monitor. And, the LED doesn’t blink 4 times as the code meant it to do.

  7. The same thing happens to any button pressed after the first time that you press it.

In brief, it works the first time you press any button but then doesn’t work as the code meant to do.

Thank you for your help

WHat string is the NXT supposed to be sending when you push each button?

Also, do you have access to RobotC? The NXT-G software is really difficult to use. It should work, but there are a lot more examples in RobotC that use NXTBee.

Finally, if I remember correctly, you needed to use an updated version of the firmware. Have you seen this in the documentation?

I send thee strings in NXT-G

Middle button sends “forward”

Left button sends “left”

Right button sends “right”

I do have access to RobotC

But the example I saw ( Integrating Lego Mindstorm NXT and Arduino )in your blog is the one that sends the string from Arduino to NXT racing car( not from NXT to Arduino like in my case). Plus that Arduino code is using something called Myserial which is something I am not familiar with (I’m a sixth grader who has just started using NXTBee and XBee). Could you provide example that sends strings from NXT to Arduino using RobotC?

Thank you so much