# OPC Write values - string?

**URL:** <https://forum.inductiveautomation.com/t/opc-write-values-string/54686>\
**Category:** Ignition\
**Created:** [January 5, 2022, 4:42pm UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686 "2022-01-05T16:42:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![derick.lawrie](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@derick.lawrie](https://forum.inductiveautomation.com/u/derick.lawrie)\
**Post date:** [January 5, 2022, 4:42pm UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/1 "2022-01-05T16:42:11Z")

</div>

Hi I am investigating writing to OPC with system.opc.writeValues(opcServer, itemPaths, values) function, I have had success writing values but now I am looking at writing strings to tags and have not had much success. I am not sure if it is because of my OPC(Kepware) tag types or if this function was not meant to write strings.

any help would be appreciated!

---

<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:** [January 5, 2022, 4:47pm UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/2 "2022-01-05T16:47:11Z")

</div>

You’ll need to provide examples, and identify your Kepware version and driver. There is a great deal of variability by driver in Kepware data type support.

---

<div class="post-metadata">

**Author:** ![Noah\_St\_Mark](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@Noah\_St\_Mark](https://forum.inductiveautomation.com/u/Noah_St_Mark)\
**Post date:** [December 19, 2025, 8:55pm UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/4 "2025-12-19T20:55:34Z")

</div>

I know this is very old but I figured it out. In my case, I type casted to a byte array. Must be how the data is represented at a lower level. I am dealing with an Allen Bradley PLC.

![image](https://us1.discourse-cdn.com/inductiveautomation/optimized/3X/2/4/24f7857bbe4da530ee36c33508c2a50f43bcba71_2_690x54.png)

Here is my test script:

```python
tankSerialLength = 14

serialNumberLenTagPath = '[Line11_Charger_PLC]Incoming_Serial_AC2.LEN'
serialNumberDataTagPath = '[Line11_Charger_PLC]Incoming_Serial_AC2.DATA[0]'
testStringa = bytearray('ILOVEDONUTS123')

tagList = []

for indexes in range(tankSerialLength):
temp = '[Line11_Charger_PLC]Incoming_Serial_AC2.DATA[{}]'.format(indexes)
tagList.append(temp)

system.opc.writeValue('Ignition OPC UA Server', serialNumberLenTagPath, tankSerialLength)
test = system.opc.writeValues('Ignition OPC UA Server', tagList, testStringa)

```

---

<div class="post-metadata">

**Author:** ![Cody\_Morgan](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Cody\_Morgan](https://forum.inductiveautomation.com/u/Cody_Morgan)\
**Post date:** [December 19, 2025, 11:50pm UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/5 "2025-12-19T23:50:52Z")

</div>

Your solution is very dependent on the PLC and OPC driver that you're using. The original poster was using a Kepware server, so you were not having the same problem that he was having.

Also, don't the Allen Bradley drivers support Strings? I'm not sure why you would need to cast a byte array. ~~It's likely the driver is coercing this into a String anyway. This is just my educated guess, I am not that familiar with Allen Bradley PLCs or the drivers.~~

Edit: I didn't see that you were writing individual bytes

---

<div class="post-metadata">

**Author:** ![Noah\_St\_Mark](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@Noah\_St\_Mark](https://forum.inductiveautomation.com/u/Noah_St_Mark)\
**Post date:** [December 19, 2025, 11:57pm UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/6 "2025-12-19T23:57:43Z")

</div>

Hi Cody,

I wasn’t aware Kepware would have its own special needs. I posted the screenshot to help explain the code. To write to the strings in the PLC from ignition. I had to define the length, then send each character individually. At first I tried type casting to a list() but in the PLC I was getting some weird unwanted extra values. I had a hunch it was character encoding so I tried type casting it to a byte array and it worked.

I posted it here because it sounded like his problem was close to mine. Here is more information about my setup in case anyone else shares my issues:

Ignition Version: 8.1.35

PLC type: 1769-L24ER-QBFC1B CompactLogix 5370

PLC Firmware Version: 32.015

PLC Vendor: Allen-Bradly/Rockwell Automation

---

<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 20, 2025, 12:38am UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/7 "2025-12-20T00:38:39Z")

</div>

This complication should not be necessary. Just write the string to `[Line11_Charger_PLC]Incoming_Serial_AC2`.

---

<div class="post-metadata">

**Author:** ![Noah\_St\_Mark](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@Noah\_St\_Mark](https://forum.inductiveautomation.com/u/Noah_St_Mark)\
**Post date:** [December 20, 2025, 12:53am UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/8 "2025-12-20T00:53:38Z")

</div>

You’re absolutely right! I must have been lost in the sauce. I swear I tried this earlier and ran into casting errors but maybe I was doing something else wrong. I will remove my post LOL

---

<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 20, 2025, 12:54am UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/9 "2025-12-20T00:54:14Z")

</div>

> [@Noah\_St\_Mark](#):
>
> I will remove my post LOL

Please don't. It is instructive to future searchers.

---

<div class="post-metadata">

**Author:** ![Noah\_St\_Mark](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@Noah\_St\_Mark](https://forum.inductiveautomation.com/u/Noah_St_Mark)\
**Post date:** [December 20, 2025, 12:55am UTC](https://forum.inductiveautomation.com/t/opc-write-values-string/54686/10 "2025-12-20T00:55:22Z")

</div>

Now it’s time for me to do a refactor 🤣
