General XBee Inquiry

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
CP_LCV
 
Posts: 74
Joined: Wed Nov 14, 2012 7:35 pm

General XBee Inquiry

Post by CP_LCV »

Here is the project I'm undertaking:

At a transformer, if there is power, the XBee is to transmit a signal (a number? an analog value? not sure yet) to another XBee. XBee 2 will tell an Arduino that as long as this signal is being received, a relay should be energized. If power to XBee 1 is cut and the signal drops off, then XBee 2 notifies the Arduino who will de-energize the relay until told to re-energize.

I'm JUST getting into XBee (literally just found out about this little guy yesterday) and I'm wondering if the XBee has any onboard memory for such a simple trasmit program or if it still needs to be interfaced with a micro-controller.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: General XBee Inquiry

Post by adafruit_support_rick »

Wellllll.... you can set up a pair of XBees to exchange pin data without need of a microcontroller. It's called pin-passing.

But if I understand you correctly, the XBee transmitter will lose power when the transformer goes off? If so, the status will not be passed, since the transmitting XBee will shut down. There is no "open connection" monitoring with XBee. The transmitter has to actively send an alert to the receiver.

User avatar
CP_LCV
 
Posts: 74
Joined: Wed Nov 14, 2012 7:35 pm

Re: General XBee Inquiry

Post by CP_LCV »

Rick,

So, the relay only needs to be energized when there's system power. There's no monitoring being done (voltage, current, wattage, etc), the XBee is purely a method of controlling this wirelessly so that if the transfer switch and the inverter are not local to one another.

So, if the power cuts out, then the relay will be denergized not because the microcontroller is telling it to close, but because the power has disappeared. When the generator comes on, the transmitter will still be off (because it's tied to the 240V rather than after the transfer switch). So, even if the receiver becomes energized, the transmitter will still be off and therefor no data is being sent telling the relay to energize.

I'm planning to use an arduino on the receiver end to control a solid state relay which will energize the 120V coil in the relay between the inverter and the house. I just wasn't sure if the transmitter also needed a controller attached in order to transmit a signal that the receiver/controller can interpret as 'activate the relay'.

User avatar
CP_LCV
 
Posts: 74
Joined: Wed Nov 14, 2012 7:35 pm

Re: General XBee Inquiry

Post by CP_LCV »

To be more clear, while there is communication between the transmitter and the receiver I want the arduino to energize the relay. If the transmitter cuts out from a power loss, therefor the transmission signal is lost, the arduino will de-energize the relay.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: General XBee Inquiry

Post by adafruit_support_rick »

So, the communications between two XBees is "connectionless". Without using a microcontroller on the tranmitter, there is no way for the receiver to know that the transmitter has gone down.

Using a microcontroller, you would transmit periodic "keep-alive" messages. If the receiver stops getting those messages, then it can assume that the transmitter has gone down. What sort of fail-over latency do you need? Typically, you would want to set things up so that several keep-alive messages need to be missed before failover occurs. This is because RF is not 100% reliable, and messages can be lost. You would want to be sure that it wasn't simply a dropped packet or two before energizing the relay.

User avatar
CP_LCV
 
Posts: 74
Joined: Wed Nov 14, 2012 7:35 pm

Re: General XBee Inquiry

Post by CP_LCV »

Ahhh, this is exactly what I needed to know. I'm going to start putting this rig together next week once all my parts are in. I'll become more familiar with XBee, then return to the forum to update/seek support so that you guys don't have to hold my hand through the entire process.

Thank you, though! You've been a great help.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: General XBee Inquiry

Post by adafruit_support_rick »

You're welcome!

User avatar
CP_LCV
 
Posts: 74
Joined: Wed Nov 14, 2012 7:35 pm

Re: General XBee Inquiry

Post by CP_LCV »

Rick, hopefully you're still keeping an eye on this.

So, I've got my xbee's talking and I can read the transmission via the serial monitor. It comes across as 14 bytes in hex and the XTCU software breaks those up for me so I know what each byte is referencing. However, what I struggle with now is how exactly that serial data is received by the coordinator xbee and read by the arduino. So, I see the byte that says 'digital pin (x) is high/low' but I don't know how to tell the Arduino to disregard the rest of the bytes and only home in on that specific one.

Does the Arduino look at each individual byte as it is transmitted? So is there a way to tell it to discard the first 12 bytes, then read and compare that 13th byte?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: General XBee Inquiry

Post by adafruit_support_rick »

Well, the Arduino can look at all the bytes. You have to read them in one-by-one anyway.
You'll need to write a parser to pick out the byte you're interested in. If it's always the 13-th byte, then that's simple:

Code: Select all

  for (int i = 0; i < 12; i++)
  {
    xbee.read();
  }
  unsigned char xbeeData13 = xbee.read():

User avatar
CP_LCV
 
Posts: 74
Joined: Wed Nov 14, 2012 7:35 pm

Re: General XBee Inquiry

Post by CP_LCV »

So, here is what I'm using for code:
if (Serial.available() >= 14) {
for (int i=0; i<12; i++) {
incomingByte = Serial.read();
}
{inputByte = Serial.read();
Serial.println(inputByte, HEX);
}
and here is what the serial monitor showed me:
1
0
1
0
1
0
30
0
0
83
A
0
7E
47
1
0
1
I recognize the 7E as the starting bit, but I don't understand why those 1's and 0's are showing as single digits rather than the 2-bit hex bytes.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: General XBee Inquiry

Post by adafruit_support_rick »

Serial.println(inputByte, HEX); doesn't pad out with leading zeros. When you see 1, it's the same as 0x01.

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”