You are here: Home Documentation Tutorials XBee Wireless Interface Sample setup
Document Actions

Sample setup

A practical example of how to get set up with your XBee wireless modules.
How to extend your Make Controller projects wirelessly using the XBee modules from Maxstream.
Page 3 of 7.
This page jumps straight into setting things up, without too much explanation.  The following pages go into more detail on some of the concepts involved, but the hope is that this should get you up and running quickly.

For this example, we'll assume that we're using 3 XBee modules - 1 receiver module connected to the Make Controller, and 2 remote modules with sensors connected.  The concepts here can easily be adapted to work with more than 2 remote modules. 

We're assuming that the modules are wired up, as described in the previous sections.  After that, the basic outline is as follows:
  1. Configure the remote modules.  To configure them, we'll need to plug them into the Make Controller.  Then once they're configured, we'll disconnect them and send them on their way.
  2. Configure the receiver module.
  3. Start listening and reading the data.

Note - as we're cruising along, remember the reference for all XBee OSC info can be found here and here.

Configure the remote modules

For each of the remote modules, we'll want to:
  • Set their address, so we can tell them apart
  • Configure which inputs they should be reading
  • Set how often they should read the inputs

To configure an XBee module it must be connected to the Make Controller's serial port, as shown in the Plugging In section.  Then, remember that we need all our boards to be in packet mode - otherwise, it won't respond properly to any of our other messages.  To do that, send the message
/xbeeconfig/packet-mode 1

Set the address
The specific address you choose doesn't matter too much, but you should remember which address you've given to which board, so you know which messages are coming back from it.  I always like to put a little sticker on the module itself with the address I gave it, just so I don't get confused later.  We'll set the address of our first module to 12 - so, send the message
/xbeeconfig/address 12

Configure the inputs
On our first module, we're just connecting a single sensor to analog in 0.  So, we need to set the XBee module to read In0 as an analog in.  To do this, send the message
/xbeeconfig/io0 2
Note that along the right side of the XBee board, all the inputs are there, labeled AD0 - DI8.   The input's number corresponds to the io property that we'll use to configure it.  The value that comes after that specifies whether that input is an analogin (2), a digital in (3), or disabled (0).  So, to set input 8 to disabled, we'd send the message
/xbeeconfig/io8 0

Set the sample rate
Now we need to set how often the module should read In0.  We'll set it to read every 50 milliseconds.  To do that, send the message
/xbeeconfig/samplerate 50
If you ever want your board to stop sending messages altogether, just set the sample rate to 0.

Lastly, and very importantly, we need to remember to save all the configuration changes we've made to the module.  Otherwise, it will revert to its defaults when it reboots.  To save the changes, send the message
/xbeeconfig/write 1

If something doesn't seem to be working quite right, you can always read back any of these settings to be sure.  Now, repeat these steps for any additional modules you have, but make sure to give them different addresses.

Configure the Receiver Module

There's not too much to do with the receiver module.  But, make sure it's in packet mode.  Again, once you plug it in, send the messages
/xbeeconfig/packet-mode 1
/xbeeconfig/write 1

Start Listening and Reading the Data

The last step is to start reading in the XBee messages.  To do this, the easiest thing is to use autosend.  This way whenever a message from an XBee module arrives, the Make Controller will make an OSC message out of it and send it back to us.  To do this, first choose whether you want the Make Controller to send messages to you over USB or Ethernet.  If you want Ethernet, send it the message
/system/autosend-udp 1
or if you want USB, send the message
/system/autosend-usb 1
Next, decide how often you want the Make Controller Kit to check for new messages.  We'll have it look every 10 milliseconds, or 100 times a second.  To do this, send the message
/system/autosend-interval 10
Lastly, turn the XBee autosend on.
/xbee/autosend 1

Now, you should have the sensors plugged into the remote XBee modules and the receiver module plugged into the Make Controller.  If you've done everything successfully, you should see a bunch of messages streaming into mchelper that look like
/xbee/io16 12 31 1023 0 0 0 0 0 0 0
This is a message back from one of the remote modules.  As is explained in the OSC reference, the first two numbers are:
  1. the address of the module that sent the message (12 in the example above)
  2. signal strength (31 above)
The next 9 numbers are the values from the 9 IO pins on the XBee module.  So, this is a message back from the board that we gave address 12, and 1023 is the value from the sensor that we have plugged into In0 on that module.

Admittedly, seeing all that data streaming into mchelper is not all that helpful.  But, it is a good way to confirm that we're getting messages back from the modules.  Now you're ready to head into your environment of choice and start reading all sorts of XBee goodness.