dhtserver/src/dht/linux/libdht.c

18 lines
380 B
C

#include "libdht.h"
#include <stdio.h>
#include <unistd.h>
#include <pi_2_dht_read.h>
int getdhtstring(int PIN, char* string)
{
float humid;
float temp;
while (1) {
if (pi_2_dht_read(PIN, PIN, &humid, &temp) == DHT_SUCCESS) {
sprintf(string, "{\"humidity\": %.1f, \"temp\": %.1f}", humid, temp);
break;
}
}
return 0;
}