- if ((sensor_id == 0x1d20) || (sensor_id == 0x1d30)) {
- if (validate_os_v2_message(msg, 153, num_valid_v2_bits, 15) == 0) {
- int channel = ((msg[2] >> 4)&0x0f);
- if (channel == 4)
- channel = 3; // sensor 3 channel number is 0x04
- float temp_c = get_os_temperature(msg, sensor_id);
- if (sensor_id == 0x1d20) fprintf(stdout, "SENSOR:TYPE=OREGON_THGR122N,ID=%d,", channel);
- else fprintf(stdout, "SENSOR:TYPE=OREGON_THGR968,");
- fprintf(stdout, "TEMPERATURE=%3.1f,HUMIDITY=%d%\n", temp_c,get_os_humidity(msg, sensor_id));
- }
- return 1;
- } else if (sensor_id == 0x5d60) {
- if (validate_os_v2_message(msg, 185, num_valid_v2_bits, 19) == 0) {
- unsigned int comfort = msg[7] >>4;
- char *comfort_str="Normal";
- if (comfort == 4) comfort_str = "Comfortable";
- else if (comfort == 8) comfort_str = "Dry";
- else if (comfort == 0xc) comfort_str = "Humid";
- unsigned int forecast = msg[9]>>4;
- char *forecast_str="Cloudy";
- if (forecast == 3) forecast_str = "Rainy";
- else if (forecast == 6) forecast_str = "Partly Cloudy";
- else if (forecast == 0xc) forecast_str = "Sunny";
- float temp_c = get_os_temperature(msg, 0x5d60);
- fprintf(stdout,"SENSOR:TYPE=OREGON_BHTR968,TEMPERATURE=%3.1f,HUMIDITY=%d,", temp_c, get_os_humidity(msg, 0x5d60));
- fprintf(stdout, "COMFORT=%s,PRESSURE=%d,FORECAST=%s\n", comfort_str, ((msg[7] & 0x0f) | (msg[8] & 0xf0))+856, forecast_str);
- }
- return 1;
- } else if (sensor_id == 0x2d10) {
- if (validate_os_v2_message(msg, 161, num_valid_v2_bits, 16) == 0) {
- float rain_rate = (((msg[4] &0x0f)*100)+((msg[4]>>4)*10) + ((msg[5]>>4)&0x0f)) /10.0F;
- float total_rain = (((msg[7]&0xf)*10000)+((msg[7]>>4)*1000) + ((msg[6]&0xf)*100)+((msg[6]>>4)*10) + (msg[5]&0xf))/10.0F;
- fprintf(stdout, "SENSOR:TYPE=OREGON_RGR968,RAINRATE=%2.0f,RAINTOTAL=%3.0f\n", rain_rate, total_rain);
- }
- return 1;
- } else if (sensor_id == 0xec40 && num_valid_v2_bits==153) {
- if ( validate_os_v2_message(msg, 153, num_valid_v2_bits, 12) == 0) {
- int channel = ((msg[2] >> 4)&0x0f);
- if (channel == 4)
- channel = 3; // sensor 3 channel number is 0x04
- float temp_c = get_os_temperature(msg, sensor_id);
- if (sensor_id == 0xec40) fprintf(stdout, "SENSOR:TYPE=OREGON_THR228N,ID=%d,", channel);
- fprintf(stdout, "TEMPERATURE=%3.1f\n", temp_c);
- }
- return 1;
- } else if (sensor_id == 0xec40 && num_valid_v2_bits==129) {
- if ( validate_os_v2_message(msg, 129, num_valid_v2_bits, 12) == 0) {
- int channel = ((msg[2] >> 4)&0x0f);
- if (channel == 4)
- channel = 3; // sensor 3 channel number is 0x04
- int battery_low = (msg[3] >> 2 & 0x01);
- unsigned char rolling_code = ((msg[2] << 4)&0xF0) | ((msg[3] >> 4)&0x0F);
- float temp_c = get_os_temperature(msg, sensor_id);
- if (sensor_id == 0xec40) fprintf(stdout, "SENSOR:TYPE=OREGON_THN132N,ID=%d,BATTERY=%s,CODE=%0X,", channel, battery_low?"LOW":"OK", rolling_code);
- fprintf(stdout, "TEMPERATURE=%3.1f\n", temp_c);
- }
- return 1;
- } else if (num_valid_v2_bits > 16) {
-fprintf(stderr, "%d bit message received from unrecognized Oregon Scientific v2.1 sensor with device ID %x.\n", num_valid_v2_bits, sensor_id);
-fprintf(stderr, "Message: "); for (i=0 ; i<20 ; i++) fprintf(stderr, "%02x ", msg[i]); fprintf(stderr,"\n\n");
+ if ((sensor_id == ID_THGR122N) || (sensor_id == ID_THGR968)){
+ if (validate_os_v2_message(msg, 153, num_valid_v2_bits, 15) == 0) {
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, (sensor_id == ID_THGR122N) ? "THGR122N": "THGR968",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id),
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Temperature", DATA_FORMAT, "%.02f C", DATA_DOUBLE, get_os_temperature(msg, sensor_id),
+ "humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, get_os_humidity(msg, sensor_id),
+ NULL);
+ data_acquired_handler(data);
+ }
+ return 1;
+ } else if (sensor_id == ID_WGR968) {
+ if (validate_os_v2_message(msg, 189, num_valid_v2_bits, 17) == 0) {
+ float quadrant = (((msg[4] &0x0f)*10) + ((msg[4]>>4)&0x0f) + (((msg[5]>>4)&0x0f) * 100));
+ float avgWindspeed = ((msg[7]>>4)&0x0f) / 10.0F + (msg[7]&0x0f) *1.0F + ((msg[8]>>4)&0x0f) / 10.0F;
+ float gustWindspeed = (msg[5]&0x0f) /10.0F + ((msg[6]>>4)&0x0f) *1.0F + (msg[6]&0x0f) / 10.0F;
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "WGR968",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id),
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "gust", "Gust", DATA_FORMAT, "%2.1f m/s",DATA_DOUBLE, gustWindspeed,
+ "average", "Average", DATA_FORMAT, "%2.1f m/s",DATA_DOUBLE, avgWindspeed,
+ "direction", "Direction", DATA_FORMAT, "%3.1f degrees",DATA_DOUBLE, quadrant,
+ NULL);
+ data_acquired_handler(data);
+ }
+ return 1;
+ } else if (sensor_id == ID_BHTR968) {
+ if (validate_os_v2_message(msg, 185, num_valid_v2_bits, 19) == 0) {
+ unsigned int comfort = msg[7] >>4;
+ char *comfort_str="Normal";
+ if (comfort == 4) comfort_str = "Comfortable";
+ else if (comfort == 8) comfort_str = "Dry";
+ else if (comfort == 0xc) comfort_str = "Humid";
+ unsigned int forecast = msg[9]>>4;
+ char *forecast_str="Cloudy";
+ if (forecast == 3) forecast_str = "Rainy";
+ else if (forecast == 6) forecast_str = "Partly Cloudy";
+ else if (forecast == 0xc) forecast_str = "Sunny";
+ float temp_c = get_os_temperature(msg, sensor_id);
+ // fprintf(stdout,"Weather Sensor BHTR968 Indoor Temp: %3.1fC %3.1fF Humidity: %d%%", temp_c, ((temp_c*9)/5)+32, get_os_humidity(msg, sensor_id));
+ // fprintf(stdout, " (%s) Pressure: %dmbar (%s)\n", comfort_str, ((msg[7] & 0x0f) | (msg[8] & 0xf0))+856, forecast_str);
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "BHTR968",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id),
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Celcius", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
+ "temperature_F", "Fahrenheit", DATA_FORMAT, "%.02f F", DATA_DOUBLE, ((temp_c*9)/5)+32,
+ "humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, get_os_humidity(msg, sensor_id),
+ "pressure", "Pressure", DATA_FORMAT, "%d mbar", DATA_INT, ((msg[7] & 0x0f) | (msg[8] & 0xf0))+856,
+ NULL);
+ data_acquired_handler(data);
+ }
+ return 1;
+ } else if (sensor_id == ID_RGR968) {
+ if (validate_os_v2_message(msg, 161, num_valid_v2_bits, 16) == 0) {
+ float rain_rate = (((msg[4] &0x0f)*100)+((msg[4]>>4)*10) + ((msg[5]>>4)&0x0f)) /10.0F;
+ float total_rain = (((msg[7]&0xf)*10000)+((msg[7]>>4)*1000) + ((msg[6]&0xf)*100)+((msg[6]>>4)*10) + (msg[5]&0xf))/10.0F;
+
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "RGR968",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id),
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "rain_rate", "Rain Rate", DATA_FORMAT, "%.02f mm/hr", DATA_DOUBLE, rain_rate,
+ "total_rain", "Total Rain", DATA_FORMAT, "%.02f mm", DATA_DOUBLE, total_rain,
+ NULL);
+ data_acquired_handler(data);
+ }
+ return 1;
+ } else if (sensor_id == ID_THR228N && num_valid_v2_bits==153) {
+ if (validate_os_v2_message(msg, 153, num_valid_v2_bits, 12) == 0) {
+
+ float temp_c = get_os_temperature(msg, sensor_id);
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "THR228N",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id),
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Celcius", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
+ "temperature_F", "Fahrenheit", DATA_FORMAT, "%.02f F", DATA_DOUBLE, ((temp_c*9)/5)+32,
+ NULL);
+ data_acquired_handler(data);
+ }
+ return 1;
+ } else if (sensor_id == ID_THN132N && num_valid_v2_bits==129) {
+ if (validate_os_v2_message(msg, 129, num_valid_v2_bits, 12) == 0) {
+
+ float temp_c = get_os_temperature(msg, sensor_id);
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "THN132N",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id),
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Celcius", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
+ "temperature_F", "Fahrenheit", DATA_FORMAT, "%.02f F", DATA_DOUBLE, ((temp_c*9)/5)+32,
+ NULL);
+ data_acquired_handler(data);
+ }
+ return 1;
+ } else if ((sensor_id & 0x0fff) == ID_RTGN318) {
+ if (num_valid_v2_bits==153 && (validate_os_v2_message(msg, 153, num_valid_v2_bits, 15) == 0)) {
+ float temp_c = get_os_temperature(msg, sensor_id);
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "RTGN318",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id), // 1 to 5
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Celcius", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
+ "temperature_F", "Fahrenheit", DATA_FORMAT, "%.02f F", DATA_DOUBLE, ((temp_c*9)/5)+32,
+ "humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, get_os_humidity(msg, sensor_id),
+ NULL);
+ data_acquired_handler(data);
+ } else if (num_valid_v2_bits==201 && (validate_os_v2_message(msg, 201, num_valid_v2_bits, 21) == 0)) {
+
+ // RF Clock message ??
+ }
+ return 1;
+ } else if (sensor_id == ID_THN129) {
+ if ((validate_os_v2_message(msg, 137, num_valid_v2_bits, 12) == 0)) {
+ float temp_c = get_os_temperature(msg, sensor_id);
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "THN129",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id), // 1 to 5
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Celcius", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
+ NULL);
+ data_acquired_handler(data);
+ }
+
+ return 1;
+ } else if (sensor_id == ID_BTHGN129) {
+ //if ((validate_os_v2_message(msg, 137, num_valid_v2_bits, 12) == 0)) {
+ float temp_c = get_os_temperature(msg, sensor_id);
+ float pressure = get_os_pressure(msg, sensor_id);
+ data = data_make(
+ "time", "", DATA_STRING, time_str,
+ "brand", "", DATA_STRING, "OS",
+ "model", "", DATA_STRING, "BTHGN129",
+ "id", "House Code", DATA_INT, get_os_rollingcode(msg, sensor_id),
+ "channel", "Channel", DATA_INT, get_os_channel(msg, sensor_id), // 1 to 5
+ "battery", "Battery", DATA_STRING, get_os_battery(msg, sensor_id) ? "LOW" : "OK",
+ "temperature_C", "Celcius", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
+ "humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, get_os_humidity(msg, sensor_id),
+ "pressure", "Pressure", DATA_FORMAT, "%.02f mbar", DATA_DOUBLE,pressure,
+ NULL);
+ data_acquired_handler(data);
+ //}
+
+ return 1;
+ }else if (num_valid_v2_bits > 16) {
+ if(debug_output) {
+ fprintf(stdout, "%d bit message received from unrecognized Oregon Scientific v2.1 sensor with device ID %x.\n", num_valid_v2_bits, sensor_id);
+ fprintf(stdout, "Message: "); for (i=0 ; i<20 ; i++) fprintf(stdout, "%02x ", msg[i]); fprintf(stdout,"\n");
+ }