Go Down

Topic: How to connect sensors, xbee modules and xbee shield to an Arduino board? (Read 3539 times) previous topic - next topic

pryan225

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.

Nick_Pyner

#16
Feb 12, 2013, 06:14 am Last Edit: Feb 12, 2013, 11:58 am by Nick_Pyner Reason: 1
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.

draythomp

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:
Code: [Select]

Serial.write('0');

and on the other end:
Code: [Select]

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?
Trying to keep my house under control http://www.desert-home.com/

pryan225

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 ?

draythomp

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.
Trying to keep my house under control http://www.desert-home.com/

pryan225

Are you talking about programming the xbee modules? Actually what i meant was whether or not there exists a way that you can burn "sketches" on to an arduino board while it has a shield or two mounted over it? Or do i have to take the shield off before i burn the code?
[I apologize for not being able to put the question straight enough...Hope this makes it easier to understand]

draythomp

The problem with many shields is that the XBee only connects to pins 0 and 1.  As long as those are connected to an XBee and the power is on, you can't program either one of them. If you use different pins for the serial connection to the XBee, you do not have to remove it to program the arduino.

So, is your shield capable of connecting the XBee serial in and out to pins other than 0 and 1 on the XBee?

You DO NOT have to use pins 0 and 1 to talk to the XBee, none of mine are.  But, how easy it is to connect to a different pin depends on the shield.
Trying to keep my house under control http://www.desert-home.com/

Go Up