Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will this work for MCP23008 #6

Open
ilium007 opened this issue Feb 28, 2021 · 8 comments
Open

Will this work for MCP23008 #6

ilium007 opened this issue Feb 28, 2021 · 8 comments

Comments

@ilium007
Copy link

ilium007 commented Feb 28, 2021

Unfortunately doesn't seem to work for MCP23008. Was able to create the mcp object but can't configure a pin for input or output.

@ilium007 ilium007 reopened this Mar 1, 2021
@ilium007
Copy link
Author

ilium007 commented Mar 1, 2021

>>> mcp = mcp23017.MCP23017(i2c, 0x20)
>>> i2c
I2C(1, scl=B6, sda=B7, freq=420000)
>>> mcp
<MCP23017 object at 2000bcf0>
>>> mcp.pin(1, mode=1, pullup=True)
False
>>>

@mcauser
Copy link
Owner

mcauser commented Jul 29, 2022

MCP23008 is a single 8-bit port variant of the MCP23017.
While one would expect it to behave similar, if not the same, there's a bunch of code in the library expects to two ports.

I don't have any MCP23008 chips/modules to test with, but I could fork this and rip out all of the 2nd port code if you're able to test it and confirm it all works. Sorry I missed this issue earlier. It's been a while. Are you still interested in the MCP23008?

@plmetz
Copy link

plmetz commented Dec 5, 2022

@mcauser I recently started a project with both a MCP23008 and a MCP23017. I was looking for a library for the MCP23008 but there's not much out there. I'd be very interested in helping you test this if you made a port for the MCP23008.

@mcauser
Copy link
Owner

mcauser commented Dec 5, 2022

Hi @plmetz , See https://github.com/mcauser/micropython-mcp23008
It's a fork of the current library with all of the PortB code removed.

I haven't tested it on any hardware yet, or written up any documentation.
It should work. If you're able to do some testing, that would be awesome!
Refer to the readme of this library for examples how to use it, with only the first 8 bits/pins available.

import mcp23008
mcp = mcp23008.MCP23008(i2c, 0x20)

List interface

mcp[0].value()
...
mcp[7].value()

Method interface

mcp.pin(0)
...
mcp.pin(7)

Property interface

mcp.mode = 0xfe
mcp.gpio = 0x01

@plmetz
Copy link

plmetz commented Dec 7, 2022

Thanks for pulling that library together. It works wonderfully, as far as I can tell. I am a hobbyist just getting started with electronics and python, so by no means an expert, but I did some testing, and on the MCP23008, I was able to:

  • confirm proper input and output functioning of the pins
  • access pins through the list interface and the method interface
  • set and read properties
  • set and use an interrupt

If there is any other specific testing that you think would be warranted I'd be happy to try.

What is your plan with the MCP23008 library? Leave it as a standalone or would you integrate it into this library? Or a "MCP230x" library?

@mcauser
Copy link
Owner

mcauser commented Dec 7, 2022

Hey, there's not a huge difference between them and the MCP23017 was well tested, so it should be good to go.
I'll add documentation and examples soon. Could use some examples/tutorials for using things like rotary encoders.

There's a lot of overlap between the two libraries, so a common MCP230x may make sense down the track.
The libraries are already quite large, so it would have to be done in a way that doesn't negatively impact each other.

I'll leave MCP23008 as is for now and add some readmes/docs to make it more complete. Then add a common ancestor to the backlog.

@plmetz
Copy link

plmetz commented Dec 8, 2022

I'm also able to submit some PRs for the documentation. As I work on my project with it I should also be able to get an example together. It's a busy time of year so might not be right away but I'd love to help.

@cpu012
Copy link

cpu012 commented Oct 4, 2023

I wrote an example for the MCP23008

mcauser/micropython-mcp23008#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants