{"id":528,"date":"2022-01-14T16:21:53","date_gmt":"2022-01-14T16:21:53","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=528"},"modified":"2022-04-11T20:22:59","modified_gmt":"2022-04-11T20:22:59","slug":"converting-analog-to-digital-using-the-adafruit-ads1015-breakout","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/electronics\/converting-analog-to-digital-using-the-adafruit-ads1015-breakout\/","title":{"rendered":"Converting analog to digital using the Adafruit ADS1015 breakout"},"content":{"rendered":"\n
Image by Adafruit<\/a><\/p>\n\n\n\n The ADS1015 can convert up to 4 analog signals to 12bit digital precision. The Raspberry Pi doesn\u2019t have a built in ADC and thus a module like this comes in very handy.<\/p>\n I will be following\u00a0Adafruit\u2019s guide<\/a>\u00a0on how to use the ADS1015 breakout board.<\/p>\n I will be using the ADS1015 in a project and not on a breadboard, thus I will be soldering the headers to point out to the top (like a Raspberry Pi\u2019s GPIO).<\/p>\n I placed the headers inside of a breadboard with the longer leads going into the breadboard.<\/p>\n Then placed the ADS1015 on top of the headers and soldered them in place.<\/p>\n <\/p>\n To do the initial testing of the module I will be using a simple voltage divider that runs of the 3.3V line of the Adafruit MCP2221A.<\/p>\n I have covered how I use the very handy little Adafruit MCP2221A before on this post<\/a> and will be using this module again for communicating to the ADS1015 using I2C.<\/p>\n <\/p>\n Before moving onto installing the software and testing the ADS1015 I decided to dial in the divider to read +\/- 1V at the point where I will be hooking up the A0 port.<\/p>\n NOTE: I tried powering the ADS1015 via the 5V line from the MCP2221A but then Blinka couldn\u2019t detect the MCP2221A module. Connecting it to the 3.3V line seems to solve the issue.<\/p>\n Please see\u00a0my post about the Adafruit MCP2221A breakout<\/a>\u00a0for how I setup Python projects like these on my Mac.<\/p>\n My git repo for this module can be\u00a0found here<\/a>.<\/p>\n <\/p>\nOverview<\/h2>\n
Soldering on the headers<\/h2>\n
Building a simple voltage divider<\/h2>\n
Setting up the software<\/h2>\n
\n
$ .\/new-project.sh\n\n# I then copied the requirements.txt from my mcp2221a directory\n$ .\/install-requirements.sh\n<\/code><\/pre>\n
\n
\n
# Active the venv and export the required environment variable for Blinka\n$ source source.sh\n(venv)$ cd examples\n(venv)$ python3 i2c-scan.py\n\nI2C addresses found: ['0x48']\n<\/code><\/pre>\n
\n
(venv)$ pip3 install adafruit-circuitpython-ads1x15\n(venv)$ .\/update-requirements.sh\n<\/code><\/pre>\n
\n
(venv)$ python\n>>> import adafruit_ads1x15.ads1015 as ADS\n>>> from adafruit_ads1x15.analog_in import AnalogIn\n<\/code><\/pre>\n
\n
NotImplementedError: ('Microcontroller not supported:', 'MCP2221')\n<\/code><\/pre>\n
\n
Converting analog signal to digital value<\/h2>\n
\n