osmc@osmc:~/sensehat$ python temp.py
Traceback (most recent call last):
File "temp.py", line 2, in <module>
sense = SenseHat()
File "/usr/lib/python2.7/dist-packages/sense_hat/sense_hat.py", line 42, in __init__
raise OSError('Cannot access I2C. Please ensure I2C is enabled in raspi-config')
OSError: Cannot access I2C. Please ensure I2C is enabled in raspi-config
Where line 42 looks like this:
if not glob.glob('/dev/i2c*'):
raise OSError('Cannot access I2C. Please ensure I2C is enabled in raspi-config')
osmc@osmc:~$ python sensehat/temp.py
Traceback (most recent call last):
File "sensehat/temp.py", line 2, in <module>
sense = SenseHat()
File "/usr/lib/python2.7/dist-packages/sense_hat/sense_hat.py", line 42, in __init__
raise OSError('Cannot access I2C. Please ensure I2C is enabled in raspi-config')
OSError: Cannot access I2C. Please ensure I2C is enabled in raspi-config
osmc@osmc:~$ grab-logs -A
Logs successfully uploaded.
Logs available at https://paste.osmc.tv/atowuzevul
With a Device Tree, the kernel will automatically search for and load modules that support the indicated enabled devices. As a result, by creating an appropriate DT overlay for a device you save users of the device from having to edit /etc/modules; all of the configuration goes in config.txt, and in the case of a HAT, even that step is unnecessary. Note, however, that layered modules such as i2c-dev still need to be loaded explicitly.
So add the line i2c-dev to file /etc/modules and reboot.