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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Connecting DS18B20 to Thingworx

festes
1-Visitor

Connecting DS18B20 to Thingworx

I have modified 'AdafruitDHT.py' script from the tutorial to connect AM2302 sensor to thingworx, and used it to bind DS18B20 sensor.

Following is the script I have used to replace existing file in line 57 of 'TempAndHumidityThing':

import w1thermsensor

sensor = w1thermsensor.DS18B20

pin = '4'

temperature = w1thermsensor.read_retry(sensor, pin)

if temperature is not None:

print('Temp={0:0.1f}*C'.format(temperature))


    sys.exit(1)

It gives 'command not found' error

Can anyone please help?

5 REPLIES 5
supandey
19-Tanzanite
(To:festes)

Hi Fred, not sure if this is the complete script, but it seems to be missing shebang something like this #!/usr/bin/env python or #!/usr/bin/env python3 . This goes at the very top of the file containing your python script.

You'll need this while executing the script from a shell to specify Python interpreter to be used

festes
1-Visitor
(To:supandey)

Sushant, I have added shebang, but it is still giving the same error. Is there anything else that I'm missing?

supandey
19-Tanzanite
(To:festes)

Could you also share which python version and on which OS are you attempting to execute this script? And also how are you executing it? Something  like ./<pythonFileName>.py

is the environment variable correctly set for python?

festes
1-Visitor
(To:supandey)

I am using Python 2.7.9 and Unix. The command I'm using is:

java -jar ./temperature-thing-jar-with-dependencies.jar wss://xxxxx.vuforia.io:8443/Thingworx/WS 3c740dfe-df0e-4c85-8ceb-ee3ce7e2ec85

The tutorial to push simulated data to Thingworx worked. But altering the script to push real-time data from DS18B20 gives the error.

manten
2-Explorer
(To:festes)

I am trying to bind temperature sensor ( DS18B20 ) data to Thingworx platform. I need the script to push real time data from DS18B20   in to thingworx. could you please help me with this script.

Announcements


Top Tags