Wireless Stick Lite wrong voltage measurement

Recently used code with Wireless Stick (which has display) and had accurate voltage reading through switching Vext pin and making measurements on adc pin #37.

Uploaded the same code to wireless stick lite and now the batt voltage always around 4.44V which incorrect. ADC returns value around 1504. Probably it has a different resistor for the voltage divider.

What are the correct values for ADC read with this board when using standard 3.7v lipo (fully charged to 4.2v)?
With wireless stick or lora32 I use following ADC values to determine full and drained battery: 1420 (4.2v) and 1080 (3.2v).

Thanks in advance.

can you post your test code?

Here is the code below. I suspect that voltage divider has different values for Wireless Stick and Wireless Stick Lite and for this reason I’m getting higher values for Wireless stick lite (v2.1)

#include "Arduino.h"

#define Vext 21 //seems to be outer power pin (battery control)

void setup() {
  Serial.begin(115200);
  adcAttachPin(37);
  analogSetClockDiv(255); // 1338mS
  pinMode(Vext, OUTPUT);  
}

float getBatteryVoltage(int nbMeasurements, int pin) {
    float voltageDivider = 1;
    // int readMin = 1080; // -> 338 * 3.2 // If you want to draw a progress bar, this is 0%
    // int readMax = 1420; // -> 338 * 4.2 // If you want to draw a progress bar, this is 100%

    // Take x measurements and average
    int readValue = 0;
    for (int i = 0; i < nbMeasurements; i++) {
        readValue += analogRead(pin);
        delay(100);
    }
    
    float voltage = (readValue/nbMeasurements)/voltageDivider;
    return voltage;
}

void loop() {
  digitalWrite(Vext, LOW);//battery control turn on/off
  delay(500);
  float volts = getBatteryVoltage(4,37);
  Serial.println(volts);
  Serial.println("=====");
  digitalWrite(Vext, HIGH);
}
1 Like

hi,

Probably it has a different resistor for the voltage divider.

they are the same.

here is Calculation formula:
V=2300/3000*ADC+150(mV)

Thank you Jason.

If you advice to use this formula to get the voltage

then we have a problem.
analogRead(37) ADC at wireless stick currently returns 1365
using in the formula above we will get 1196.5 mV which is 1.19 volts.

meanwhile the same code above but printing ADC value only, same battery switched from one board to another within 10 seconds:
wireless stick: 1380
wireless stick lite: 1470

This test shows that analogRead(37) has different values with the same battery at the same level for Wireless Stick and Wireless Stick Lite. Assuming your words that both boards has same resistors for voltage divider than I should have a similar values for analogRead(37).

Is there a bug somewhere?