Using Bluetooth with 3 NXT bricks
Page 1 of 1

Author:  ghostthirteen [ Mon Dec 15, 2014 8:22 pm ]
Post subject:  Using Bluetooth with 3 NXT bricks

We're working on a cool underwater robot project where we use three NXT bricks - two for sensors and one for main processing and motor control. The two sensor bricks (slaves) capture sensor data and should send it to the master continuously. The master processes the data and decides what actions to take.

We understand the master-slave concept and we have paired and established contacts correctly, but can only get the master to talk to one brick, not both. We read that the master must send a message to each slave before the slave can respond. But can't find any examples or even functions for the master message. Does anybody know what function(s) would work? Also, do we need to include "btConnect" and "btDisconnect" in the code?

Author:  tabbycatrobots [ Mon Dec 15, 2014 10:09 pm ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

I have a library of functions that I put together to reliably connect 4 NXTs, but it
is coded in NXC. I used NXC for my NXTs, and use RobotC for my EV3. If this
will help you, I can email the files to you. It is a lot of code to post online.
You may be able to translate my NXC code to RobotC, or at least see the sequence
of calls. It took me about a month to get it to reliably connect 4 NXTs. And even
then sometimes, like at Brickfair, when there are dozens (100s) of people around with
cell phones, it would time out if I tried to connect more than 2 NXTs. Are there many
other BT devices near your NXTs? The other thing I did that seemed to increase
reliability, was to always send a 32 value, not other data types. Oh, just to clarify,
I had one master and 3 slaves.

Author:  tito [ Tue Dec 16, 2014 2:34 pm ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

I actually doubt that 1 NXT BT master can connect to more than 1 NXT BT slave by RobotC... :-/ (CMIIW)

Author:  tabbycatrobots [ Tue Dec 16, 2014 3:17 pm ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

Can RobotC use multiple BT channels? Assuming it is possible for RobotC to connect
to multiple NXTs (I'm still learning RobotC), here are a couple more ideas.
Are you using different BT channels for each slave? In NXC, I had the master connect to
a slave on channel 0, then after testing the connection, they would use a unique channel for
each slave. And there are some good BT coding ideas in these 2 books. They are about
NXC, but they may give you some ideas.
Creating Cool Mindstorms NXT Robots by Daniele Benedettelli
LEGO Mindstorms NXT Power Programming Robotics In C by John C. Hansen

Author:  tito [ Tue Dec 16, 2014 3:26 pm ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

AFAIK, as I already wrote, not possible for RobotC

Author:  BurningLights [ Wed Dec 17, 2014 1:06 am ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

It actually is possible in ROBOTC to have multiple NXTs connected to a master brick. Each of the slaves will be connected to the master on their port 0, and the master will be connected to each slave on port 1, 2, or 3. You can see a complete list of the NXT Bluetooth commands at I think the most relevant ones for reading and writing data to multiple NXTs would be cCmdMessageWriteToBluetooth and cCmdMessageRead. I don't believe that you need to use btConnect and btDisconnect in the program to make it work, as long as you connect up all the bricks under the Bluetooth section of the NXT's menu ahead of time. However, I haven't really used robot-to-robot Bluetooth much with ROBOTC, so I can't be certain.

Author:  tito [ Wed Dec 17, 2014 5:48 am ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

ok, I stand corrected!
The ROBOTC BT messaging has been optimized for a single slave connection on the master.
ROBOTC also allows for multiple slave support, but a description of this is beyond the scope of this tutorial.

Author:  ghostthirteen [ Tue Dec 30, 2014 12:59 am ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

Thanks Burning Lights. We'll give it a try and let you know...

Author:  lepperk [ Mon May 09, 2016 5:31 pm ]
Post subject:  Re: Using Bluetooth with 3 NXT bricks

Has anyone made this work? I'm working with a Robofest team. They've made a Pac-Man game with robots -- one robot is Pac-Man, two are ghosts. The Pac-man robot is controlled by an NXT-built joystick. We're trying to have another NXT control the two robots -- at least to the extent that it can send a message when the game is over so that the ghosts stop moving. We have programmed this successfully for one ghost but cannot figure out how to have the controller successfully send messages to both ghosts.

I expect we need some way to tell the controller which NXT 'ghost' to send the message to, but I cannot find any information on how to program that. I understand that this may slow communication down a little, but for our application I don't think it will make a big difference. If you've had any success in RobotC 4.x, please share!


Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group