Skip to content

Fix rak11310 Voltage Read #6618

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Nivek-domo
Copy link
Contributor

@Nivek-domo Nivek-domo commented Apr 18, 2025

add voltage read correction for rak11310

πŸ™ Thank you for sending in a pull request, here's some tips to get started!

❌ (Please delete all these tips and replace them with your text) ❌

  • Before starting on some new big chunk of code, it it is optional but highly recommended to open an issue first
    to say "Hey, I think this idea X should be implemented and I'm starting work on it. My general plan is Y, any feedback
    is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
  • Please do not check in files that don't have real changes
  • Please do not reformat lines that you didn't have to change the code on
  • We recommend using the Visual Studio Code editor along with the 'Trunk Check' extension (In beta for windows, WSL2 for the linux version),
    because it automatically follows our indentation rules and its auto reformatting will not cause spurious changes to lines.
  • If your PR fixes a bug, mention "fixes #bugnum" somewhere in your pull request description.
  • If your other co-developers have comments on your PR please tweak as needed.
  • Please also enable "Allow edits by maintainers".
  • Please do not submit untested code.
  • If you do not have the affected hardware to test your code changes adequately against regressions, please indicate this, so that contributors and commnunity members can help test your changes.
  • If your PR gets accepted you can request a "Contributor" role in the Meshtastic Discord

🀝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other (please specify below)

add voltage read correction for rak11310
@fifieldt fifieldt changed the title Update Power.cpp Fix rak11310 Voltage Read Correction Apr 18, 2025
@fifieldt fifieldt changed the title Fix rak11310 Voltage Read Correction Fix rak11310 Voltage Read Apr 18, 2025
#if defined(RAK11310)
float voltage_raw = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / 1023) * raw;

LOG_INFO("[POWER DEBUG] AREF=%.2fV, ADC_RAW=%u, ADC_MULT=%.2f",
Copy link
Member

Choose a reason for hiding this comment

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

Please don't log an info called 'DEBUG' :-)


scaled = (voltage_raw * 1.22f) - 0.1f;
scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / 4096) * raw;
LOG_INFO("[POWER CORRECTION] Before=%.2fmV, After=%.2fmV",
Copy link
Member

Choose a reason for hiding this comment

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

Please drop the [POWER CORRECTION] - Log lines will be auto-prefixed with the thread name.

(double)operativeAdcMultiplier);

scaled = (voltage_raw * 1.22f) - 0.1f;
scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / 4096) * raw;
Copy link
Member

@caveman99 caveman99 Apr 19, 2025

Choose a reason for hiding this comment

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

you are computing scaled twice here. either the latter is in here by mistake or you can drop the former one.

raw,
(double)operativeAdcMultiplier);

scaled = (voltage_raw * 1.22f) - 0.1f;
Copy link
Member

Choose a reason for hiding this comment

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

1.22f seems to be a correction factor. can we make this a generic correction macro and remove the #ifdef bracket? In case we need it on more than the 11310

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.

2 participants