Skip to content

Analog to Digital

Jhkier edited this page Sep 2, 2021 · 10 revisions

This example will explain the wiring https://www.instructables.com/PCF8591-i2c-Analog-IO-Expander-Fast-Easy-Usage/

Make sure that you use pins for all power/ground and not just those to power the device or the pin used.

STEP:

  • sudo i2cdetect -l #list all i2c
  • sudo i2cdetect 0 #list channels/devices on i2c input/bus 0
  • sudo i2cget -y 0 0x48 #shows all pins active on input 0 and device 0x48
  • sudo i2cset -y 0 0x48 0x02 # this will change it to be focused on pin 2 rather than pin 0 by default

sudo i2cdetect -l #this will tell you which channels on the pi are active (sca_0 or sca_1) sudo i2cdetect 0 # will read which adc devices are acctive on channel 0

sudo i2cdetect -l #this will tell you which channels on the pi are active (sca_0 or sca_1) sudo i2cdetect 0 # will read which adc devices are acctive on channel 0

  •  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    
  • 00: -- -- -- -- -- -- -- -- -- -- -- -- --
  • 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • 40: -- -- -- -- -- -- -- -- 48 49 -- -- -- -- -- -- #this will show that there is an ADC device PCF8591T is attached
  • 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  • 70: -- -- -- -- -- -- -- --

After considerable effort, I've moved to ADS1015 Analog reader as it appears more accurate and encounters much less error.... The problem with ADS1015 is that the pythoncity library is much more complex and comprehensive.

Explaination on i2c:

Additional resources:

Clone this wiki locally