Skip to content

Commit

Permalink
added json/kv capbilities to Acurite tower sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenakh committed Oct 25, 2016
1 parent 729504b commit 66a3752
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/devices/acurite.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,11 @@ static int acurite_txr_callback(bitbuffer_t *bitbuf) {
float tempc, tempf, wind_dird, rainfall = 0.0, wind_speedmph;
uint8_t humidity, sensor_status, repeat_no, message_type;
char channel, *wind_dirstr = "";
char channel_str[2];
uint16_t sensor_id;
int wind_speed, raincounter, temp;
int wind_speed, raincounter, temp, valid = 0;
uint8_t strike_count, strike_distance;
data_t *data;


local_time_str(0, time_str);
Expand Down Expand Up @@ -468,17 +470,23 @@ static int acurite_txr_callback(bitbuffer_t *bitbuf) {
sensor_status = bb[2]; // @todo, uses parity? & 0x07f
humidity = acurite_getHumidity(bb[3]);
tempc = acurite_txr_getTemp(bb[4], bb[5]);
tempf = celsius2fahrenheit(tempc);
sprintf(channel_str, "%c", channel);

data = data_make(
"time", "", DATA_STRING, time_str,
"model", "", DATA_STRING, "Acurite tower sensor",
"id", "", DATA_INT, sensor_id,
"channel", "", DATA_STRING, &channel_str,
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, tempc,
"humidity", "Humidity", DATA_INT, humidity,
"status", "", DATA_FORMAT, "0x%x", DATA_INT, sensor_status,

printf("%s Acurite tower sensor 0x%04X Ch %c: %3.1F C %3.1F F %d %% RH\n",
time_str, sensor_id, channel, tempc, tempf, humidity);
NULL);

// currently 0x44 seens to be a normal status and/or type
// for tower sensors. Battery OK/Normal == 0x40
if (sensor_status != 0x44)
printf("%s Acurite tower sensor 0x%04X Ch %c, Status %02X\n",
time_str, sensor_id, channel, sensor_status);
data_acquired_handler(data);
valid++;

return 1;
}

// The 5-n-1 weather sensor messages are 8 bytes.
Expand Down

0 comments on commit 66a3752

Please sign in to comment.