The code: (it is very small, just to test the sensor)
import adafruit_dht, board
print("Current temperature is " + str(adafruit_dht.DHT11(board.D21).temperature))
Full error:
Traceback (most recent call last):
File "/home/murrakhm/Desktop/temp_v1.py", line 3, in <module>
print("Current temperature is " + str(adafruit_dht.DHT11(board.D21).temperature))
File "/home/murrakhm/.local/lib/python3.9/site-packages/adafruit_dht.py", line 274, in temperature
self.measure()
File "/home/murrakhm/.local/lib/python3.9/site-packages/adafruit_dht.py", line 219, in measure
pulses = self._get_pulses_pulseio()
File "/home/murrakhm/.local/lib/python3.9/site-packages/adafruit_dht.py", line 149, in _get_pulses_pulseio
pulses.append(self.pulse_in.popleft())
OverflowError: unsigned short is greater than maximum
The value the sensor (or some other part of your code) is returning is greater than 65535, which is the maximum value for an unsigned short
.
I am not sure how to fix that, I do not have experience with raspberry pi sensors.
PS - An unsigned short is just a number type. short
means it is 2 bytes, and unsigned
means it must be positive (no +/- sign )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.