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?
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()
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:
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.
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!