int main(void) { Temper *t; char buf[256]; int i, ret; usb_set_debug(0); usb_init(); usb_find_busses(); usb_find_devices(); t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, 0); if(!t) { perror("TemperCreate"); exit(-1); } bzero(buf, 256); ret = TemperGetOtherStuff(t, buf, 256); if(t->debug) { printf("Other Stuff (%d bytes):\n", ret); for(i = 0; i < ret; i++) { printf(" %02x", buf[i]); if(i % 16 == 15) { printf("\n"); } } printf("\n"); } double tempc; double rh; if(TemperGetTempAndRelHum(t, &tempc, &rh) < 0) { perror("TemperGetTemperatureAndRelHum"); exit(1); } /* printf("Temperature: %.2f°F, %.2f°C\tRelative humidity: %.2f%%\n", (9.0 / 5.0 * tempc + 32.0), tempc, rh); */ double dew, tn, m; if (tempc > 0) { tn = 243.12; m = 17.62; } else { tn = 272.62; m = 22.46; } dew = tn * (log(rh/100)+(m*tempc/(tn+tempc))) / (m - log(rh/100) - (m*tempc/(tn+tempc))); printf("%.2f %.2f %.2f\n", tempc, rh, dew); return 0; }
void initialize(void){ int i, ret; usb_set_debug(0); usb_init(); usb_find_busses(); usb_find_devices(); t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, 0); if(!t) { perror("TemperCreate"); exit(-1); } }
int main(void) { Temper *t; char buf[256]; int i, ret; usb_set_debug(0); usb_init(); usb_find_busses(); usb_find_devices(); t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, 0); if(!t) { perror("TemperCreate"); exit(-1); } /* TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x43, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); */ float tempc; if(TemperGetTemperatureInC(t, &tempc) < 0) { perror("TemperGetTemperatureInC"); exit(1); } printf("temperature %.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0), tempc); return 0; }