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

**URL:** <https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156>\
**Category:** Device Manager\
**Created:** [August 10, 2010, 10:40am UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156 "2010-08-10T10:40:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 10, 2010, 10:40am UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/1 "2010-08-10T10:40:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mkotasek](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mkotasek](https://forums.digi.com/u/mkotasek)\
**Post date:** [August 10, 2010, 2:14pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/2 "2010-08-10T14:14:42Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 10, 2010, 2:26pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/3 "2010-08-10T14:26:54Z")

</div>

Thanks for your quick reply,

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

Benjamin

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [August 10, 2010, 2:28pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/4 "2010-08-10T14:28:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 10, 2010, 2:41pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/5 "2010-08-10T14:41:15Z")

</div>

For now a few weeks notice seems enough.

Thanks for this interesting comment!

Benjamin

---

<div class="post-metadata">

**Author:** ![clohfink](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@clohfink](https://forums.digi.com/u/clohfink)\
**Post date:** [August 10, 2010, 3:15pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/6 "2010-08-10T15:15:06Z")

</div>

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

```auto
    
        
           
            
          
        
    

```

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.

---

<div class="post-metadata">

**Author:** ![clohfink](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@clohfink](https://forums.digi.com/u/clohfink)\
**Post date:** [August 10, 2010, 3:17pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/7 "2010-08-10T15:17:35Z")

</div>

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:

```auto
    
      
        
          
        
      
    

```

and look at the alias attributes.

---

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 10, 2010, 3:32pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/8 "2010-08-10T15:32:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mkotasek](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mkotasek](https://forums.digi.com/u/mkotasek)\
**Post date:** [August 10, 2010, 3:49pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/9 "2010-08-10T15:49:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 10, 2010, 3:59pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/10 "2010-08-10T15:59:42Z")

</div>

I tried this :

```auto

  
    
      
    
    
      
        
          
        
      
    
  

```

But the response is :

```auto

  
    
      
        
          
            
              State group unknown
              supply_voltage
            
          
        
      
    
  

```

Is it because of the Firmware?

Thanks

Benjamin

---

<div class="post-metadata">

**Author:** ![cpopp](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cpopp](https://forums.digi.com/u/cpopp)\
**Post date:** [August 10, 2010, 4:53pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/11 "2010-08-10T16:53:48Z")

</div>

Try sending the query\_state without the supply\_voltage element supplied, like:

```auto

  
    
      
    
    
      
        
      
    
  

```

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.

---

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 10, 2010, 4:59pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/12 "2010-08-10T16:59:55Z")

</div>

This is what I get with query\_state without individual parameter :

```auto

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

```

There is no supply\_voltage …

Thanks,

Benjamin

---

<div class="post-metadata">

**Author:** ![cpopp](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cpopp](https://forums.digi.com/u/cpopp)\
**Post date:** [August 10, 2010, 6:18pm UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/13 "2010-08-10T18:18:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bsoufflet](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bsoufflet](https://forums.digi.com/u/bsoufflet)\
**Post date:** [August 11, 2010, 9:40am UTC](https://forums.digi.com/t/is-it-possible-to-get-the-battery-level-of-an-xbee-node-using-digi-web-services/3156/14 "2010-08-11T09:40:48Z")

</div>

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

Benjamin
