Main Content

readVoltage

Read voltage from analog input pin

Description

example

voltage = readVoltage(bbb, pin_name) measures the voltage applied to an analog input pin relative to the ADC ground pin (GND_ADC).

The BeagleBone® Black board has six analog input pins. Each analog input pin has a 12-bit ADC that converts the analog input voltage to a digital voltage reading. The ADC-driver built into the Linux® kernel returns the voltage measurement converted to a double. The values range from 0 V (GND_ADC) to 1.8 V (VDD_ADC).

Caution

  • Never connect a voltage greater than 1.8 Vacross the ADC pins. Voltages greater than 1.8 V can damage the board.

  • Always connect the negative (ground) side of a voltage source to GND_ADC. The ADC measures positive voltages only. A reversed connection can damage the board.

Examples

collapse all

Read voltage at pin 'AIN0'

bbb = beaglebone();
readVoltage(bbb, 'AIN0')
ans = 

1.64

Input Arguments

collapse all

BeagleBone Black connection created using beaglebone, specified as an object.

Name character vector.

Example: 'AIN0'

Data Types: char

Output Arguments

collapse all

Voltage at analog GPIO pin, in volts

Version History

Introduced in R2015a