Cover image
Try Now
2017-09-13

MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

3 years

Works with Finder

4

Github Watches

16

Github Forks

30

Github Stars

micropython-mcp230xx

Micropython I2C-based manipulation of the MCP series GPIO expanders MCP23017 and MCP23008, derived from the Adafruit_MCP230xx.py module of https://github.com/adafruit/Adafruit_Python_GPIO

This has been tested with ESP8266 running Micropython 1.8.7 on MCP23017 only, but hopefully works also for MCP23008 if you have one. Please post an issue if you have success.

To use, wire up the GPIO expander chip following this loom...

  • MCP23017 Pins
    • 9 => 3.3V supply
    • 10 => GND
    • 12 => ESP8266 GPIO5 (NodeMCU D1) [I2C SCL Signal]
    • 13 => ESP8266 GPIO3 (NodeMCU D2) [I2C SDA Signal]
    • 12 => 10kOhm resistor => 3.3V Supply [I2C SCL Pull-up]
    • 13 => 10kOhm resistor => 3.3V Supply [I2C SDA Pull-up]
    • 18 => 10kOhm resistor => 3.3V Supply [Reset pin in 'run' configuration]

Also choose the address of each MCP23017, e.g.

  • Addressing pins for address 0x20
    • 15 => 10kOhm resistor => GND
    • 16 => 10kOhm resistor => GND
    • 17 => 10kOhm resistor => GND

The mappings between pins and I2C addresses are...

Pin pull table

If you wish to use a different I2C address, or a different GPIO-numbered SDA or SCL pin than the default then pass that in to the constructor.

The default constructor arguments mean that MCP23017() is equivalent to MPC23017(address=0x20, gpioScl=5, gpioSda=4).

A handy visual reference is this from mathworks, although I recommend that for ESP8266 the chip power should be provided by 3.3V not 5V, to make sure logic levels are correct and that the serial data line doesn't overload SDA.

MCP Pinout

For example, the following will set the output values of pins 10-15 and read the logic value (True or False) of pins 0-9

import mcp

io = mcp.MCP23017()

# controls some output pins
outPins = list(range(10,16))
nextVals = {}
for pinNum in outPins:
    io.setup(pinNum, mcp.OUT)
    nextVals[pinNum] = True
io.output_pins(nextVals)

# monitors and prints some input pins
inPins = list(range(0,10))
for pinNum in inPins:
    io.setup(pinNum, mcp.IN)
while True:
    print(io.input_pins(inPins))

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

  • 1Panel-dev
  • 💬MAXKB是一种现成的AI聊天机器人,它集成了检索功能增强的生成(RAG)管道,支持强大的工作流程并提供高级的MCP工具使用功能。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

    Reviews

    4 (1)
    Avatar
    user_9XOhAda2
    2025-04-17

    The micropython-mcp230xx by ShrimpingIt is a fantastic library for integrating MCP230xx series I/O expanders with your MicroPython projects. This well-documented and easy-to-use module opens up a new range of possibilities for adding more I/O ports to your microcontroller with minimal hassle. Highly recommended for any MicroPython enthusiast looking to extend their project capabilities efficiently! Check it out at https://github.com/ShrimpingIt/micropython-mcp230xx.