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.