Boomerang RSSI Readings

From TinyOS Wiki
Jump to: navigation, search

Reading RSSI values from Tmote Sky

When a Tmote Sky receives a packet, it stores the signal strength of the incoming packet in the TOS_Msg structure. It is also possible to read the signal strength in the absence of the incoming packets. Such functionality is useful for estimating the noise floor of a particular channel and locating sources of interference such as 802.11 networks and microwave ovens. The default radio stack does not include such functionality; this document includes instructions for how to incorporate the needed functionality into the radio stack.

You will need to modify two files CC2420ControlM.nc and CC2420RadioC.nc. The preferred way of doing such modifications is to copy these files to a local application directory, and perform the modification there. Note that these files by default are located in /opt/moteiv/tos/lib/CC2420. The modifications to the CC2420RadioC are fairly simple, all we need is to connect an extra Resource to use in RSSI reading:

 implementation {
  ...
 components new CC2420ResourceC() as CmdRSSI;
  ...
 CC2420ControlM.CmdRSSI -> CmdRSSI;
 }
 

We modify CC2420ControlM to provide an extra ADC interface, and to use an additional Resource:

 provides {
 ...
 interface ADC as RSSI;
 ...
 }

 uses {
 ...
 interface ResourceCmd as CmdRSSI;
 ...
 }
 implementation { 
 ...
  async command result_t RSSI.getData() { 
    call CmdRSSI.deferRequest();
    return SUCCESS;
  }
  
  event void CmdRSSI.granted(uint8_t rh) { 
    uint16_t data;
    data = call HPLChipcon.read(rh, CC2420_RSSI);
    call CmdRSSI.release();
    data += 0x7f;
    data &= 0x00ff;
    signal RSSI.dataReady(data); 
    
  }

  async command result_t RSSI.getContinuousData() { 
    return FALSE;
  }

With the above interface, the RSSI readings are represented as positive, unsigned integers. To convert the above RSSI reading to dBm we need to subtract 173 from the reading (approximately, the actual number is somewhat dependent on the individual radio chip). For example, if the above reading yields 120, the measured signal strength is about -53dBm.