Skip to main content
1-Visitor
August 2, 2017
Question

Connecting DS18B20 to Thingworx

  • August 2, 2017
  • 5 replies
  • 2761 views

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
August 3, 2017

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

festes1-VisitorAuthor
1-Visitor
August 3, 2017

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

5-Regular Member
August 3, 2017

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?