AttributeError: 'module' object has no attribute 'DHT11'

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
DiegoArnaiz74
Posts: 1
Joined: Tue Dec 01, 2020 1:35 am

AttributeError: 'module' object has no attribute 'DHT11'

Post by DiegoArnaiz74 » Tue Dec 01, 2020 1:48 am

Hello everyone! I need help! I have an issue with a DHT11 and a generic 39pin ESP32 dev board.

My program returns only sometimes, this error: "AttributeError: 'module' object has no attribute 'DHT11'". But it works most of the times.

I'm reading temperature and humidity, send it to a 16x2 display and uploading the data to AskSensors

This is a part of the code, and my project so far it's here (I'm just testing):
https://github.com/darnaiz/WeatherStationDev1

Code: Select all

from machine import I2C
from machine import Pin
from machine import RTC
from time import sleep
from time import sleep_ms
from time import ticks_ms
from esp8266_i2c_lcd import I2cLcd
import network
import dht
import urequests
import WorldClock

p0 = Pin(4, Pin.OUT)
p1 = Pin(17, Pin.OUT)
d = dht.DHT11(Pin(16))
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=400000)
lcd = I2cLcd(i2c, 0x27, 2, 16)
lcd.backlight_off()
lcd.clear()
(etx. etc)

I'll thanks a lot your help :)

Post Reply