Raspberry Pi to Tag, Best Option

I have a Raspberry Pi running NUT (network ups tools) to monitor some UPSs that power more RPis that run Ignition clients. Blackouts are not healthy for RPi, so I the goal is to shutdown the Pis when the UPS goes from line power to battery power. I have NUT sending out emails when the power source changes, and it also writes the message to a txt file. I would like this message as an Ignition tag. What is the best way to do this? I tried MQTT but it doesn’t work yet, plus the Cirrus-Link modules are $$$. My next thought was to have Ignition read the txt file periodically and write the contents to a tag. Is this a good way to expose the info as a tag, or is there a better method?

I would use a POST to the WebDev module to deliver to Ignition memory tag(s).

1 Like

Why not use TCP driver and just connect to IP of RPI?

Then write bash or .py to send message at interval over port. Using telnet or something?

I’ve had bad luck with using TCP, mainly because I don’t know much about how to use it.

I am using it to talk to weigh scales, BCScanners and several arm controllers running different distros. I’ve had much luck with IA TCP driver used in this fashion.

Depending on what you’re doing and how you’re publishing the data in the sensor program. You could write a service in like a couple of mins to do what you want. I started here – https://www.pubnub.com/blog/socket-programming-in-python-client-server-p2p/

Good Luck!

The only thing that makes me hesitant of that is python sockets. I’ve heard about python sockets being slow and causing memory problems in Ignition. I believe @pturmel makes the suggestion to use Java sockets instead. I know even less about Java sockets, Java in general, as a matter of fact.

Right now, I have a Pi listening to a UPS locally, then I have an Ansible server (with NUT) as a client to that Pi. It sends out emails when it goes on battery power, etc. When the battery is at 50%, I have NUT call an Ansible playbook to shutdown all of my RPis that are running Ignition Clients. This should prevent blackouts of my Pis. It would be nice to get the UPS events in Ignition in case that I want to send out a warning message to anyone using the Ignition Client that it will be shutting down soon.

I’ll post what I come up with

Well, I would usually heed what he says. But, I’d imagine he’s talking about the J implementation and not the C one that’d you’d be messing with on the Pi. Maybe the J isn’t thread-safe. Good luck anyhow!

I’d use the java socket on the ignition side, within jython, and the python socket on the Pi side. Either way, one side is gonna listen, the other will ask for or push status regularly.

I will return to this and try sockets at some point, but I need something a little simpler for right now. My NUT server is writing the ups status to a file on the Pi side. From the Pi side, I’ve shared the folder. The file is on the Ignition gateway and I can open and view it manually from the desktop. I want to see if I can read the file from Ignition. IE

path = '\\Z:\upsLogs.txt'
contents = system.file.readFileAsString(path)
print contents

It errors out citing that the file does not exist. Do I have to setup a shared network drive in the Ignition.conf file for it to read this file even though it is accessible on the gateway? Or am I screwing up the file path? I mapped the Z: on windows to \\RPi_IP_ADDRESS\upsTagInfo


path = '\\\\Z:\\upsLogs.txt'

Also, there is a section in the manual dedicated to mapping drives.

In short you may need to add them to the ignition.conf, especially if the remote PC (pi) is not on the domain

The path you suggested did not work. I’m working on the network mapping, but I’m not sure of these lines:


The ones below these are the credentials for the shared folder, but I’m sure what these credentials are for?
PS: I like your logo, that’s neat

So, if you were browsing to the folder using Windows File Explorer, and it asks you for credentials, these are the same credentials you would save in the conf

If there are none requested, put in the credentials that the SCADA service runs under

p.s. thanks! if you look close, or watch the jingle at the start of my videos, it spells Matrix Engineering from the 3x3 Matrix logo (https://youtu.be/RDcFgat6_sc)… the animation overlay was done in… Ignition!