Created
January 23, 2014 01:00
-
-
Save kfigiela/8570788 to your computer and use it in GitHub Desktop.
idDHTLib for mbed example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ticker dhtTicker, lcdTicker; | |
void dhtWrapper(); | |
idDHTLib DHTLib(PTD7, dhtWrapper); | |
void dhtWrapper(){ | |
DHTLib.dht22Callback(); // change do dht11Callback if needed | |
} | |
void readDht() { | |
if(!DHTLib.acquiring()) DHTLib.acquire(); | |
} | |
void updateDisplay() { | |
float humidity = DHTLib.getHumidity(); | |
printf("%f\n", humidity); | |
// ... update LCD or sth | |
} | |
int main() { | |
dhtTicker.attach(&readDht, 3.0); // DHT's can be read no more often than every 2s if I remember correctly | |
lcdTicker.attach(&updateDisplay, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment