Skip to main content
1-Visitor
March 28, 2019
Solved

Raspberry Pi EMS Value Stream

  • March 28, 2019
  • 1 reply
  • 5689 views

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

 

 

Best answer by jsaynava

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.

1 reply

14-Alexandrite
March 29, 2019

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

jsaynava1-VisitorAuthor
1-Visitor
March 29, 2019

Hi,

 

attached you can find logs for both.

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

14-Alexandrite
March 29, 2019

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?