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

Thingworx connecting to Raspberry Pi

SOLVED
Highlighted
Regular Member

Thingworx connecting to Raspberry Pi

Hello,

 

i am trying to get the data from my PIR motion sensor to the remote PiThing i created in the Quickstart guide.

i added this code in the PiTemplate.lua

 

properties.PIR = { baseType="NUMBER", pushType="ALWAYS", value=0 }
local sensorCmd = io.popen("python etc/custom/templates/11.py")
s = sensorCmd:read("*a") properties.PIR.value = s

 

and i tried with 2 types (with and without a loop) of python code (the code works fine if i am trying it from terminal only in the raspberry Pi, does not work in TW) that i attached.

 

the other sensors as in the guide work just fine, only with this one i am not getting any data, event though the remote thing sees it as a property

 

can anyone please help?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Thingworx connecting to Raspberry Pi

Managed to solve this. Apparently i was not sending anything to Lua because my Python script was composed of a void function that did not have a return statement. so i made a function that returns true when the movement is made.

4 REPLIES 4

Re: Thingworx connecting to Raspberry Pi

What is the value 's' after you read it in? Are you seeing any errors? I would also try using a property with a STRING type since you may be getting a null character, or carriage return, or EOF put into that variable

Re: Thingworx connecting to Raspberry Pi

thanks for the replay! i set the type as string but did not see any difference. no, i do not see errors and looks like 's' is having 0 as value, it sends 0 to Thingworx

Re: Thingworx connecting to Raspberry Pi

does anybody know how to make this work please?

Re: Thingworx connecting to Raspberry Pi

Managed to solve this. Apparently i was not sending anything to Lua because my Python script was composed of a void function that did not have a return statement. so i made a function that returns true when the movement is made.