# Read battery status

**URL:** <https://discourse.nodered.org/t/read-battery-status/89953>\
**Category:** Hardware\
**Created:** [2 August 2024 11:18 UTC](https://discourse.nodered.org/t/read-battery-status/89953 "2024-08-02T11:18:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kralle](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@Kralle](https://discourse.nodered.org/u/Kralle)\
**Post date:** [2 August 2024 11:18 UTC](https://discourse.nodered.org/t/read-battery-status/89953/1 "2024-08-02T11:18:14Z")

</div>

Hello,

I use the Dragino CPL03-LB with the code recommended by the manufacturer (see below) in the data that arrives in Node Red I can't find any data for the battery status. For other sensors I find the value batV. That has to be possible. Does anyone know how this works? Thank you

[Dragino CPL03 Formatter Code.txt](https://discourse.nodered.org/uploads/short-url/gYO3xquVpTY0k7miDjAF6qDT4Ih.txt) (4.9 KB)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 August 2024 13:26 UTC](https://discourse.nodered.org/t/read-battery-status/89953/2 "2024-08-02T13:26:57Z")

</div>

A quick look at the code shows it has different functions in it. One of the functions

`function Decoder(bytes, port) {`

checks the port and if it matches 0x05  
` else if(port==0x05)`  
Then it returns some batter y information.

If you have any other questions about this code you should contact Dragino.

---

<div class="post-metadata">

**Author:** ![Kralle](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@Kralle](https://discourse.nodered.org/u/Kralle)\
**Post date:** [6 August 2024 10:10 UTC](https://discourse.nodered.org/t/read-battery-status/89953/3 "2024-08-06T10:10:00Z")

</div>

Thanks zenofmud for your answer. I haven't been in the Node Red world for that long. I have a fundamental question of understanding. Currently the sensor is sending on port 2 and according to the debug under decoded\_payload gives Alarm, CMOD Last\_Duration, Pin\_Status, TDC, Time, Total\_Pulse. etc. This is also data that I need. How do I get the data from the battery??? Probably via a different port. Is all other data then gone? Thank you

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 August 2024 11:00 UTC](https://discourse.nodered.org/t/read-battery-status/89953/4 "2024-08-06T11:00:05Z")

</div>

Sadly I'm not going to be of much help since I don't have the device ad have no experience with it.

As for saving data from a reading there are several things you could do

1. store it in a database
2. store it in [context](https://nodered.org/docs/user-guide/context)
3. you could join messages into one msg: See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 November 2024 11:00 UTC](https://discourse.nodered.org/t/read-battery-status/89953/5 "2024-11-04T11:00:16Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
