Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 9a77169

Browse files
authored
Merge pull request #55 from szponek/fix-pi3-detection
Detect Pi 3 properly on newer kernels
2 parents 3f30544 + e1d10e1 commit 9a77169

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Adafruit_DHT/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def get_platform():
5050
elif version == 2:
5151
from . import Raspberry_Pi_2
5252
return Raspberry_Pi_2
53+
elif version == 3:
54+
"""Use Pi 2 driver even though running on Pi 3"""
55+
from . import Raspberry_Pi_2
56+
return Raspberry_Pi_2
5357
else:
5458
raise RuntimeError('No driver for detected Raspberry Pi version available!')
5559
elif plat == platform_detect.BEAGLEBONE_BLACK:

Adafruit_DHT/platform_detect.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ def pi_revision():
7878

7979

8080
def pi_version():
81-
"""Detect the version of the Raspberry Pi. Returns either 1, 2 or
81+
"""Detect the version of the Raspberry Pi. Returns either 1, 2, 3 or
8282
None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+),
83-
Raspberry Pi 2 (model B+), or not a Raspberry Pi.
83+
Raspberry Pi 2 (model B+), Raspberry Pi 3 or not a Raspberry Pi.
8484
"""
8585
# Check /proc/cpuinfo for the Hardware field value.
8686
# 2708 is pi 1
8787
# 2709 is pi 2
88+
# 2835 is pi 3
8889
# Anything else is not a pi.
8990
with open('/proc/cpuinfo', 'r') as infile:
9091
cpuinfo = infile.read()
@@ -100,6 +101,9 @@ def pi_version():
100101
elif match.group(1) == 'BCM2709':
101102
# Pi 2
102103
return 2
104+
elif match.group(1) == 'BCM2835':
105+
# Pi 3
106+
return 3
103107
else:
104108
# Something else, not a pi.
105109
return None

0 commit comments

Comments
 (0)