Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

Knowledge Base

ADC Pi C Library

ADC Pi C Library Installation and Usage

Created 29/07/2024 | Last Updated: 30/07/2024

C Library to use with ADC Pi Raspberry Pi development board.

The example C programs can be found in /ABElectronics_C_Libraries/ADCPi/demos

Downloading and Installing the library

To download to your Raspberry Pi type in the terminal:

git clone https://github.com/abelectronicsuk/ABElectronics_C_Libraries.git

Functions

read_raw(uint8_t address, uint8_t channel, uint8_t bitrate, uint8_t pga,	uint8_t conversionmode)

Reads the raw value from the selected ADC channel
Parameter: (uint8_t) address - I2C address for the target device e.g. 0x68
Parameter: (uint8_t) channel - 1 to 4
Parameter: (uint8_t) bitrate - 12, 14, 16 or 18
Parameter: (uint8_t) pga - 1, 2, 4 or 8
Parameter: (uint8_t) conversionmode - 0 = one shot conversion, 1 = continuous conversion
Returns: (uint32_t) value from ADC buffer


read_voltage(uint8_t address, uint8_t channel, uint8_t bitrate, uint8_t pga, uint8_t conversionmode);

Reads the voltage from the selected ADC channel
Parameter: (uint8_t) address - I2C address for the target device e.g. 0x68
Parameter: (uint8_t) channel - 1 to 4
Parameter: (uint8_t) bitrate - 12, 14, 16 or 18
Parameter: (uint8_t) pga - 1, 2, 4 or 8
Parameter: (uint8_t) conversionmode - 0 = one shot conversion, 1 = continuous conversion
Returns: (double) voltage value from ADC