Skip to content

Commit

Permalink
Added code to handle the Oregon Scientific THWR800 Wireless Floating
Browse files Browse the repository at this point in the history
Temperature Sensor.  The packet is type 0x44, 7 bytes in length and only
measures temperature.

In the log file it appears as:
DATA[20110306053856]:type=WATER,sensor=3,temp=18.0
  • Loading branch information
geoffk committed Mar 6, 2011
1 parent 0a5b11e commit 511ecd6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions wmr100.c
Expand Up @@ -302,6 +302,22 @@ void wmr_handle_temp(WMR *wmr, unsigned char *data, int len)
free(msg);
}

void wmr_handle_water(WMR *wmr, unsigned char *data, int len)
{
int sensor;
float temp;
char *msg;

sensor = data[2] & 0x0f;

temp = (data[3] + ((data[4] & 0x0f) << 8)) / 10.0;
if ((data[4] >> 4) == 0x8) temp = -temp;

asprintf(&msg, "type=WATER,sensor=%d,temp=%.1f", sensor, temp);
wmr_log_data(wmr, msg);
free(msg);
}

void wmr_handle_pressure(WMR *wmr, unsigned char *data, int len)
{
int pressure, forecast, alt_pressure, alt_forecast;
Expand Down Expand Up @@ -383,6 +399,9 @@ void wmr_handle_packet(WMR *wmr, unsigned char *data, int len)
case 0x42:
wmr_handle_temp(wmr, data, len);
break;
case 0x44:
wmr_handle_water(wmr, data, len);
break;
case 0x46:
wmr_handle_pressure(wmr, data, len);
break;
Expand Down Expand Up @@ -428,6 +447,9 @@ void wmr_read_data(WMR *wmr)
case 0x42:
data_len = 12;
break;
case 0x44:
data_len = 7;
break;
case 0x46:
data_len = 8;
break;
Expand Down

0 comments on commit 511ecd6

Please sign in to comment.