For my final I knew I could not finish all of this, so I decided to follow through on the efforts the card project that Roy, Nathan and I started but were not able to get working.
For this project, I envisioned:
Kite/Radio 1 (coordinator) queries Kite/Radio 2(router) for signal strength
Kite/Radio 1 then sends the signal strength to Radio 3(router) that would be on the ground.
Radio 3 would send this data through the serial port to then have some computer program process it.
So, I used the library that Roy created to have radio 1 read the signal strength from radio 2. I then wrote some code to send an API packet: transit request to send the signal strength value to the 3rd radio. I managed to get all three radios talking together. The third radio was sending the signal strength readings as ASCII data across the serial port. Given time constraints I just wrote a very simply arduino program that would light up 1-10 LEDs based on the values of the signal strength.
Unfortunately, on the day of class, my three radios wouldn't work together!! All three radios showed that they were on, and receiving data. However, signal strength value was not making it to the third radio; or at least the signal strength value was not being read across the serial port. I found it very disappointing.
****
Here is the code that was installed on a mini arduino attached to Radio 1 (note, you would have to include Roy's library for the first part of the code to work):
#include
#include
XBee radio_one; // my radio
/* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SETUP
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
void setup()
{
Serial.begin( BAUD_RATE ); // BAUD_RATE is 9600
// address of local radio
set_64_bit_address_on( radio_one, "0013A2004031F8FF" );
}
/* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
LOOP
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
void loop()
{
static byte response;
// remote radio addr , at command
send_remote_at_query( radio_one, "0013A2004030CFCC", "DB" );
read_at_query_into( &response ); // returns reponse and waits a half a second
Serial.print(0x7E, BYTE); // start byte
Serial.print(0x00, BYTE); // high part of length (always zero)
Serial.print(0xF, BYTE); // low part of length (the number of bytes that follow, not including checksum)
Serial.print(0x10, BYTE); // 0x10 is a Transmit Request API ID
Serial.print(0x0, BYTE); // frame id set to zero for no reply
// ID of recipient, or use 0xFFFF for broadcast
Serial.print(0x00, BYTE);
Serial.print(0x13, BYTE);
Serial.print(0xA2, BYTE);
Serial.print(0x00, BYTE);
Serial.print(0x40, BYTE);
Serial.print(0x30, BYTE);
Serial.print(0xCF, BYTE); // 0xFF for broadcast
Serial.print(0xDB, BYTE); // 0xFF for broadcast
// 16 bit of recipient or 0xFFFE if unknown
Serial.print(0xFF, BYTE);
Serial.print(0xFE, BYTE);
Serial.print(0x00,BYTE); //sets maximum number of hops that can occur
//send each character value read from Kite 2 as byte
Serial.print(0x00,BYTE); //non-optional option, set all other bits to 0
Serial.print(response, BYTE);
// checksum is sum of all bytes after length bytes
long sum = 0x10 + 0x0 + 0x00 + 0x13 + 0xA2 + 0x00 + 0x40 + 0x30 + 0xCF + 0xDB + 0xFF + 0xFE + 0x00 + 0x00 + response;
Serial.print( 0xFF - ( sum & 0xFF) , BYTE ); // calculate the proper checksum
delay(1000);
}
****
Here is how the three radios were setup:
No comments:
Post a Comment