# Write more Variables in S7 PLC with S7comm

**URL:** <https://discourse.nodered.org/t/write-more-variables-in-s7-plc-with-s7comm/11665>\
**Category:** General\
**Created:** [29 May 2019 09:31 UTC](https://discourse.nodered.org/t/write-more-variables-in-s7-plc-with-s7comm/11665 "2019-05-29T09:31:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Schnatter](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Schnatter](https://discourse.nodered.org/u/Schnatter)\
**Post date:** [29 May 2019 09:31 UTC](https://discourse.nodered.org/t/write-more-variables-in-s7-plc-with-s7comm/11665/1 "2019-05-29T09:31:07Z")

</div>

Hello,

in my project I want to write Data from a MSSQL Database in one DB of S7-PLC.  
Can I write all 11 Arrays of Data in the DB in one turn, or only one?

 ![project](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6ea3669e3e63de5e4ec21c0a953c3b2a7d83bbcd.png) ![Configuration%20S7comm](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b81336a3bc9e3e429a69c830482ac2371ccc31dd.png)  
How can I Adress all Variables at once?  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Schnatter](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Schnatter](https://discourse.nodered.org/u/Schnatter)\
**Post date:** [29 May 2019 09:32 UTC](https://discourse.nodered.org/t/write-more-variables-in-s7-plc-with-s7comm/11665/2 "2019-05-29T09:32:03Z")

</div>

Or is it better to use the S7-knode?

---

<div class="post-metadata">

**Author:** ![gfcittolin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gfcittolin/32/23354_2.png) [@gfcittolin](https://discourse.nodered.org/u/gfcittolin)\
**Post date:** [4 June 2019 13:36 UTC](https://discourse.nodered.org/t/write-more-variables-in-s7-plc-with-s7comm/11665/3 "2019-06-04T13:36:12Z")

</div>

I don't know about the `node-red-contrib-s7comm`, but with `node-red-contrib-s7` you can use the `s7 out` node and send an array of values to be written on `msg.payload`, with the names of the variables being an array of their names on `msg.variables`.

Here's a sample flow as an example

```json
[{"id":"4dd0a4a3.141a9c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d0365f50.6cdef","type":"s7 out","z":"4dd0a4a3.141a9c","endpoint":"f93ce6f4.8dccc8","variable":"","name":"","x":700,"y":360,"wires":[]},{"id":"146aaa14.0e6926","type":"s7 in","z":"4dd0a4a3.141a9c","endpoint":"f93ce6f4.8dccc8","mode":"all","variable":"","diff":true,"name":"","x":240,"y":100,"wires":[["916db5ae.0434c8"]]},{"id":"916db5ae.0434c8","type":"debug","z":"4dd0a4a3.141a9c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":670,"y":100,"wires":[]},{"id":"2bd16383.d74d9c","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"B0","payload":"10","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":240,"wires":[["43867ead.fea44"]]},{"id":"addcbd04.431fb","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"B0","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":200,"wires":[["43867ead.fea44"]]},{"id":"6f576722.7ac128","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"B1","payload":"15","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":320,"wires":[["43867ead.fea44"]]},{"id":"1ef8cc84.dca1e3","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"B1","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":280,"wires":[["43867ead.fea44"]]},{"id":"43867ead.fea44","type":"change","z":"4dd0a4a3.141a9c","name":"","rules":[{"t":"set","p":"variable","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":260,"wires":[["d0365f50.6cdef"]]},{"id":"43dd1926.af3a18","type":"change","z":"4dd0a4a3.141a9c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[payload, payload, payload, payload]","tot":"jsonata"},{"t":"set","p":"variable","pt":"msg","to":"[\"B0\", \"B1\", \"B2\", \"B3\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":460,"wires":[["d0365f50.6cdef"]]},{"id":"c9136c43.260c2","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":420,"wires":[["43dd1926.af3a18"]]},{"id":"7fb7169c.d904b8","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":460,"wires":[["43dd1926.af3a18"]]},{"id":"7d76a8c3.d9ab88","type":"inject","z":"4dd0a4a3.141a9c","name":"","topic":"","payload":"4","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":500,"wires":[["43dd1926.af3a18"]]},{"id":"f93ce6f4.8dccc8","type":"s7 endpoint","z":"","address":"192.168.15.211","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","cycletime":"500","timeout":"1500","verbose":"default","name":"TestPLC","vartable":[{"addr":"DB2,B0","name":"B0"},{"addr":"DB2,B1","name":"B1"},{"addr":"DB2,B2","name":"B2"},{"addr":"DB2,B3","name":"B3"}]}]

```
