Skip to content

Litte change in example: AdafruitDHT.py #1

@ds2k5

Description

@ds2k5

Hello,
i tryed your: Python_DHT with Python 3.4.2.
Did not work.

python3 AdafruitDHT.py
File "AdafruitDHT.py", line 35
print 'usage: sudo ./Adafruit_DHT.py [11|22|2302] GPIOpin#'
^
SyntaxError: Missing parentheses in call to 'print'

It work with python2

Here is my mod

AdafruitDHT.zip

24c24
< import Adafruit_DHT
---
> import Python_DHT
28,30c28,30
< sensor_args = { '11': Adafruit_DHT.DHT11,
< 				'22': Adafruit_DHT.DHT22,
< 				'2302': Adafruit_DHT.AM2302 }
---
> sensor_args = { '11': Python_DHT.DHT11,
> 				'22': Python_DHT.DHT22,
> 				'2302': Python_DHT.AM2302 }
35,36c35,36
< 	print 'usage: sudo ./Adafruit_DHT.py [11|22|2302] GPIOpin#'
< 	print 'example: sudo ./Adafruit_DHT.py 2302 4 - Read from an AM2302 connected to GPIO #4'
---
> 	print ("usage: sudo ./Adafruit_DHT.py [11|22|2302] GPIOpin#")
> 	print ("example: sudo ./Adafruit_DHT.py 2302 4 - Read from an AM2302 connected to GPIO #4")
41c41
< humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
---
> humidity, temperature = Python_DHT.read_retry(sensor, pin)
48c48
< 	print 'Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity)
---
> 	print ('Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
50c50
< 	print 'Failed to get reading. Try again!'
---
> 	print ('Failed to get reading. Try again!')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions