RuntimeError :could not determine I2C bus for platform

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
Abdellah_eddiraa
 
Posts: 1
Joined: Thu Jun 09, 2022 9:08 pm

RuntimeError :could not determine I2C bus for platform

Post by Abdellah_eddiraa »

I’m trying to realize an oscilloscope with raspberry pi4 and an ads1115 but i get this error after running my code any tips please
Here’s the code :
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import Adafruit_ADS1x15
# Create an ADS1115 ADC (16-bit) instance.
adc = Adafruit_ADS1x15.ADS1115()
GAIN = 1
val = [ ]
# Start continuous ADC conversions on channel 0 using the previous gain value.
adc.start_adc(0, gain=GAIN)
print('Reading ADS1x15 channel 0')
fig, ax = plt.subplots()
ax.set_ylim(-5000,5000)
ax.set_title('Oscilloscope')
ax.grid(True)
ax.set_ylabel('ADC outputs')
line, = ax.plot([], 'ro-', label='Channel 0')
ax.legend(loc='lower right')
def update(cnt):
# Read the last ADC conversion value and print it out.
value = adc.get_last_result()
print('Channel 0: {0}'.format(value))
# Set new data to line
line.set_data(list(range(len(val))), val)
ax.relim()
ax.autoscale_view()
#Store values for later
val.append(int(value))
if(cnt>50):
val.pop(0)
ani = FuncAnimation(fig, update, interval=500)
plt.show()

And this is the link of the full project :
https://doc-14-c8-docs.googleuserconten ... 92gpfu35rp
Attachments
E3A3E080-E9FD-4FBD-80BA-AB2042576200.jpeg
E3A3E080-E9FD-4FBD-80BA-AB2042576200.jpeg (170.72 KiB) Viewed 107 times

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: RuntimeError :could not determine I2C bus for platform

Post by adafruit_support_mike »

What version of Raspbian are you using?

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”