Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *command = "dht";
- // The command "dht" returns a string in the form "xx.x xx.x"
- FILE *fd = popen(command, "r");
- char buffer[10];
- fgets(buffer, 10, fd);
- pclose(fd);
- char temp[5] = "";
- char humid[5] = "";
- strncpy(temp, buffer, 4);
- temp[4] = '\0';
- strncpy(humid, buffer+5, 4);
- humid[4] = '\0';
- char tempInfo[15];
- sprintf(tempInfo, "Temp: %s C", temp);
- char humidInfo[15];
- sprintf(humidInfo, "Hum: %s %%", humid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement