1

I'm trying to connect my BeagleBone Black with DHT11 sensor. I'm following the Adafruit guide they provide, but on script run:

import board
import adafruit_dht
import time
    stdin, stdout, stderr = bbb.exec_command('echo out > /sys/class/gpio/gpio45/direction')
    print("Connessione riuscita!!!!")
    # Sensor should be set to Adafruit_DHT.DHT11,
    # Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302.
    dht_device = adafruit_dht.DHT11(board.D18)

    temperature = dht_device.temperature
    humidity = dht_device.humidity
    print(
    "Temp: {:.1f} , C Humidity: {}% ".format(
    temperature, humidity
    )
    )
    if humidity is not None and temperature is not None:
        print('Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
    else:
        print('Failed to get reading. Try again!')
    # Fai suonare il buzzer per 10 secondi

It gives me the error: AttributeError: module 'board' has no attribute 'D18' . I also tried with the P8_11 pin which would be the actual one of the BeagleBone, but still it doesn't work.

Does anyone know how to fix this error, or alternatively give me a way to connect the two devices in Python? Thanks in advance.

1 Answer 1

0

Have you tried using board.GP45 or board.D45 as that is pin 11 on the P8 side.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.