Skip to content

Battery voltage incorrect #10

@mjdonders

Description

@mjdonders

If the TinyPICO helper is created and used immediately, the battery voltage reported is incorrect.
Rationale:

  • lastMeasuredVoltage isn't initialized in the constructor. Fix: in the constructor: lastMeasuredVoltage = 0.0f;

  • nextVoltage is set the current time, so if immediately after GetBatteryVoltage is called 'nextVoltage - millis() > 0' is false and the (currently uninitialized) lastMeasuredVoltage is returned without a new ADC read. Fix: in the constructor, change the nextVoltage initialization to: nextVoltage = millis() - 1; //do a '-1' to ensure I can get the battery voltage this msec.

Note that isToneInit isn't initialized in the constructor as well, even not related to this issue, I guess that initializing to false might be wise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions