How to connect sensors, xbee modules and xbee shield to an Arduino board?

Hi,

I have the following components which i need to function together as a single module.

*Arduino UNO board
*Arduino XBEE shield
*XBEE Module

Now i need to connect a few sensors to the board. How do i do that?

I have gone through a few links and could manage to pull up some information:

Sensor: Radio Control Planes, Drones, Cars, FPV, Quadcopters and more - Hobbyking
Sensor expansion board: Radio Control Planes, Drones, Cars, FPV, Quadcopters and more - Hobbyking
Sensor shield: 2 Pin XH2.54 Plug Connector Wire--200mm - emartee.com

I am a bit confused about how to use/ which ones to use/ how to integrate them?

Also is it possible to mount multiple sensors? So that i could mount an xbee module with a shield as well as a sensor shield with sensors?

Please help me.

Regards,
Priyankar Bhattacharjee

Assuming you want to use more than one sensor at a time, simply wiring them into the headers of the shield is not really enough and proper terminals are required.

I know nothing about Xbee shields. I assume they are made to take the Xbee module and therefore you have that side of things sorted. I think the sensor adapter is just a piece of junk. The two others are much the same as each other. I have the second one, you can get that for half the price on eBay. I found it useless. Quite aside from the fitting problems, I have never seen any plugs that fit in the sockets provided and I could do a better job making my own. You probably would too.

Googling Xbee shield, I see the red Sparkfun looks fairly, if not very, sensible. It has a prototyping area on which you can put your own headers to take your own sensors. If your shield is one of those or similar, you don't need to waste your money on the other stuff.

I have this one : http://www.digikey.com/product-detail/en/A000021/1050-1006-ND/2638994
(Clearly, only some pins surface out)

But i think this is the one i should have bought : http://www.digikey.com/product-detail/en/A000064/1050-1023-ND/2784004

Now all the pins do not surface up. So what are we supposed to do to connect sensors as well as communicate (with xbee shield + module) over the uno?

pryan225:
But i think this is the one i should have bought

So what are we supposed to do to connect sensors as well as communicate (with xbee shield + module) over the uno?

Um, yes, well... A principle reason why I don't know much about Xbee is that the only thing I do know is that the Xbee shield manufacturers have no idea about what they are doing, and your first example is fair evidence of that.

Having said that, your second example looks fine to me, and I'm sure you are right. Perhaps not perfect in theory, but it has the three vital assets

  1. a row of proper holes for wiring to the headers

  2. twelve holes across means four 3-wire headers in a row.

  3. stackable headers.

Most importantly, it has other relevant peripherals that would deter me from making my own. The main reason why I don't know about Xbee is that I have managed to avoid it - so far. If I eventually have to indulge in it, this is the sort of board I would get.

Thank you.

I've been where you are and made a bunch of mistakes, so a couple of suggestions: I like this board for an XBee shield

http://www.ebay.com/itm/XBee-shield-for-Arduino-/220982906382?ssPageName=ADME:L:OC:US:3160

It lets you connect the serial input on the XBee to any pin on the arduino, and if you use a mega2560, you add a couple of wires and can get to any pin on it as well. It has leds, reset switch, and prototype area so you can mess around a bit on the board itself. You can piggy back another shield on top of it also.

As for sensors, visit Terry King's site at http://arduino-direct.com/sunshop/ , he has a bunch of sensors, shields, and most importantly, examples of using a lot of the stuff. Even though you already have some items, the articles and description of the devices will help you understand how this stuff works.

XBee, I didn't see where you mentioned which XBee you got, but I hope it's a Series 2 or 2.5 device. The series 1 are marginally easier to use, but they don't have anywhere near the capabilities of the later devices.

To get you started, decide what you want to do. Maybe measure the temperature in your main room. For this you need a temperature sensor to plug into the arduino. Then you will want to see what it's reading, so you'll probably want to get an LCD display. Then you'll want to do something else. As you decide what you want to monitor or control, you'll understand what you need to have to do it.

As for multiple sensors, yes you can have multiple sensors. The arduino can sample a number of them and then format a message to send through the XBee to another one hooked to some device you want to get the data to.

Basically, think about what you want to do, gather some information on doing it, then go have fun.

With your xBee shield, it looks like you need it to be on top of your shield stack, with whatever stackable sensor shield you can find making the filling in an arduino/xBee sandwich. I used the Sparkfun prototyping shield for this purpose, to mount a temperature sensor. I don't like that shield much - the prototyping area was hard to use because all the nodes are electrically separate so it was a very fiddly job wiring it up. Much more durable than the breadboard it replaced though!

Thanks guys...the sandwich according to me should be arduino board + sensor shield + some headers (to raise the level up a little bit to allow enough room for multiple sensors) + xbee shield + xbee module. What do you guys think?

The only way you're going to know for sure is to stack them up and see what happens. The answer will probably be obvious.

pryan225:
the sandwich according to me should be arduino board + sensor shield + some headers (to raise the level up a little bit to allow enough room for multiple sensors) + xbee shield + xbee module.

This implies it is appropriate for the sensors to go on the board, and the Arduino will be in the right place to do the sensing. Only you can make that judgement.

Similarly, only you can decide on the need for extra stackers. Note though, if you make your sensor shield, extra long legs can be had from here:

http://www.ebay.com/itm/130802267649?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

but note also they are not really long enough to clear an EtherNet socket!

I put clock modules on standard pinrows and an ordinary shield will just clear it

Now i have everything set up...Just a bit apprehensive about whether or not i should put the x-bee module all the way down into the shield...Because it takes quite a lot of effort to pull that thing up and plug into the spark fun explorer to program it...I am scared that it might damage the module if i went doing it for a couple of times.

I plug and unplug mine all the time. After a while, the sockets loosen up enough so that it doesn't take as much force to get it out. Be careful of bending pins on the XBee though, it's really easy for it to let go on one end as you pull it out, bending the pins on the other end. Don't worry too much though if you do bend them, they don't break too easily. Just don't make a habit of it.

You are probably just being paranoid and, the more you plug/unplug, the easier it is likely to get. If I understand you correctly, the Xbee module has to go into another device in order to be programmed, and I guess you only do that once anyway.

I have noticed variation int the way a shield installs. I have wondered if some have harder brass in the pins and it takes a bit more to straighten them.

Sure. Maybe over a period of time, will overcome the fear :smiley:

Also now that i am setting up one arduino to be the sender and the other to be the receiver.

What i am trying to achieve is to blink an led on and off on the receiver based on inputs (1's and 0's) from sender.

Steps for sender:

1)Write the code for the sender.
2)Compile it.
3)Burn the code into the arduino uno.
4)Load the xbee shield with xbee module

Steps for receiver:

1)Write the code for receiver.
2)Compile it.
3)Burn the code into the arduino uno.
4)Load the xbee shield with xbee module.

Then plug them onto diferent computers. (Just for power supply i am assuming)

But it does not seem to work. I am copy pasting the code below.

Sender:

int data = 0;
int ledPin = 13;

void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT);

}

void loop(){

if(data == 0){
Serial.write(0);
digitalWrite(ledPin, LOW);
data = 1;
}

delay(1000);

if(data == 1){

Serial.write(0);
digitalWrite(ledPin, HIGH);
data = 0;

}

delay(1000);

}

Receiver:

int ledPin = 13;

void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT);

}

void loop(){

//while(Serial.available() == 0);

if(Serial.read() - '0'){
digitalWrite(ledPin, HIGH);
delay(1000);
}

else{
digitalWrite(ledPin, LOW);
delay(1000);
}

Serial.flush();

}

But i am not being able to achieve the result...The led on the sender blinks fine which indicates data is being transmitted as desired. But the led on the receiver bears a constant HIGH. (which is what i do not understand). Please help.

I don't know anything about XBee but I see the while line is commented out, and I would also question the following if. The latter is only because I haven't seen one like that.

First, when you're posting code, the forum has a tool for that. Look on the lines above where you're posting and you'll see a #, if you hover over it, it'll say 'Insert Code". Use that tool to insert code into the post and you'll get a nice box around the code with a scrollbar to go through it with.

Next, Serial.write(0); will write a null to the output. Serial.write is how you send binary out the serial port on IDE version 1 and above. On earlier ones, you can use Serial.print(0,char); So, you're writing a null (zero) out the port and looking for an ascii '0' on the other end.

To make it easier for other folks to understand, something like:

Serial.write('0');

and on the other end:

if (Serial.read() == '0')

would make it easier. Many people don't think about 0 being false and anything else being true. So, in this case subtracting an ascii '0' from the input to give a zero result may obscure your intent such that people overlook it.

Oh, notice how the 'code' tags work?

Will remember to format the code the next time around. Also i have one more doubt: do i need to take the xbee shield (with the module mounted on it) off the arduino board every time before programming/ reprogramming it ?

No, but you have to write code to talk out the serial port. I've hooked up wires to the serial in and out a couple of times, but that turned into a real pain after a while. Eventually, I just gave up and did the plug and unplug routine.

There is another way if you have two XBees where one of them can be in the USB adapter on a computer all the time. It is possible to program the settings on an XBee that is on a network remotely using XCTU. The method is reasonably complex and hard to explain.

After you've done it a couple of times, it gets easier, but those first few times are a real pain. I use it all the time to change the destination address on a remote XBee from some specific device to broadcast so I can see what it is doing. Basically, you need an extra XBee that can be used to monitor and do other things that isn't normally part of your network.