[D32] VBAT adc clarification

Open
#17 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
arduino

Research direction

Locate the D32 documentation and the schematics referenced in the issue, then compare the documented GPIO and charging connections with the hardware. Update the text with the VBAT divider, GPIO35 reading method, current, and CHRG connection; clarify whether the listed hardware improvements are in scope.

Written by the indexing model from the issue text.

Description

this is missing in the text and needs to be read out from the schematics.

the VBAT is connected over a voltage divider (100k/100k) to GPIO35. (maximum current of 21.5µA)
the CHRG pin is not connected to a gpio (but a vbus powered led)

following a sample sketch to get the VBAT:

#include <sys/time.h>
#include <Arduino.h>

//#define LOG(fmt, ...)
#define LOG(fmt, ...)  (Serial.printf("%09llu: " fmt "\r\n", GetTimestamp(), ##__VA_ARGS__)); Serial.flush();
//#define DEBUGLOG(fmt, ...)
#define DEBUGLOG(fmt, ...) (Serial.printf("%09llu: [DEBUG]" fmt "\r\n", GetTimestamp(), ##__VA_ARGS__)); Serial.flush();

int64_t GetTimestamp() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return (tv.tv_sec * 1000LL + (tv.tv_usec / 1000LL));
}

void setup() {
  Serial.begin(115200);
  Serial.flush();
  if (adcAttachPin(35)) {
    LOG("[SYSTEM]ADC attached!");
  }
}
void loop() {
  unsigned int millivoltage = analogReadMilliVolts(35);
  int VDRatio = 2;
  LOG("[SYSTEM] VBAT: %.2f V", (millivoltage * VDRatio/1000.0));
  delay(5000);
}

and the serial output:

001415884: [SYSTEM] VBAT: 4.22 V
001420887: [SYSTEM] VBAT: 4.22 V

Improvements:

  • make the CHRG pin available
  • make the CHRG led optional
  • disconnect the VBAT voltage divider with a p-mosfet
  • connect the PROG over a p-mosfet to ground for disabling the charge circuit
Dominant language
No language data
Stars
38
Forks
36
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wemos/docs

All issues in wemos/docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.