LoRa Node 151 ADC measure battery voltage

I’m currently testing the LoRa node 151 using the example code for the STM32CubeIDE.

I’ve connected a HDC1080 sensor after adding the stm32L1xx I2C drivers, works fine, low power in sleep (stop mode) as expected.

Now I’m trying to see if I can measure the battery voltage with ADC to transmit along with temp and humidity. I’ve worked with similar implementations of this LoRaWAN code that had ADC drivers implemented and measured battery voltage level from a specific pin.

Is this possible on the LoRa Node 151, the pinout refers to PA_2 for power detection, can this pin be used to read voltage level with ADC?

I’ve tried reading PA_2 but am getting 0 values, although could easily be my code.

Any help greatly appreciated.

Please refer to the schematic diagram, we need set PB3 low to enable the Q6 first, and then read ADC data via PA2.

1 Like

I have the same problem. I tried setting PB3 LOW. It does drop the input voltage from 3.8V to 2.1 V but there is still some voltage sneaking in.
Any way to use any of the other GPIO pins as an analogRead?

Did anyone every get a solution to this? I have several node 151s running on battery and even compensating for the voltage divider, I am still getting reading that cannot be correct. Here is my code followed by the readings. Note I am using the LoRaWAN_151CC code with ADC measurement.

   //voltage divider on ADC2 input
   //val = (R2/(R1+R2))*batt_mv
   //R1=220K, R2=100K
      // val is a function variable and is a uint32_t
   uint32_t batt_mv = val * 3.2;

   AppData[0] = batt_mv >>8 ;
   AppData[1] = batt_mv;

   DebugPrintf("ADC Value : %u mv - %x\r\n",val,val);
   DebugPrintf("Battery : %u mv - %x\r\n",batt_mv,batt_mv);


ADC Value : 1281 mv - 501
Battery : 4099 mv - 1003

the batteries measure at 3.67VDC using a DMM