Skip to main content


Returns the imp’s power supply voltage




Float — the analog supply voltage


This method provides the unit’s power-supply voltage as a floating-point value in Volts. This can be used to issue low-battery warnings, or to aid interpretation of analog-to-digital converter (ADC) readings, which are obtained relative to the power-supply voltage. The imp WiFi hardware requires 3.3V, so unless your design takes special measures to raise 3.3V only when needed, the result of this call ought to remain close to 3.3.

The determination uses the STM32 microcontroller’s internal voltage reference, which is not precise. Consequently, the result may be up to two per cent off from the actual voltage.

Module-specific Information


hardware.voltage() is not implemented on the imp005.


With imp002 modules, the analog power supply and digital power supply can be separate and at different voltages — the VDDA and VDD pins, respectively — provided the analog supply is no higher than the digital. On imp002-based designs taking advantage of this separation, hardware.voltage() returns the current analog supply voltage. There is no way to determine the digital supply voltage.

Example Code

Reading an analog input returns a value relative to the imp’s power supply voltage. This code samples an analog input pin every second and uses hardware.voltage() to convert the pin’s value — a number between 0 and 65535 — into a voltage reading.