# Wrong battery level readings

**URL:** <https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462>\
**Category:** emonTH\
**Created:** [3 February 2018 19:39 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462 "2018-02-03T19:39:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [3 February 2018 19:39 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/1 "2018-02-03T19:39:14Z")

</div>

Hi,

We have 8 emonTHs, and 1 gives the ‘wrong’ battery level data. It says 1.5 V, even when we put new batteries in there.

Anyone know what I can do about this?

Thanks

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [3 February 2018 22:18 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/2 "2018-02-03T22:18:57Z")

</div>

Is it a new purchase or a fault that’s just appeared? If new, when did you buy it and what colour is the board?  
Where does it give the wrong data - on the FTDI connector and the Arduino serial window, emonCMS or what?

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [3 February 2018 23:07 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/3 "2018-02-03T23:07:44Z")

</div>

HI @Robert.Wall , sorry about the lack of info.

We ‘got’ this at the end of 2016, by an engineer who installed the heating system/mvhr/passive house. The board look like this: [https://community.openenergymonitor.org/uploads/default/original/2X/e/ea412484d6a3c5ee47cc6bd5bbb0befe00d0a6fc.jpg](https://community.openenergymonitor.org/uploads/default/original/2X/e/ea412484d6a3c5ee47cc6bd5bbb0befe00d0a6fc.jpg) (it seems to be v2?).

We have an emonPi, which shows those readings of 1.5V.

I checked the ‘config’ files in EmonHub, the node has the same settings/configurations/numbers etc as the other emonTH. So the readings seems ‘legit’ … The temp/hr/rssi are all in line with another emonTH I have placed next to it. I also used a volt meter to test the batteries, and they are the ‘same’ voltage as another emonTH, which shows around a 3.0 reading.

Anything I can do to correct this?

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [4 February 2018 00:06 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/4 "2018-02-04T00:06:24Z")

</div>

I think there is a very slim possibility that the emonTH sketch has been changed - this might have happened before you got the unit, but I can’t think of a reason to do so, unless someone was experimenting. If you have a programmer, it would be possible to reload to original sketch.

One question - is the reading rock solid, or does it change with battery condition, i.e, is it working but the scale is wrong? If it’s a constant value, I can’t suggest a cure other than to try reloading the sketch. If it’s wrongly scaled, then adjusting the appropriate value in the line `scales = ` in emonhub.conf to give you the right numbers as shown on your meter is the best I can suggest. If it’s exactly 1.5 when the true battery voltage is exactly 3.0, then the final `0.1` becomes `0.2`.

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [4 February 2018 06:43 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/5 "2018-02-04T06:43:28Z")

</div>

Hi,

The battery level is 1.5V. Since I just started investigate/use the emonPi/TH/Tx myself (after 1 year being used and installed by engineer) I just discovered that it had a ‘wrong’ battery reading.

The Temperature and RH readings seems to be fine.

I am happy to learn how to reload the sketch, but needs some beginners clues how to do that.

P.s. I have another thread only trying to figure out how to change the node name on [emoncms.org](http://emoncms.org) (totally new beginner here)

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [4 February 2018 11:56 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/6 "2018-02-04T11:56:36Z")

</div>

You need:

1. [A programmer](https://shop.openenergymonitor.com/programmers/)  
(Those from other places might or might not work out of the box.)
2. The Arduino IDE & libraries. The instructions to get yourself set up are in ‘Learn’, under “Using the Arduino IDE”.
3. The sketch. Get the whole “src” directory from [emonth2/firmware at master · openenergymonitor/emonth2 · GitHub](https://github.com/openenergymonitor/emonth2/tree/master/firmware)  
and move it complete with contents into the “sketchbook” directory of the Arduino IDE.

Beware connecting the programmer. The connector is not polarised, line up “GND” on the programmer and emonTH.  
The main sketch is (confusingly) src.ino, but config.ino is part of it and is included automatically. Compile and upload.

> [@Amaravati](#):
>
> P.s. I have another thread only trying to figure out how to change the node name on [emoncms.org](http://emoncms.org) (totally new beginner here)

Click the ‘pencil’ icon, rename it, click the tick.

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [4 February 2018 14:36 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/7 "2018-02-04T14:36:18Z")

</div>

Ok, that’s helpful! I google that I came upon this:

> **[Firmware Modification](https://guide.openenergymonitor.org/technical/compiling/)**
>
> Compiling Firmware

So, since this is a emonTH on node 30. I will also need to adapt the src.ino into node 30 right?

I guess I will need to get one of these programmers first! Thanks.

P.s. I saw your reply on my renaming thing… I think we misunderstood what I wanted to rename… it is the node’s name on [emoncms.org](http://emoncms.org) (not emonPi).

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [4 February 2018 15:31 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/8 "2018-02-04T15:31:18Z")

</div>

Ok, I am getting there. Spend quite some time on your forum and websites now. Came [across](https://github.com/openenergymonitor/emontx-3phase) an upload tool, which simplifies my life:

> **[GitHub - openenergymonitor/emonupload: Upload / update latest...](https://github.com/openenergymonitor/emonupload)**
>
> Upload / update latest OpenEnergyMonitor firmware. Contribute to openenergymonitor/emonupload development by creating an account on GitHub.

Have asked for ordering the programmer tool. Was tempted to get something from amazon, but relented to avoid any difficulty. (Also couldn’t really find anyone on the forum sharing alternatives).

Hope it works.

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [10 February 2018 13:39 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/9 "2018-02-10T13:39:16Z")

</div>

@Robert.Wall

I followed instructions [here](https://guide.openenergymonitor.org/technical/compiling/) about compiling. I followed until step 4 and 5. Step 4 (building/compiling) I get ‘issues’

> ```
> Compiling .pioenvs\emonth2\src\src.ino.o
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/src.ino: In function 'void loop()':
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/src.ino:452:19: warning: unused variable 'last' [-Wunused-variable]
> 
> unsigned long last = now;
> ^
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/config.ino: In function 'void save_config()':
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/config.ino:100:22: warning: comparison between signed and unsigned integer expressions 
> [-Wsign-compare]
> for (int i = 0 ; i < EEPROM.length() ; i++) {
> ^
> In file included from C:/Users/Admin/Downloads/emonth2-master/firmware/src/src.ino:78:0:
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/config.ino: At top level:
> .piolibdeps\JeeLib_ID252/RF69_avr.h:122:13: warning: 'spiInit' defined but not used [-Wunused-function]
> static void spiInit (void) {
> ^
> .piolibdeps\JeeLib_ID252/RF69_avr.h:154:16: warning: 'spiTransfer' defined but not used [-Wunused-function]
> static uint8_t spiTransfer (uint8_t cmd, uint8_t val) {
> ^
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/src.ino:480:13: warning: 'writeReg' defined but not used [-Wunused-function]
> static void writeReg (uint8_t addr, uint8_t value) {
> ^
> C:/Users/Admin/Downloads/emonth2-master/firmware/src/src.ino:484:16: warning: 'readReg' defined but not used [-Wunused-function]
> static uint8_t readReg (uint8_t addr) {
> ^
> 
> ```

I am not sure why this happens, than when I upload, it adds more stuff on it, see below:

> ```
> ^
> Linking .pioenvs\emonth2\firmware.elf
> Checking program size
> Building .pioenvs\emonth2\firmware.hex
> 
> text data bss dec hex filename
> 14808 468 629 15905 3e21 .pioenvs\emonth2\firmware.elf
> [SUCCESS] Took 28.96 seconds
>  
> [SUMMARY]
> Environment emonth2 [SUCCESS]
> Environment isp [SKIP]
> Environment emonth2_deploy [SKIP]
> [SUCCESS] Took 28.96 seconds
> Uploading firmware remotely
> Could not find active agents. Please start it before on a remote machine using `pio remote agent start` command.
> See http://docs.platformio.org/page/plus/pio-remote.html
> 
> ```

Could someone help?

 ![Capture](https://community.openenergymonitor.org/uploads/default/original/2X/d/dae8e64709a5aff645ad567610dfb86e9173fedc.PNG)

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [10 February 2018 14:31 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/10 "2018-02-10T14:31:24Z")

</div>

OK, a bit of false alarm.

You have to click UPLOAD and not UPLOAD TO REMOTE. So the manual is not correct anymore, and the upload icon is now defaulted to ‘upload to remote device’.

![remote](https://community.openenergymonitor.org/uploads/default/original/2X/a/a423bf264badee770fa4dda9d3cec49b7aec9505.PNG)

![remote2](https://community.openenergymonitor.org/uploads/default/original/2X/c/c3a9f6aba3376d45d4e37096536ab1b47e92d3a8.PNG)

Well @Robert.Wall, I managed to upload the firmware with the above mentioned warnings. The emonTH then shows 3.1V!!! But that is only for the first input, the second input after 60s, it reverts back to 1.5V. So no luck here, do you have anymore recommendations?

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [10 February 2018 15:44 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/11 "2018-02-10T15:44:57Z")

</div>

I can’t use platformio, so I’ve no idea what is happening with that. You can however ignore the warnings, some are things that ought to be tidied up but have not been, some are simply saying there are library functions that you’re not using.

> [@Amaravati](#):
>
> The emonTH then shows 3.1V!!! But that is only for the first input, the second input after 60s, it reverts back to 1.5V.

That is weird!  
Have you a second Node 30 on the system?

Where are you reading 3.1 V as the first reading, then 1.5 V afterwards? Is it at the Serial Monitor via the FTDI connector, or via your emonCMS? (You should see “batt:31” for 3.1 V in the Serial Monitor.)

[Edit]  
If you’re seeing 3.1 V then 1.5 V at both, try copying this line (442)

```auto
      Serial.print("batt:"); Serial.print(emonth.battery);

```

and put a copy immediately below line 385, to give you:

```auto
    emonth.battery=int(analogRead(BATT_ADC)*0.0322); //read battery voltage, convert ADC to volts x10
    Serial.print("batt:"); Serial.print(emonth.battery);

```

If you get 3.1 V from the this new print, and 1.5 from the original, there’s a problem with the voltage being changed after it has been read.

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [11 February 2018 15:50 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/13 "2018-02-11T15:50:55Z")

</div>

Thanks @Robert.Wall

I deleted my previous post, which was a bit of sharing my exhaustion to get the serial monitor to work (which didn’t). But of course one minute after I posted I found one ([solution documented/shared here](https://community.openenergymonitor.org/t/serial-monitor-gibberish/6546)).

1. no we do not have another node 30

2. previously I only read from the emonPi. currently I can read this:  

3. after you I updated the firmware with your suggestion I get this:  
 ![Capture](https://community.openenergymonitor.org/uploads/default/original/2X/b/bcb29241708927123770cccd824174ff8f0b4070.PNG)

In both cases the first reading is 31 (or 32) and then subsequent reading is 15.

So… (hardware) broken?

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [11 February 2018 16:20 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/14 "2018-02-11T16:20:21Z")

</div>

> [@Amaravati](#):
>
> So… (hardware) broken?

That could be a possibility. I cannot see or think of anything to explain what’s happening - especially as everything else seems to be working. Let’s see what @glyn.hudson has to say.

At least we know the value isn’t being changed between reading it and transmitting it, so the software seems to be OK. It’s almost as if the scaling factor - the “0.0322” in  
`emonth.battery=int(analogRead(BATT_ADC)*0.0322); ` is being changed, or it’s reading something else, after the first time it’s sent, but I can’t see how that can happen.

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [18 February 2018 19:01 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/15 "2018-02-18T19:01:20Z")

</div>

@glyn.hudson anything you could help us with this?

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [19 February 2018 01:45 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/16 "2018-02-19T01:45:11Z")

</div>

Am I right in understanding that this issue only effects 1/8 of your emonTH’s? If so it sounds like a hardware fault issue. Please contact shop support: _[support@openenergymonitor.zendesk.com](mailto:support@openenergymonitor.zendesk.com)_

---

<div class="post-metadata">

**Author:** ![Amaravati](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@Amaravati](https://community.openenergymonitor.org/u/Amaravati)\
**Post date:** [26 February 2018 14:46 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/17 "2018-02-26T14:46:53Z")

</div>

@Gwil I hope you received the emonTH unit back from me! Let us know if you find any causes for that emonTH.

---

<div class="post-metadata">

**Author:** ![Gwil](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/gwil/32/29028_2.png) [@Gwil](https://community.openenergymonitor.org/u/Gwil)\
**Post date:** [1 March 2018 10:22 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/18 "2018-03-01T10:22:36Z")

</div>

Thank you, we received the board. We loaded it with the latest sketch (V3.2.3) and it looks to be working fine - the battery voltage readings are correct:

 ![20180301_101542](https://community.openenergymonitor.org/uploads/default/original/2X/0/0a1cb385a1eb19def66b088882e2b6592d1fd52f.jpg)

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [1 March 2018 12:41 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/19 "2018-03-01T12:41:44Z")

</div>

Does it continue to show 3.2 V? @Amaravati reported the first reading correct, then it dropped to 1.5 V.

---

<div class="post-metadata">

**Author:** ![Gwil](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/gwil/32/29028_2.png) [@Gwil](https://community.openenergymonitor.org/u/Gwil)\
**Post date:** [1 March 2018 14:09 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/20 "2018-03-01T14:09:05Z")

</div>

Ok, we’ve been logging it to a feed and it is reading 1.6V consistently - we are seeing the same thing happen.

> [@Amaravati](#):
>
> I also used a volt meter to test the batteries, and they are the ‘same’ voltage as another emonTH, which shows around a 3.0 reading.

3.0 initial = 1.5 subsequent  
3.2 initial = 1.6 subsequent

---

<div class="post-metadata">

**Author:** ![Gwil](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/gwil/32/29028_2.png) [@Gwil](https://community.openenergymonitor.org/u/Gwil)\
**Post date:** [1 March 2018 14:17 UTC](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462/21 "2018-03-01T14:17:06Z")

</div>

Looking closely at the board, pins 8 and 9 of the atmega 328 are not in contact with the board.

[Next page](https://community.openenergymonitor.org/t/wrong-battery-level-readings/6462.md?page=2)
