The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.
- Home
- Help and Support
- Knowledge Base
- Code & Languages
- C++ Library and Demos
- ADC Pi Library for C++
-
Raspberry Pi
- PCB Header Assembly Jig
- Raspberry Pi GPIO Pins
- Samba Setup on Raspberry Pi
- Set a static IP Address on Raspberry Pi OS Bookworm
- I2C Part 1 - Introducing I2C
- I2C Part 2 - Enabling I2C on the Raspberry Pi
- I2C Part 3 - I2C tools in Linux
- I2C Part 4 - Programming I2C with Python
- SPI and Python on Raspberry Pi OS
- Using Pythonpath with our Python Libraries
- Connecting Development Boards to the Raspberry Pi 400
- General
- Code & Languages
- Raspberry Pi Pico Tutorials
- 1 Wire Pi Tutorials
- ADC Pi Tutorials
- ADC DAC Pi Zero Tutorials
- ADC Differential Pi Tutorials
- Expander Pi Tutorials
-
IO Pi Plus Tutorials
- IO Pi Plus FAQ
- IO Pi Plus Tutorial 1 - The Blinking LED
- IO Pi Plus Tutorial 2 - Push the Button
- IO Pi Plus Tutorial 3 - Introducing Interrupts
- IO Pi Plus Tutorial 4 - More Interrupts
- IO Pi Plus Tutorial - MQTT Reading the Ports
- IO Pi Plus with Raspberry Pi Pico
- IO Pi Plus Tutorial - MQTT Control
- Driving Relays or Higher Loads with the IO Pi Plus
- 16 Channel Opto-Isolated Input Board
- Relay Board for the IO Pi Plus 2.1
- IO Zero 32 Tutorials
- RTC Pi Tutorials
- Serial Pi
- Servo PWM Pi Tutorials
-
Home Assistant
- Using 1 Wire with Home Assistant and the Raspberry Pi OS
- Using I2C Devices on the Raspberry Pi with Home Assistant
- Using the ADC Differential Pi with Home Assistant on the Raspberry Pi
- Using the ADC Pi with Home Assistant on the Raspberry Pi
- Using the IO Pi Plus with Home Assistant on the Raspberry Pi
-
Legacy Products
- ADC DAC Pi (Discontinued)
- ADC Pi (Discontinued)
- Buffer Pi - Legacy Product
- Com Pi (Discontinued)
- Delta-Sigma Pi (Discontinued)
- Expander Pi (Discontinued)
- IO Pi (Discontinued)
- IO Pi Plus 1.0 (Discontinued)
- IO Pi Zero (Discontinued)
- Logic Level Converter (Discontinued)
- RTC Alarm Pi (Discontinued)
- RTC Pi (Discontinued)
- Serial Pi (Discontinued)
- 1 Wire Pi (Discontinued)
- 1 Wire Pi Plus 1.0 (Discontinued)
- Other Supported Platforms
ADC Pi Library for C++
ADC Pi C++ Library Installation and Usage
C++ Library to use with ADC Pi Raspberry Pi development board.
The example CPP files can be found in /ABElectronics_CPP_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_CPP_Libraries.git
Classes:
ADCPi(uint8_t address1, uint8_t address2, uint8_t rate)
Parameter: address1 - I2C address of ADC chip 1. 0x68 to 0x6F
Parameter: address2 - I2C address of ADC chip 2. 0x68 to 0x6F
Parameter: rate - Bit rate for ADC sampling. 12, 14, 16 or 18
Methods:
read_voltage(uint8_t channel)
Read the voltage from the selected channel.
Parameter: channel - 1 to 8
Returns: (double) number between 0 and 5.06
read_raw(uint8_t channel)
Read the raw value from the selected channel.
Parameter: channel - 1 to 8
Returns: (uint32_t) raw number
set_pga(uint8_t gain)
Set the gain of the PGA on the chip.
Parameter: gain - 1, 2, 4, 8
Returns: null
set_bit_rate(uint8_t rate)
Set the sample bit rate of the ADC.
Parameter: rate - 12, 14, 16, 18
12 = 12 bit (240SPS max)
14 = 14 bit (60SPS max)
16 = 16 bit (15SPS max)
18 = 18 bit (3.75SPS max)
Returns: null
set_conversion_mode(uint8_t mode)
Set the conversion mode for the ADC.
Parameter: mode - 0 = One-shot conversion, 1 = Continuous conversion
Returns: null