- Code: Select all | TOGGLE FULL SIZE
import board
import busio
import time
import sys
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
# Setup
i2c = busio.I2C(board.SCL, board.SDA)
#ads = ADS.ADS1115(i2c)
ads = ADS.ADS1115(address=0x48, i2c=i2c)
channel = AnalogIn(ads, ADS.P0)
print(chan.value, chan.voltage)
output:
- Code: Select all | TOGGLE FULL SIZE
$ python3 ph.py
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 172, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/usr/local/lib/python3.7/dist-packages/busio.py", line 116, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 49, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 308, in write_bytes
self._device.write(buf)
OSError: [Errno 6] No such device or address
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 178, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/usr/local/lib/python3.7/dist-packages/busio.py", line 106, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 56, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 179, in read_bytes
return self._device.read(number)
OSError: [Errno 6] No such device or address
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ph.py", line 11, in <module>
ads = ADS.ADS1115(address=0x48, i2c=i2c)
File "/usr/local/lib/python3.7/dist-packages/adafruit_ads1x15/ads1x15.py", line 65, in __init__
self.i2c_device = I2CDevice(i2c, address)
File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 68, in __init__
self.__probe_for_device()
File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 180, in __probe_for_device
raise ValueError("No I2C device at address: %x" % self.device_address)
ValueError: No I2C device at address: 48
yet this is the output of sudo i2cdetect -y 1:
any ideas ?
- Code: Select all | TOGGLE FULL SIZE
$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --