# Raspberry Pi to Tag, Best Option

**URL:** <https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822>\
**Category:** Ignition\
**Created:** [December 19, 2019, 2:16pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822 "2019-12-19T14:16:33Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 19, 2019, 2:16pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/1 "2019-12-19T14:16:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 19, 2019, 3:32pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/2 "2019-12-19T15:32:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 19, 2019, 8:10pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/3 "2019-12-19T20:10:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 19, 2019, 10:01pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/4 "2019-12-19T22:01:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 20, 2019, 6:10pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/5 "2019-12-20T18:10:41Z")

</div>

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/](https://www.pubnub.com/blog/socket-programming-in-python-client-server-p2p/)

Good Luck!

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 20, 2019, 9:30pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/6 "2019-12-20T21:30:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 20, 2019, 10:15pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/7 "2019-12-20T22:15:02Z")

</div>

> [@dkhayes117](#):
>
> I believe @pturmel makes the suggestion to use Java sockets instead.

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!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 21, 2019, 12:29am UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/8 "2019-12-21T00:29:47Z")

</div>

> [@wking](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 3, 2020, 7:49pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/10 "2020-01-03T19:49:28Z")

</div>

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

```auto
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`

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 3, 2020, 7:51pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/11 "2020-01-03T19:51:17Z")

</div>

Try

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

```

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 3, 2020, 7:53pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/12 "2020-01-03T19:53:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 3, 2020, 8:45pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/13 "2020-01-03T20:45:51Z")

</div>

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

```auto
wrapper.ntservice.account=user
wrapper.ntservice.password=password

```

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

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 3, 2020, 8:59pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/14 "2020-01-03T20:59:20Z")

</div>

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](https://youtu.be/RDcFgat6_sc))… the animation overlay was done in… Ignition!

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 3, 2020, 9:01pm UTC](https://forum.inductiveautomation.com/t/raspberry-pi-to-tag-best-option/30822/15 "2020-01-03T21:01:41Z")

</div>

> [@Gateway scoped mapped drive](http://forum.inductiveautomation.com/t/gateway-scoped-mapped-drive/20483/4):
>
> As suspected, sorting S:\ led to I:\ not recognised… however I am very pleased to report modifying the conf file worked smiley For both user and password fields in the conf file, I created a local admin login user on the remote non-domain PC. Thank you!
