Custom Components for Microchip MCP3424 A/D converters and MCP23017 16-bit I/O expander chips

I will be happy to tell you more about my device :slight_smile: Picture below.


I need a lot of outputs and a lot of inputs to system. I could use e.g. ā€œIO Pi Plusā€ and external realy board/ boards or a number of ā€œArduinosā€. But it would take a loooot of space. I wanted it to fit into a small Fusebox. Thatā€™s why I designed it myself.
Now STM32F1 controls all inputs and outputs directly. It can work offline without Raspberry Pi. But if I want to use Home Assistant and all cool internet features then I have Raspberry connected. Iā€™m using I2C to connect STM32 - RP3. This is where your component comes in handy. It uses I2C, creates switches and binary sensors and is easy to implement. STM32 is slave and unfortunately it can only have 2 addresses :frowning: Therefore if I create 3 or more entity in Hassio then STM no longer receives this frames. Thatā€™s why I wanted to push one extra byte before each frame sent from RP3. STM would treat it as an address and based on the rest of frame enable or disable outputs. I was wondering if I should modify your files: switch.py and binary_sensor.py or MCP23017 library itself.
If the library then I need to copy it locally and import it somehow into your component? Do you know where this library should be located so that your component can see it?

Thank you very much for your help,
Sebastian

That is a nice looking project you have going on here. The code for the Adafruitā€™s mcp23017 library is here: https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx/tree/master/adafruit_mcp230xx

Modifying that library to make it work with your project might get too complicated, is there another way to send that extra bite without hacking into the mcp23017 library? maybe, as I mentioned before, making use of the internal _write_u8() function here: https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx/blob/ecb4b4f38f01991ec29e0ab59673b19cea631957/adafruit_mcp230xx/mcp230xx.py.

What would the data received by the STM32 look like? Do you have a github repo with your code?

Jardi.

Hi,
I used your component (official from hassio) and everything worked and still working perfectly. Thank you :slight_smile: With time, however, the number of ā€œbinary sensorsā€ significantly increased. And Iā€™d rather use interrupt instead of polling. Unfortunately, the official version of your component probably doesnā€™t have this option :frowning:
On your github repo, I noticed that binary_sensor component has the ability to use any raspberry pin as an interrupt trigger. This is exactly what I dream of right now :slight_smile: But unfortunately this component gives with me errors :frowning:

err

Iā€™m sorry that Iā€™m bothering you. And thank you for all your help so far :slight_smile:

Hi,

I am sorry it took me over a month to reply to this message. I was traveling for a couple of weeks and then I didnā€™t see your message until now. It looks like you downloaded the component after I merged a PR that StephenBeirlaen contributed to it in that repository, his code improves the interrupt handling but It changes the structure of the binary_sensor in the configuration yaml. I have to apologize because I forgot to update the README file, I updated it just now with the right structure, give it a try and let me know if it works well for you, the configuration.yaml should look like this:

binary_sensor:
  - platform: mcp23017
    pull_mode: UP
    invert_logic: true
    interrupt_port: 12
    chips:
      - i2c_address: 0x20
        pins:
          8: pin8
          9: pin9
          10: pin10
          11: pin11
          12: pin12
          13: pin13
          14: pin14
          15: pin15
      - i2c_address: 0x24
        pins:
          8: prototypepcbpin8

@sokolsok,

I see its al sort off old postā€¦

I am trying the same. I have a board with 2 MCPā€™s on it and ended up with some of the same sort errors and am playing arond with the versions in de manifest.json to be the latest. I only see the warning about using the custom component. U am using the latest version and config from github.

i am new to HA, could you expalin how to see the other errors (i am using Hassio as os)
as i dont see the binary_senors related to the mcp23017 in my device-list, i therefor asume the component is not working.

Kind regards,

Peter