I have the following python script which I am using to configure an ADC chip via I2C:
#import ctypes
import pylibi2c
print("Initialising 60202C01 Audio ADC Board")
#Open i2c device @/dev/i2c-0, addr 0x50.
i2c = pylibi2c.I2CDevice('/dev/i2c-0', 0x4C)
# Set delay
i2c.delay = 10
# Set page_bytes
i2c.page_bytes = 8
# Set flags
i2c.flags = pylibi2c.I2C_M_IGNORE_NAK
print(i2c)
# From i2c 0x0(internal address) read 256 bytes data, using ioctl_read.
data = i2c.ioctl_read(0x00, 1)
# Write data to i2c, buf must be read-only type
size = i2c.write(0x01, b'\x98') #Global Mode Control
size = i2c.write(0x03, b'\xFF') #Overflow Mask
size = i2c.write(0x04, b'\x00') #High pass filters enabled
size = i2c.write(0x06, b'\x00') #Everything powered up
size = i2c.write(0x08, b'\x00') #No channels muted
size = i2c.write(0x0A, b'\x0E') #SDOUT1 Enabled
print("ADC Initialiation complete")
This was confirmed working, however since recently rebuilding and flashing the OS I now get an error when I try to run this script:
mantis@mantis-desktop:~/Desktop$ python3 CS5368_Init.py
Initialising 60202C01 Audio ADC Board
Traceback (most recent call last):
File "CS5368_Init.py", line 7, in <module>
i2c = pylibi2c.I2CDevice('/dev/i2c-0', 0x4C)
PermissionError: [Errno 13] Permission denied
It works OK if I use SUDO, but would prefer not to use this. Could you please explain how I can set up the permissions to allow this script to run without super-user permissions?