analogRead(ADC_BATTERY) not working on Nano 33 Iot

Used to use a simple statement as below:

adcReading = analogRead(ADC_BATTERY);

to measure battery level on MKR Wifi 1010, it turned out the statement is not working on Nano 33 Iot.
Error during compiling: “exit status 1
‘ADC_BATTERY’ was not declared in this scope”

Tried following declaration, which by the way hasn’t ever required on MKR Wifi1010:

#define ADC_BATTERY (32u)

Result is an infinite loop and program execution not moving forward.

Could someone provide some specific suggestion on how to fix it.?

Obviously the assumption is that Nano Iot has the same internal battery level measurement as MKR wifi1010 does. Is that a wrong assumption?

Thanks in advance


The Arduino Nano 33 IoT has an additional analog pin over the MKRWifi1010. You can connect your battery voltage divider there. To make the code compatible you can then define the ADC_BATTERY using that pin. e.g.

#define ADC_BATTERY   A7

Note: This will only make high level code compatible. The pins are not the same. e.g. MKRWifi1010 pin A5 is not the same as Nano 33 IoT pin A5. So, any low level code that manipulates registers might not be compatible.

There is no internal battery measurement. The MKRWifi1010 has a voltage divider connected to one of the pins that is connected to the ADC. Have a look at the schematic. You can find it in the store under DOCUMENTATION.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.