I2C OSError 5

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
pythoncontroller
Posts: 3
Joined: Tue Nov 25, 2014 9:02 pm

I2C OSError 5

Post by pythoncontroller » Mon Feb 23, 2015 10:07 pm

I have been trying to use the touch sensor on the LCD module and have been running into issues with OSError 5. Just following the tutorial brings this error:

Code: Select all

Micro Python v1.3.8 on 2014-12-29; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import pyb
>>> import mpr121
>>> m = mpr121.MPR121(pyb.I2C(2, pyb.I2C.MASTER))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/flash/lib/mpr121.py", line 21, in __init__
  File "/flash/lib/mpr121.py", line 25, in enable_elec
OSError: 5
What is causing this error? I have searched for it, but other references seem to result from far more complicated commands. Could it be a soldering problem? (The skin is in the y position, that is why it is "...pyb.I2C(2,..." and not "...pyb.I2C(1,...")
Thanks in advance!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C OSError 5

Post by dhylands » Tue Feb 24, 2015 1:56 am

5 corresponds to EIO which originate in the stmhal HAL as HAL_ERROR.
https://github.com/micropython/micropyt ... phal.c#L12

Probably the most common reason is that the i2c device isn't responding.

So soldering could be a problem. Does anything show up if you do an i2c.scan() ?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C OSError 5

Post by dhylands » Tue Feb 24, 2015 5:17 am

With the LCD board plugged into the Y position like this:
https://www.dropbox.com/s/itq7y3jjm65ov ... 2.jpg?dl=0
https://www.dropbox.com/s/s5si6rkjbgne0 ... e.jpg?dl=0
https://www.dropbox.com/s/5uxmxg7l58oy5 ... 9.jpg?dl=0

I tried this code:

Code: Select all

import pyb
import mpr121
m = mpr121.MPR121(pyb.I2C(2, pyb.I2C.MASTER))
for i in range(100):
   print(m.touch_status())
   pyb.delay(100)
and it seemed to work fine. Also doing an i2c.scan:

Code: Select all

>>> i2c = pyb.I2C(2, pyb.I2C.MASTER)
>>> i2c.scan()
[90]

Post Reply