XBee 868 

Example

: Getting RSSI

This example shows how to get RSSI after receiving a packet


File:
"WaspXBee868_3_gettingRSSI.pde"


Code



/*
 *  ------Waspmote XBee 868 Getting RSSI Example------
 *
 *  Explanation: This example shows how to get RSSI after receiving a packet
 *
 *  Note: XBee modules must be configured at 38400bps and with API enabled.
 *
 *  Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L.
 *  http://www.libelium.com
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see .
 *
 *  Version:                0.2
 *  Design:                 David Gascón
 *  Implementation:    Alberto Bielsa
 */

long previous=0;
uint8_t state=0;

void setup()
{
  // Inits the XBee 868 library
  xbee868.init(XBEE_868,FREQ2_4G,NORMAL);

  // Powers XBee
  xbee868.ON();
}

void loop()
{
  // Waiting message
  previous=millis();
  while( (millis()-previous) < 20000 )
  {
    if( XBee.available() )
    {
      xbee868.treatData();
      if( !xbee868.error_RX )
      {
        // Getting RSSI using the API function
        xbee868.getRSSI();
        if( !xbee868.error_AT ){
          XBee.print("RSSI: ");
          XBee.println(xbee868.valueRSSI[0],HEX);
        }
        free(xbee868.packet_finished[xbee868.pos-1]);
        xbee868.packet_finished[xbee868.pos-1]=NULL;
        xbee868.pos--;
      }
    }
  }
}
 

Download code

You can download the code of this example.


© Libelium Comunicaciones Distribuidas S.L.

| Terms of use