# Data acquistions in synchronous way

**URL:** <https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286>\
**Category:** Industrial\
**Created:** [24 September 2020 13:26 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286 "2020-09-24T13:26:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishalk](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vishalk](https://discourse.nodered.org/u/vishalk)\
**Post date:** [24 September 2020 13:26 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/1 "2020-09-24T13:26:34Z")

</div>

Hello,

I am using Node red version v1.1.3  
I am getting resistance data from PLC and then using Node-red for acquistion and monitoring with data on grafana.  
But, all data are not synchronized.I want data to be synchronous, for every timestamp I should get data of that point.  
I will really appreciate any suggestions and idea

Vishal

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [24 September 2020 13:32 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/2 "2020-09-24T13:32:46Z")

</div>

More information would be required here for people to be able to help you. To start with...

What PLC are you using?  
How do you communicate with it?  
What messages do you get from the PLC?

---

<div class="post-metadata">

**Author:** ![vishalk](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vishalk](https://discourse.nodered.org/u/vishalk)\
**Post date:** [24 September 2020 14:00 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/3 "2020-09-24T14:00:11Z")

</div>

Hello ,

Thanks for the input mudwalker.

1.Siemens simatic PLC : CPU 1512SP-1 PN with analog card : AI 4xRTD/TC 2-,3-,4-wire HF\_1  
Siemens sinumerik controller: to get axis positions  
2. I am using Opc ua communication  
3. Iam getting array of float type values to Node-red. There I am distributing array to single float value to different Influx db node.All data get stored in Influxdb database . From Influx db database I taking these data and displaying on Grafana.  
4. Also, there are two opc ua client node in node red for different controller (simatic and sinumerik)

Vishal

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [24 September 2020 15:15 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/4 "2020-09-24T15:15:40Z")

</div>

Never worked with OPC, but I feel sure some others on here have.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 September 2020 16:10 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/5 "2020-09-24T16:10:10Z")

</div>

If you are getting all the data values at one time then the best thing is to write them all to one Measurement at the same time, then they will all have the same timestamp. If you want them to go to different Measurements then use the influxdb batch node and again you can write them all in one message so they will have the same timestamps.

---

<div class="post-metadata">

**Author:** ![vishalk](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vishalk](https://discourse.nodered.org/u/vishalk)\
**Post date:** [25 September 2020 09:51 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/6 "2020-09-25T09:51:06Z")

</div>

Hello ,

If I write all the different data to one measurement with one name, then how I will seprate them in grafana , where I am monitoring the many data?

If I use influxdb batch node , then I can see there is no option of measurement name. which measurement name I will use in grafana ?

1. influx db out: I tried connectiong trwo input wires to single influx db out with one measurement. How to seprate my measurements in grafana, I am not able to see my data in garafana.

2. influxdb batch node : when used this , I gave two input data wires to single influx db batch node . but, again I am not able to see the data in grafana. what sholld be the measurement name ?

3. can you please tell me how to see my data in influxdb database, I tried the syntax  
" SELECT \*FROM databasename LIMIT 10 ", but console shows no measurements. Even though I can see my measurement names with syntax " show field keys". I wanted to check if I am getting all data with same time stamp.

Thanks  
vishal

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 September 2020 10:23 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/7 "2020-09-25T10:23:41Z")

</div>

> [@vishalk](#):
>
> If I write all the different data to one measurement with one name, then how I will seprate them in grafana , where I am monitoring the many data?

Use one Measurement but different Fields within that measurement.

> [@vishalk](#):
>
> I use influxdb batch node , then I can see there is no option of measurement name.

The help for the node says:  
The **msg.payload** needs to be an array of _point_ objects.

The **measurement** property of a point contains the name of the measurement for the point. The **fields** property will contain the fields of the point. If supplied, the **tags** property will contain the tags for the point. To set the time for the point, supply a **timestamp** property.

However you don't need to use the batch node, see below.

Answering your numbered points:

1. You don't need to connect multiple wires. You said you start with all the values in an array, instead of splitting it up build a single message containing all the field values and pass that to the node. Again see the help text for the node:  
If **msg.payload** is an object containing multiple properties, the fields will be written to the measurement.
2. You don't need to use the batch node.
3. Do you mean using the command line influx client? If so then you first have to tell it which database to use. `use mydatabase`. Then `show measurements` will show you the measurement names, then `select * from mymeasurement` will show you the fields and tags in that measurement. In influxdb a measurement is approximately the same as a table in a normal database. `show field keys` shows you the names and types of the fields within each measurement.

---

<div class="post-metadata">

**Author:** ![vishalk](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vishalk](https://discourse.nodered.org/u/vishalk)\
**Post date:** [25 September 2020 11:50 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/8 "2020-09-25T11:50:31Z")

</div>

Hello ,

1. I am using two OPC ua read node, one gets a array of data and when I see it on grafana its almost synchronous .  
Sorry, but other OPC ua read is not getting a array but instead it getting many data of , most of them float format. I want all these float data to be synchronized.

2. I checked in influxdb database, array data are synchronized .but the different other float data for other OPCua node which are not in array are not geeting same time stamp or not synchronized.

Vishal Kaushik

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 September 2020 13:02 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/9 "2020-09-25T13:02:13Z")

</div>

In that case you need to join them together. You can probably use a Join node for this, this example from the cookbook shows how this can be done. [https://cookbook.nodered.org/basic/join-streams](https://cookbook.nodered.org/basic/join-streams)

---

<div class="post-metadata">

**Author:** ![vishalk](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vishalk](https://discourse.nodered.org/u/vishalk)\
**Post date:** [28 September 2020 07:13 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/10 "2020-09-28T07:13:12Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1aaf0c008ee914d1bd4459e4b72049329a288615.png)

I am already using function node to join all the float data.  
Infact, I am giving all the Node ID of different data (8 float and 1 integer data).  
see, the picture for refrence.  
But, I dont know if its making an array.

If I use join ,

1. What should I put in inject node msg.payload (I a using timestamp)? if I am using join, and try to join msg the, output of join is array with timestamp as payload.

2. how should i seprate msg at output of Opcua client node? Earlier I was using divide node and function node, there I was giving all node id for sepration.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 September 2020 08:52 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/11 "2020-09-28T08:52:02Z")

</div>

> [@vishalk](#):
>
> If I am using join, and try to join msg the, output of join is array

Look at the example I linked to again. If you are getting an array you have not configured it as in the example. Import the example and play with it to see how it works.

---

<div class="post-metadata">

**Author:** ![leonie2020](https://avatars.discourse-cdn.com/v4/letter/l/c67d28/32.png) [@leonie2020](https://discourse.nodered.org/u/leonie2020)\
**Post date:** [28 September 2020 09:02 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/12 "2020-09-28T09:02:38Z")

</div>

I haven't go through all the post and reply but what you have going on is similar with what i have done.  
In my project, all the data are from PLC by Modbus Tcp directly. More than 300 float points should be read from it. And all the data will be write into influxDB by every result trigger.I am not care about the timestamp because all the data are write to database at the same time.The time gap between plc reading and database insert should less than 1s.You can set the msg.payload with tag information before write the data to influxdb. For grafara, you can deal with the data by tag group later.

 ![msedge_pk3SupKgfi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea35dfd2a8ac408a4d16efb6d7bd422f1e2c2162.png) ![msedge_ySSEDe76MX](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c90c5249df0c253c650879adddea35092a01175.png)

---

<div class="post-metadata">

**Author:** ![vishalk](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vishalk](https://discourse.nodered.org/u/vishalk)\
**Post date:** [28 September 2020 11:44 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/13 "2020-09-28T11:44:14Z")

</div>

Thank you for all your replies  
now ,I run the example and I have configured exactly as in the example. After the OPCua communication by opcua client read node, I am using switch node to seprate the output with property msg.topics.  
But at output of opcua read node I am not getting payload for all the different data injected.  
I am only getting the payload of last inject node to the join node(I checked the topic with debug node, I am only getting data of the last inject node. I dont know how to split the payload at output of opcua node

Also, I am using 2 Opcua communication node,to communicate with two different server (2 siemens controller) .Both controllers are giving sending many float data. So, I have to synchronize both the opc ua data too.

Vishal

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 September 2020 13:39 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/14 "2020-09-28T13:39:23Z")

</div>

I thought the problem was that you were reading the data ok, but because it came in at different times it didn't get written to influx at the same timestamp. The suggestion was to use the Join node after the opc node in order to join all the values into one message. However, looking at the screenshot you posted you seem to be splitting the message after the opc mode, so the question is why are you doing that? Why are you not just writing it to the database at that point?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 November 2020 13:39 UTC](https://discourse.nodered.org/t/data-acquistions-in-synchronous-way/33286/15 "2020-11-27T13:39:37Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
