question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MCP23017 as GPIO provider example

See original GitHub issue

Hi,

First of all a big thank you for your great effort in releasing the pi4j v2 library, you did an amazing job.

I’d like to use the MCP23017 as a GPIO provider, but the codes you posted as examples are very simple and in some cases confuse me. For example: https://github.com/Pi4J/pi4j-example-minimal/blob/main/src/main/java/com/pi4j/example/MinimalExample.java

        // Here we will create I/O interfaces for a (GPIO) digital output
        // and input pin. Since no specific 'provider' is defined, Pi4J will
        // use the default `DigitalOutputProvider` for the current default platform.
        var ledConfig = DigitalOutput.newConfigBuilder(pi4j)
                .id("led")
                .name("LED Flasher")
                .address(PIN_LED)
                .shutdown(DigitalState.LOW)
                .initial(DigitalState.LOW)
                .provider("pigpio-digital-output");
        var led = pi4j.create(ledConfig);

You wrote: “Since no specific ‘provider’ is defined” but some provider is there: “.provider(“pigpio-digital-output”)”. BTW: how do I know what strings you predefined to put in the provider (e.g. to avoid the same strings in my custom implementations)?

I tried to create MCP23017 as my custom provider, but unfortunately I was not successful. The documentation is very limited and there is no complete example of how to create such a provider. Could you please help and create an example of an “advanced IO provider”?

Many thanks in advance.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:39 (28 by maintainers)

github_iconTop GitHub Comments

1reaction
savageautomatecommented, Oct 26, 2021

@taartspi

We never returned to my initial provider code and its implementation questions. I can see this thread has moved past that old discussion, which code stream do I download to participate ?

Sorry. I must have dropped the ball on that one.

Let’s work from here: https://github.com/savageautomate/pi4j-plugin-microchip and just focus on Microchip devices at this time. Feel free to create issues/questions in that repo as well.

Once we get a fully working plugin defined and work out all the configuration details we can use it as a reference to create other plugins/providers for other chipsets.

Thanks, Robert

1reaction
savageautomatecommented, Oct 26, 2021

@tatery

A few more improvements to the prototype code today. It should work for both DIGITAL INPUT and OUTPUT but only when polling input states. The code to handle MCP23017 interrupts and propagate GPIO events for inputs is not implemented yet.

@FDelporte (RE: https://github.com/Pi4J/pi4j-device-tca9548/tree/master/src/main/java/com/pi4j/devices/mcp23017) That code is not really following the “Provider” model. So I don’t think its pluggable into the Pi4J framework as a reusable GPIO digital input/output provider. If we can get https://github.com/savageautomate/pi4j-plugin-microchip fully working this could be moved under the Pi4J GitHub umbrella and serve as an example for others.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Arduino | Tutorial | MCP23017 Interfacing - YouTube
MCP23017 IC with Arduino. This enables to have more digital GPIO on Arduino or any other uc.########################Links: MCP23017 Pin ...
Read more >
Overview | Adafruit MCP23017 I2C GPIO Expander
This Adafruit MCP23017 I2C GPIO Expander Breakout has 16 GPIO with matching ground pad. We particularly like the '17 as an expander for...
Read more >
Interfacing an ESP32 to an MCP23017 GPIO expander
Before we can use the component, we have to initialize it. The API provides a function for this purpose mcp23017_err_t mcp23017_init(mcp23017_t ...
Read more >
MCP23017/MCP23S17 Data Sheet - Microchip Technology
High-Speed I2C Interface (MCP23017):. - 100 kHz ... GPIO register for data changes or for continually ... For example, if the BANK.
Read more >
Using the MCP23017 IO Expansion Board - Blynk Community
The examples were also very badly written (certainly from a Blynk ... As I said earlier, the 16 GPIO pins on the MCP23017...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found