About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Register or Sign In

Question on the read_voltage() function

496 Views - Created 25/07/2018


Posted by:

Users Avatar

Does anyone have any example C code using the 'read_voltage() function'


We want to use the ADC Pi to read a varying voltage, send it out as a serial 16/17 bit number and then store it

in the R-Pi's memory as a parallel number.

Any examples of C code to do this would be greatly appreciated.




Posted by:

Users Avatar

United Kingdom

Users Twitter  Users Website  

Hello Wayne

You can find a demo application using the read_voltage() function in our github repository at https://github.com/abelectronicsuk/ABElectronics_C_Libraries/blob/master/ADCPi/demo-adcread.c

read_voltage() takes 5 parameters:

address - I2C address for the target device e.g. 0x68
channel - 1 to 4
bitrate - 12, 14, 16 or 18
pga - 1, 2, 4 or 8
conversionmode - 0 = one shot conversion, 1 = continuous conversion

The function returns a double typed voltage from the ADC.

AB Electronics UK Tech Support

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.