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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Thingworx connecting to Raspberry Pi

gabitudor
10-Marble

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?

 

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

4 REPLIES 4

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

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

does anybody know how to make this work please?

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.

Announcements


Top Tags