1

Im currently trying to set up an ADC (ADS1115) and trying to test it so everything works. Ive used a code from github (link provided at the end) and watched several youtube videos about how to set it up. No matter how I do i either get: "ModuleNotFoundError No module named 'board', then I tried to install the module and get: AttributeError: Module 'board' has no attribute 'SCL'. I provide a picture of the code. At this moment, I have no clue on how to get it fixed... Seems to work when you watch youtube tutorials about it, but not when im trying to implement it. I´ve also tried using the full code, but get the same attribute error.

github link: https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/blob/main/examples/ads1x15_simpletest.py

import time
import board
import busio
import adafruit_ads1x15.ads1015 as ADS
from adafruit.ads1x15.analog_in import AnalogIn

i2c = busio.I2C(board.SCL, board.SDA)
ads = ADS.ADS1015(i2c)
chan = AnalogIn(ads, ADS.P0)

while True:
     print(chan.voltage)
4
  • Which rpi are you doing this on? Which OS is it running
    – Bravo
    Dec 11, 2021 at 2:05
  • Are you running CircuitPython on the Pi? It appears that the library is for CircuitPython rather than standard Python. Dec 11, 2021 at 12:36
  • @Bravo Rasperry Pi 4, model B, Raspbian GNU/Linux 11 (Bullseye)
    – Konrado
    Dec 11, 2021 at 12:44
  • @ElliotAlderson I have installed it according to the adafruit instructions (link below) but when im running the example script it does not work and I get the same AttributeError on D4. learn.adafruit.com/circuitpython-on-raspberrypi-linux/…
    – Konrado
    Dec 11, 2021 at 13:06

2 Answers 2

0

I have written an example for my lg library.

There are examples for C and Python (local and remote).

Python local example

0

I am using a Pi 4 with Raspian (most current version as of 01/2023) and have followed this official guide from Adafruit: https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/python-circuitpython , having it to work perfectly.

Following the guide you will notice that you will have to install CircuitPython and Blinka. All that will only work with Python 3, so be sure to have it as the default python on your machine.

Also, make sure you have your system updated with How do I upgrade Raspbian?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.