0

I defined two GPIO pins as SCL and SDA for another I2C, (e.g., i2c3 on busnum=3). ADS1115 was successfully detected by runing (sudo i2cdetect -y 3). enter image description here Also, the modified simplest.py (where Adafruit_ADS1x15.ADS115 (address=0x48, busnum=3)) is able to give readings from P0 using sudo python simplest.py enter image description here.

However, the problem is the same simplest.py cannot work in Thonny, saying " import Adafruit_ADS1x15 ImportError: No module named 'Adafruit_ADS1x15'".

I have no idea of where the problem is and how to fix it.

  • 2
    You should post text, not pictures of text. – RalfFriedl Apr 16 at 5:05
  • You are being told Thonny can not find the module. I expect there will be a setting somewhere to tell Thonny the location of library modules. – joan Apr 16 at 7:24
  • I might have misunderstood something. Do you mean you can run the AdaFruit python program in IDLE, but not in Throny? Then it is the Throny problem. – tlfong01 Apr 16 at 7:43
1

sudo python simplest.py

Here you are using Python 2. Thonny uses Python 3. Probably you have Adafruit_ADS1x15 installed for Python 2 but not for Python 3.

0

Yes, the AdaFruit ADS1015 python import problem is 3 years old. You might need to try (at your own risk!) the get around program in their GitHub. They might be using v2.6 and old version of Raspbian.

The bad thing is that AdaFruit no longer supports Python. They have switched to CircuitPython which is not 100% compatible to Rpi. One way is look at their CircuitPython ADS1115 library and modify it to suit Rpi.

adafruit/Adafruit_Python_ADS1x15 setup.py -Fix python3 pip install ez_setup import issue - 2016

I have tested ADS1015 using RpiB+ and written a little program to read the register "Who am I".

Perhaps I can show you my setup and my little test program here.

I am testing 4 ADS1015 at the same time, so I need to remove all the I2C pull ups in the modules, otherwise the Rpi I2C circuit will be overloaded and cannot detect the modules.

ads1015 remove pullup

Then I use i2cdetect command to detect the modules.

ads1015 detect

Then I wrote a little test program to do just one simple thing - read the register "Wo am I". The full listing with sample output of the Minimal, Complete, Verifiable program is as below. You just plug and play, no libraries are required. One minor thing is that I am using Chinese Windows and there might be funny characters here and there, now and then. In case you have problems reading my file, try the PenZu backup below.

tlfong01 ads1015 test16 PenZu backup file

Good luck to your project! :)

3:16PM TUE. 4/16/2019


# ads1015_test16_2019apr1601 tlfong01 2019apr16hkt1506
# Rpi3B+ stretch linux 4.14.34-v7+ arm python 3.5.3

import smbus

i2cCh0    = smbus.SMBus(1)

def readRegOneByte(i2cCh, devAddr, regAddr):
    readByte = i2cCh.read_byte_data(devAddr, regAddr)
    return readByte

def testReadRegWhoAmI():
    print('\n*** Begin test **********************************************\n')
    devAddr = 0x48
    regAddr = 0x71
    readByte = readRegOneByte(i2cCh0, 0x48, 0x71)
    print('      devAddr    =', hex(devAddr))
    print('      regAddr    =', hex(regAddr))
    print('      regContent =', hex(readByte))
    print('\n*** End   test **********************************************')
    return

testReadRegWhoAmI()

'''
*** Sample Output tlfong01  2019apr16hkt1509 ***

>>> 
== RESTART: /home/pi/Python_Programs/test1193/ads1015_test01_2019apr1601.py ==

*** Begin test **********************************************

      devAddr    = 0x48
      regAddr    = 0x71
      regContent = 0x85

*** End   test **********************************************
>>> 
'''
# *** End ***



3:16PM TUE. 4/16/2019
  • I also tried Adafruit_CircuitPython_ADS1x15, but do not know how to customize the code (github.com/adafruit/Adafruit_CircuitPython_ADS1x15) when creating the I2C bus, i2c = busio.I2C(board.SCL, board.SDA), or creating the ADC object using the I2C bus, to get readings from the designated i2c3 or 0x48 busnum=3? – TAO Apr 16 at 14:26
  • Ah, I think you need to first run the circuitPython version, eg US$9 Trinket M0. If everything goes well, then you study the code and see what is need to convert to make it Rpi compatible. I once tried PyBoard and BBC Micro with MicroPython, which is similar to Circuit Python. But I found MicroPython very weak, small memory, slow REPL MU, no interrupts. In other words, as weak as Arduino. If your project is small, you might like to switch to M0 hardware (which I tried and found it very very small, even smaller than Arduino). Or plan to spend more time studying Rpi. – tlfong01 Apr 16 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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