hwCPUVoltage() on AVR screws up analogRead() readings
-
Can I use
hwCPUVoltage()
function to read cpu power supply voltage in my sketch? As far as I understand this function is not documented.I'm asking because this function affects
analogReference(INTERNAL)
with furtheranalogRead(pin)
call. According to source code it seems for me thathwCPUVoltage()
isn't restoring ADC settings before return.Simple code to test is looking something like this:
void setup() { analogReference(INTERNAL); } void loop() { analogRead(pin_number); // good value hwCPUVoltage(); analogRead(pin_number); // bad value }
-
There is a vcc voltage library if you want to read voltage supplied but I heard it isn't very accurate
1 out of 2
Suggested Topics
-
Code for beta-testing?
Controllers • 24 Mar 2014, 20:48 • andriej 9 Aug 2014, 10:44 -
Sensor presentation failure
Bug Reports • 31 Jul 2016, 19:23 • Sergio Rius 3 Mar 2021, 18:48 -
ACK -aka ECHO beeing missed by Serial Gateway with RF24 radios. V2.3.2
Bug Reports • 15 Apr 2023, 06:27 • GaryStofer 21 Apr 2023, 17:34 -
some differences between serial- and tcp-gateways.
Bug Reports • 15 Mar 2023, 09:26 • Branther 30 Mar 2023, 15:40 -
sleep(0) in V2.1 doesn't sleep indefinitely anymore. Used to powerdown and sleep in V1.5
Bug Reports • 22 Nov 2019, 00:35 • GaryStofer 15 Apr 2023, 05:50 -
Making WiFiManager compatible with MySensors 2.3.2
Bug Reports • 12 Feb 2020, 21:43 • pihome 1 Jun 2022, 16:02