Wrong battery level readings

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

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 (not emonPi).

Ok, I am getting there. Spend quite some time on your forum and websites now. Came across an upload tool, which simplifies my life:

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.

@Robert.Wall

I followed instructions here 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?

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

remote2

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?

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.

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)

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

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

    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.

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).

  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

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

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.

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

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: [email protected]

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

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:

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

1 Like

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

3.0 initial = 1.5 subsequent
3.2 initial = 1.6 subsequent

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

Somehow, I don’t think that’s right. :open_mouth:

Soldered the pins onto the board and it is now reporting the correct voltage.

Obviously the one that got away during manufacture.

The crystal and D5? So how was it appearing to work at all? (@Amaravati never mentioned an external DS18B20, so I assume D5 not connected made no difference.)
But why/how an apparently correct first reading, then about half what it should be? That I don’t understand.

@Gwil - it possible you are counting the pins clockwise from the “pin 1 corner marker” so you are looking at pins 25 and 24, which makes more sense since ADC1 (batt voltage) is on pin 24 (the 9th pin clockwise).

[edit - better pic with pin numbers]

1 Like

Yes, sorry everyone - Paul is correct, the pins were 25 and 24.

Thanks for reporting back @Gwil, good to see there was indeed something not properly connected on the board. It was rather strange to have a first ‘correct’ reading, and subsequent wrong readings…