How to RPi.GPIO library to function with Ignition Maker Edition

Hello!
First post here so feel free to give me some advice on relevant information needed…

I’m currently running Ignition Maker Edition(8.1.1) on a Rasbperry Pi 4. I have been able to setup DBs, remote connect on my network, and perform all the normal Gateway functionality! But, I’m interested in getting access and use to the GPIO, even if it was just basic Pin Control functionality. Is there a way to let Ignition inherit the usual Python library(“import RPi.GPIO as GPIO”)? Is it possible to move that library into the Ignition Gateways library? I already began trying by moving the contents of the RPi folder into Ignition pylib folder. It will try to perform the import but says that the “_GPIO” module is missing.

Anyone have feedback on this? If helpful, I can send out screenshots of what I’ve done thus far?

Much thanks!

1 Like

I got a proof of concept of integration with the DIOZero Java module working on a Raspberry Pi4B sitting on my desk; I’m running pigpiod on the Pi, and then use an introduced scripting function to create the connection:

The script running on that toggle switch is just this:

	led = system.util.globals.setdefault("LED", system.gpio.LED(system.util.globals.setdefault("factory", system.gpio.factory()), 17))
	led.on() if currentValue.value else led.off() 
2 Likes

Paul!

Your quite the genius here! Did you just get this done recently? Most resources online try to tell people to use a modbus work around, but what youve done here in the sense of a library is how i feel it should be done. Great work!

I was able to go ahead and setup the pigpio daemon on the Pi and run some simple examples to confirm the library was installed correctly, such as the following:

import pigpio
import time
pi1 = pigpio.pi()

pi1.write(20,1)
time.sleep(3)

pi1.write(20,0)
pi1.write(21,1)
time.sleep(3)
pi1.write(21,0)

Simply lighting two different LEDs on different pins…

Now, onto introducing the DIOZero resources! You called it a wrapper? I’m of course familiar with modules, which we can simply install as .modl files to the gateway. And then of course you can add drivers in jdbc folders, py scripts in the pylib, and so on. How do we handle adding these files? Manually as a module in the Ignition/data folder? Just seeking some direction as to how to get it all plugged in.

Thanks!

Interesting. Especially interesting is that the author of diozero broke out his RPi-specific GPIO driver into its own library, and with an MIT license (yay!):

That is a huge leg up for the Ignition OPC driver I'm considering, for the RPi as "remote I/O":

:smiley:

7 Likes

So I have the skeleton of a module in that Github repo, but no built .modl file (at some point I'll integrate CI with all my half-finished module projects so they at least get automatically built).
If you check out that repo, you can use the gradle wrapper to build it (./gradlew build), then install it on a gateway with the 'allow unsigned modules' flag set. Once you do that, there's a system.gpio scripting library installed, that currently only adds one function - system.gpio.factory(), which is basically a shim to DIOZero's factory method - you can pass a host and port to do a remote connection, or use no arguments to make a connection to the local pigpio daemon.
At that point, you can directly import GPIOZero's classes to abstract different GPIO devices - the library aliases LED to system.gpio.LED for ease of testing, but doesn't bring in any others.

Certainly not very 'user friendly' yet - @pturmel's efforts would likely be a lot closer to a plug and play solution.

On both parts it would be really nice to see it come full through! Just in general I feel like being able to use the RPi IO should be something straightforward to do when setting up a gateway. That being said, if something full came out I wouldn’t want it to lose its core communication functionality though, such as SPI, I2C, etc…
When I get time, I will try to build your’s and get running, for now I need some simple Discrete IO for what I’m trying to put together. Thanks!

1 Like

It is nice if you make it native to ignition as new feature.

DIZero requires either a separate running daemon or to be loaded as root. If neither of these changes it will forever be relegated to unsupported module status.

1 Like

pigpio daemon needed by the subset I called out is installed by default in Raspian, and is easily enabled in the RPi setup kit. That’s why I think it is the path to pursue. In my copious free time. /:

3 Likes

Maybe @PGriffith will turn it into a half-supported module some day :wink:

I wouldn’t want to see this as part of Ignition platform since it’s only applicable to RPi, but an RPi support module that works on Maker might be interesting, even if it’s unofficial.

edit: I realize the dio-zero library is more widely applicable and works on other boards.

4 Likes

Errrrgggh now I want to play with one of my RPi’s instead of work.

4 Likes