Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How set GPIO Pin for DHT22 over ENV Variable? #57

Closed
@Tob1as

Description

@Tob1as

Hello,

i use the example file dht_simpletest.py and replace D18 with D4 for use on Raspberry Pi 3.

But now I would like to set the pin over an enviroment variable. I add this to the script:

import os

DHT_DATA_PIN = int(os.environ.get('GPIO_PIN_DHT22', 4))

But now I have problem to replace the number 4 in this line:

dhtDevice = adafruit_dht.DHT22(board.D4)

This:

dhtDevice = adafruit_dht.DHT22(DHT_DATA_PIN)
# or
dhtDevice = adafruit_dht.DHT22(4)

works local on Raspberry, but not in Docker Container... error: self._pin = Pin(pin.id) AttributeError: 'int' object has no attribute 'id'. So i think i must use it with "board".

Can anyone help or have an idea? :-)

(My complete Code if it helps.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions