Is it possible to get the battery level of an Xbee node using digi web services?

Hi,

Is it possible to get the battery level or the battery voltage of the Xbee devices using a RCI call or something else?

Thanks for your help,

Benjamin

Hi Benjamin,

I’m making a few assumptions about your setup. That you are running on a device that has the python interpreter, and that you have a means to upload RCI requests to the device.

To setup a RCI call to return a node’s battery level or voltage, you’ll have to use a python script to catch the RCI call, call the ‘IS’ AT command on the specified node, interpret the results, and return the values.

To setup the RCI callback, you need to use the ‘rci’ library and register a callback to process the incoming RCI request. See this link for more info: http://www.digi.com/wiki/developer/index.php/Rci

Then you need to request the ‘IS’ AT command from the specified node using the xbee library’s ddo_get_param() function. See link for more info: http://www.digi.com/wiki/developer/index.php/Xbee

The ‘IS’ byte structure has a specified structure, depending whether you are running ZB or another XBee technology. Your appropriate radio manual will contain the definition. Additionally, the ‘low battery’ pin is also defined here, which changes per radio platform.

An alternative is the ‘%V’ value, which is available on some radio technologies. It returns the current supply voltage as the radio sees it.

Once you have your answer, just return the answer in the call back, and you’re done.

Hope this helps,
Max

Thanks for your quick reply,

We will try to use a Python Script as you described it for this.

Benjamin

Just be aware that this ‘%V’ value is only the voltage on XBee Vcc (power input) pin. So if there is a voltage regulator between your battery and your XBee, you will only see the output of the regulator. All Digi XBee adapters are designed like this today.

So it might read 3.3v for a long time, then start dropping as the battery input to the regulator falls below the regulator’s required minimum to sustain 3.3v out. So you’ll only have a few weeks notice once the battery starts to drop - especially with lithium.

To get a true battery level you’ll need to design your own circuit to feed this voltage into an AD/analog pin. Just be aware that tapping the battery like this will add a small load to the battery, which will reduce your battery life some.

For now a few weeks notice seems enough.

Thanks for this interesting comment!

Benjamin

I think you can get the ‘%V’ value also with a:

    
        
           
            
          
        
    

I haven’t verified this however… not really sure if it would work. But if currently using web services it might avoid the need for writing a python script.

Although something to note if doing this through RCI is that if wrapped in SCI iDigi would cache the results, so be sure if you want it executed on the device to add the cached=“false” attribute to the send_message element.

Also if ever need mapping between the DDO and the long name used in the web services check the descriptor with:

    
      
        
          
        
      
    

and look at the alias attributes.

Hi thanks for your answer,

Is only available on new firmware? I have 2.9.0.7 installed on my gateways and there is no supply_voltage available when I send a query_setting command.

Thanks,

Benjamin

Supply voltage is only available for query_state:

Which returns the supply voltage field for the XBee. Specifying the address like clohfink said will allow you to get the state from any node on the network.

I tried this :



  
    
      
    
    
      
        
          
        
      
    
  

But the response is :



  
    
      
        
          
            
              State group unknown
              supply_voltage
            
          
        
      
    
  


Is it because of the Firmware?

Thanks

Benjamin

Try sending the query_state without the supply_voltage element supplied, like:


  
    
      
    
    
      
        
      
    
  

I do not believe the query_state request for zigbee supports requesting individual parameters. If the above works you should be able to see which values are returned and pull out the supply_voltage if present.

This is what I get with query_state without individual parameter :


  
    
      
        
          
            
              0x400
              0xc
              0x804b
              0x1843
              0x50002
              73
              20858
              80
              0x2040
              200
              2000
              65535
              65535
              3333
              65535
              18
            
          
        
      
    
  

There is no supply_voltage …

Thanks,

Benjamin

I don’t have a 2.9.0.7 version device, but I did try it on 2.10.0.7 level device and I have supply_voltage present in the query_state reply. If updated firmware is available you might want to give it a try, I’m not sure when supply_voltage was added.

Chris

Thanks!
I will try it with the new firmware as soon as I am able to upgrade it.

Benjamin