0

I am trying to connect a particle sensor to RPi via I2C.

I have added dtparam=i2c_arm=on to the config.txt file and I have also un-blacklisted I2C.

Using the Serial Python module, I have a script that defines a connection with /dev/i2c-0 and when I try and run this script in the Linux terminal, I get this message:

Traceback (most recent call last):
  File "fly_modt.py", line 23, in <module>
    ser2 = serial.Serial('/dev/i2c-0')
  File "/home/pi/OPC/serial/serialutil.py", line 282, in __init__
    self.open()
  File "/home/pi/OPC/serial/serialposix.py", line 296, in open
    self._reconfigurePort()
  File "/home/pi/OPC/serial/serialposix.py", line 325, in _reconfigurePort
    raise SerialException("Could not configure port: %s" % msg)
serial.serialutil.SerialException: Could not configure port: (25, 'Inappropriate ioctl for device')

I am wondering what is going on and what I need to do in order to get this I2C connection to work.

Also, to add more information to the question, when I use the cat command for i2c-0, I get an Input/ouput error:

cat i2c-0
cat: i2c-0: Input/output error

Thanks

0

The script is trying to manipulate /dev/i2c-0 (an I2C bus) as if it is a serial link. An I2C bus is not a serial link.

To talk to as I2C bus use the Python SMBus module (or my pigpio's inbuilt I2C support).

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.