Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wireless Paper (v1.0 & v1.1) not showing battery percentage #3208

Merged
merged 6 commits into from
Feb 13, 2024

Conversation

todd-herbert
Copy link
Contributor

@todd-herbert todd-herbert commented Feb 11, 2024

Addresses #3131

Affects:

Boards which are both:

  • ESP32S3, and
  • Measure battery with ADC2

As far as I am aware, this is currently only Wireless Paper V1.0 and V1.1.
Presumably any new boards meeting the criteria will suffer from the same issue?

Caveats:

usbPower and isCharging are not working correctly.
Looking at the schematic, it might not be possible to get the necessary information (?)

  • With no battery connected, VBAT hovers around 3.9V
  • The C̅H̅R̅G̅ pin of the TP4054 Li-lon Battery Charger IC does not connect to the MCU, only to an orange LED.

Code changes:

  • ADC config in variant.h (both boards)

  • Use gate ADC_CTRL to connect / disconnect voltage divider

  • For ESP32S3: avoid "ADC2 wifi bug workaround". Not required for S3, and breaks compile:

    firmware/src/Power.cpp

    Lines 271 to 273 in 1d44815

    // ADC2 wifi bug workaround, see
    // https://github.com/espressif/arduino-esp32/issues/102
    WRITE_PERI_REG(SENS_SAR_READ_CTRL2_REG, RTC_reg_b);

    Instead, check the esp_err_t returned by adc2_get_raw() to confirm that read was successful.

  • For ESP32S3: handle new enum value in logging:

    firmware/src/Power.cpp

    Lines 428 to 433 in 1d44815

    #ifdef CONFIG_IDF_TARGET_ESP32S3
    // ESP32S3
    else if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP_FIT) {
    LOG_INFO("ADCmod: ADC Characterization based on Two Point values and fitting curve coefficients stored in eFuse\n");
    }
    #endif

thebentern added a commit to meshtastic/artifacts that referenced this pull request Feb 11, 2024
src/Power.cpp Outdated Show resolved Hide resolved
@todd-herbert
Copy link
Contributor Author

@code8buster I do realize the suggestion was that the deprecated interface should be avoided. #3131 (comment)

I did look into the new API, but as far as I could tell (and I'm no expert), the required methods haven't yet been implemented in the Heltec Enviornment, despite recent releases.

@Gabrielerusso
Copy link
Contributor

Caveats:
usbPower and isCharging are not working correctly.
Looking at the schematic, it might not be possible to get the necessary information (?)
With no battery connected, VBAT hovers around 3.9V
The C̅H̅R̅G̅ pin of the TP4054 Li-lon Battery Charger IC does not connect to the MCU, only to an orange LED.

same as Heltec Tracker schematic, charge voltage is around 4.15V (average), isCharging in my case is working only with full battery as the lookup table i use measures anything above 4150mV as fully charged, so by going over that it recognizes it's connected.

For the usbPower also there is the same problem.

I don't understand why the charge output of the TP4057 isn't connected even if would be pretty simple to do so afterwards (DIY).

thebentern added a commit to meshtastic/artifacts that referenced this pull request Feb 11, 2024
@todd-herbert
Copy link
Contributor Author

todd-herbert commented Feb 12, 2024

@Gabrielerusso Sorry, that was an accident; I bumped the button. I know you've already reviewed it. Thanks for your input.

thebentern added a commit to meshtastic/artifacts that referenced this pull request Feb 12, 2024
Copy link
Contributor

@code8buster code8buster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have hardware to test this with, but it does pass the smell test.
It's possible that your code for reading adc2 is actually better overall.

I never found anyone to test the "workaround" with a heltec v2/2.1 that was also connected to wifi.

@todd-herbert
Copy link
Contributor Author

It might have been unnecessary at this point, but here is at least some measure of proof.

@thebentern thebentern merged commit 0b466fd into meshtastic:master Feb 13, 2024
66 checks passed
@todd-herbert todd-herbert deleted the battery-percentage branch February 15, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants