title: (Adafruit_Python_DHT - Raspberry Pi) in get_platform RuntimeError: Unknown platform
body: <p>I have a <strong>Raspberry Pi 4</strong> connected with a DHT22 sensor, and I want to read data from my sensor.</p>
  <p>So I installed the library <a href="https://github.com/adafruit/Adafruit_Python_DHT" rel="nofollow noreferrer">Adafruit_DHT</a></p>
  <pre><code>sudo pip3 install Adafruit_DHT
  </code></pre>
  <p>then, I navigate to the directory <code>Adafruit_Python_DHT/examples/</code>, and then,</p>
  <p>since I have a DHT<strong>22</strong> sensor connected to GPIO pi n° <strong>4</strong>,</p>
  <p>I run</p>
  <pre><code>python AdafruitDHT.py 22 4
  </code></pre>
  <p>and I get</p>
  <pre><code>(lab_app) root@Raspberry100:/var/www/lab_app/Adafruit_Python_DHT/examples# python AdafruitDHT.py 2302 4
  Traceback (most recent call last):
    File &quot;AdafruitDHT.py&quot;, line 41, in &lt;module&gt;
      humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    File &quot;/var/www/lab_app/lib/python3.8/site-packages/Adafruit_DHT-1.4.0-py3.8-linux-armv7l.egg/Adafruit_DHT/common.py&quot;, line 94, in read_retry
      humidity, temperature = read(sensor, pin, platform)
    File &quot;/var/www/lab_app/lib/python3.8/site-packages/Adafruit_DHT-1.4.0-py3.8-linux-armv7l.egg/Adafruit_DHT/common.py&quot;, line 80, in read
      platform = get_platform()
    File &quot;/var/www/lab_app/lib/python3.8/site-packages/Adafruit_DHT-1.4.0-py3.8-linux-armv7l.egg/Adafruit_DHT/common.py&quot;, line 63, in get_platform
      raise RuntimeError('Unknown platform.')
  RuntimeError: Unknown platform.
  (lab_app) root@Raspberry100:/var/www/lab_app/Adafruit_Python_DHT/examples# python AdafruitDHT.py 22 4
  Traceback (most recent call last):
    File &quot;AdafruitDHT.py&quot;, line 41, in &lt;module&gt;
      humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    File &quot;/var/www/lab_app/lib/python3.8/site-packages/Adafruit_DHT-1.4.0-py3.8-linux-armv7l.egg/Adafruit_DHT/common.py&quot;, line 94, in read_retry
      humidity, temperature = read(sensor, pin, platform)
    File &quot;/var/www/lab_app/lib/python3.8/site-packages/Adafruit_DHT-1.4.0-py3.8-linux-armv7l.egg/Adafruit_DHT/common.py&quot;, line 80, in read
      platform = get_platform()
    File &quot;/var/www/lab_app/lib/python3.8/site-packages/Adafruit_DHT-1.4.0-py3.8-linux-armv7l.egg/Adafruit_DHT/common.py&quot;, line 63, in get_platform
      raise RuntimeError('Unknown platform.')
  RuntimeError: Unknown platform.
  (lab_app) root@Raspberry100:/var/www/lab_app/Adafruit_Python_DHT/examples#
  </code></pre>
  <p>Since the traceback indicates</p>
  <blockquote>
  <p>'Unknown platform.'</p>
  </blockquote>
  <p>I did a little research on the github repository of Adafruit_Python_DHT library, and I found the script <a href="https://github.com/adafruit/Adafruit_Python_DHT/blob/master/Adafruit_DHT/common.py" rel="nofollow noreferrer"><code>Adafruit_Python_DHT/Adafruit_DHT/common.py</code></a>. <br> Here I see there is an If/elif structure <code>def get_platform()</code> that aims to identify the device calling the library, but there is value assignment only for RPi 1, 2 and 3, while RPi 4 is missing.<br>
  So I bet this is the reason why the error <code>unknown platform</code> occurs.</p>
  <p>I navigated the library source code and I found out the directory <a href="https://github.com/adafruit/Adafruit_Python_DHT/tree/master/Adafruit_DHT" rel="nofollow noreferrer"><code>Adafruit_Python_DHT/Adafruit_DHT/</code></a> , in which the last commit says &quot;included Raspberry Pi 4&quot;. <br>
  Here is a module <a href="https://github.com/adafruit/Adafruit_Python_DHT/blob/master/Adafruit_DHT/platform_detect.py" rel="nofollow noreferrer"><code>platform_detect.py</code></a> that seems to be designed to somehow &quot;upgrade&quot; the library in order to recognize Raspberry Pi 4.</p>
  <p>So I tryed to &quot;upgrade&quot; my library by doing this:</p>
  <p>In <code>(lab_app) root@Raspberry100:/var/www/lab_app/Adafruit_Python_DHT/Adafruit_DHT#</code>,</p>
  <p>I run</p>
  <pre><code>platform_detect.py
  </code></pre>
  <p>And I don't get any output from the prompt, so I guess everything has gone right.</p>
  <p>Then I navigate to the directory <code>Adafruit_Python_DHT/examples/</code> and run again</p>
  <pre><code>python AdafruitDHT.py 22 4
  </code></pre>
  <p>but I still get the same error.</p>
  <p>So how can I get data from a DHT22 sensor connected to GPIO pi n° 4 by using Adafruit_Python_DHT library?</p>