cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Raspberry Pi EMS Value Stream

SOLVED
Highlighted
Regular Member

Raspberry Pi EMS Value Stream

Hello all,

 

We have established Raspberry Pi connection to Thingworx server with Edge microserver and Lua Script Resource and the property values update correctly. (https://developer.thingworx.com/resources/guides/thingworx-raspberry-pi-quickstart)

 

How can we get the values to be logged to a value stream?

Value stream is defined and connected to the PiThing. Properties from RaspberryPi are bind and marked as "persistent" and "logged" (for example cpu_temperature). Initial record to the value stream is created when LSR is started but after this no new records are added. The initial record with the original time stamp just gets a new value (eg. cpu_temperature). I am querying the value stream with "QueryPropertyHistory" service.

 

What are we missing here?

 

Any help would be appreciated.

ThingWorx 8.4.2-b2151

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Raspberry Pi EMS Value Stream

Hi,

 

The LSR does indeed send the data with the same timestamp everytime.

I digged around the lua files and modified file "/EMS/microserver/etc/thingworx/lua/utils.lua" so that it adds the os.time() instead of prop.time.  This way the timestamp updates and data gets logged to the value stream.

 

function toVariantVTQ(prop)
local t = {}
local name = prop.name or "value"
t['value'] = { baseType = prop.baseType, value = prop.value } -- variant format for JSON
-- t['time'] = prop.time or os.time() * 1000
t['time'] = os.time() * 1000 or os.time() * 1000
t['quality'] = prop.quality or "UNKNOWN"
return t
end

I'm not sure whether this is intended behaviour of the LSR or not but at least now it works.

View solution in original post

6 REPLIES 6

Re: Raspberry Pi EMS Value Stream

The steps seems to correct, so could you upload the wsems, and lua logs?

Re: Raspberry Pi EMS Value Stream

Hi,

 

attached you can find logs for both.

At the moment it is pushing only "humidity" to Thingworx.

Re: Raspberry Pi EMS Value Stream

Thank you for the logs.

You are using "EMS Version 5.4.0.114", and there is an issue about connectivity (non-SSL) between wsems and lua.

The reference article is  below.

 

EMS and LSR are unable make a connection to SSL enabled ThingWorx server using EMS 5.4.0
https://www.ptc.com/ja/support/article?n=CS281541

 

Easy way is that download WSEMS5.4.1 and later which fixed the issue.

If you still see the issue after update the wsems, could you send the config.json and config.lua?

 

Re: Raspberry Pi EMS Value Stream

Hi,

 

Using  EMS 5.4.5 did not correct the issue.

Configured the connection with SSL and self-signed certificate but the behaviour is still the same: Value stream does not get new records. Properties are available from the thing and update correctly in the "Properties and Alerts" page.

 

Attached the config files and new logs.

There are no errors after LSR is started.

 

Thank You in advance for any help.

Re: Raspberry Pi EMS Value Stream

I checked logs and config, and it looks like no problem.

I did quick test and saw the same phenomenal, the value stream is not added, but value is changed.

I checked the timestamp of updated value and looked like the sample lua (PiTemplate.lua)

sent all same timestamp.

Could you check if you use "refresh" bottom of Thing property to add the value (value stream)?

 

 

 

Re: Raspberry Pi EMS Value Stream

Hi,

 

The LSR does indeed send the data with the same timestamp everytime.

I digged around the lua files and modified file "/EMS/microserver/etc/thingworx/lua/utils.lua" so that it adds the os.time() instead of prop.time.  This way the timestamp updates and data gets logged to the value stream.

 

function toVariantVTQ(prop)
local t = {}
local name = prop.name or "value"
t['value'] = { baseType = prop.baseType, value = prop.value } -- variant format for JSON
-- t['time'] = prop.time or os.time() * 1000
t['time'] = os.time() * 1000 or os.time() * 1000
t['quality'] = prop.quality or "UNKNOWN"
return t
end

I'm not sure whether this is intended behaviour of the LSR or not but at least now it works.

View solution in original post