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()
I'll thanks a lot your help