Sub Process_Globals
Public Serial1 As Serial
Public DHT11sensor As dht
Public DHT11pin As Pin
'DHT11 signal pinnumber: D4 = GPIO2 = 2
Public DHT11pinNumber As Byte = 0x02
Private MeasureTimer As Timer
Private MeasureTimerInterval As ULong = 2000
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
DHT11pin.Initialize(DHT11pinNumber, DHT11pin.MODE_INPUT)
MeasureTimer.Initialize("MeasureTimer_Tick", MeasureTimerInterval)
MeasureTimer.Enabled =True
Log("AppStart - DHT11 read every ", MeasureTimerInterval / 1000, " seconds")
End Sub
Private Sub MeasureTimer_Tick
DHT11sensor.Read11(DHT11pin.PinNumber)
Log("Temperature: ",DHT11sensor.GetTemperature, "C, Humidity:",DHT11sensor.GetHumidity, "%")
End Sub