Skip to main content
1-Visitor
Aug 2, 2017 1:53 PM UTC
Question

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-Regular Member
Aug 3, 2017 7:18 AM UTC

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

Translate
festes1-VisitorAuthor
1-Visitor
Aug 3, 2017 8:20 PM UTC

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

Translate
5-Regular Member
Aug 3, 2017 9:10 PM UTC

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?

Translate