Skip to content

Commit

Permalink
Acurite 606TX Sensor Support (merbanan#382)
Browse files Browse the repository at this point in the history
* Added support for the Acurite 606TX (temperature only) sensor.

* Added support for the Acurite 606TX (temperature only) sensor.

* Change sensor name. Update fork and fix merge conflicts.

* Merge fixes.
  • Loading branch information
khkremer authored and merbanan committed May 24, 2016
1 parent 42d6da1 commit a203075
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/rtl_433.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define DEFAULT_LEVEL_LIMIT 8000 // Theoretical high level at I/Q saturation is 128x128 = 16384 (above is ripple)
#define MINIMAL_BUF_LENGTH 512
#define MAXIMAL_BUF_LENGTH (256 * 16384)
#define MAX_PROTOCOLS 53
#define MAX_PROTOCOLS 54
#define SIGNAL_GRABBER_BUFFER (12 * DEFAULT_BUF_LENGTH)

/* Supported modulation types */
Expand Down
3 changes: 2 additions & 1 deletion include/rtl_433_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
DECL(proove) \
DECL(bresser_3ch) \
DECL(springfield) \
DECL(oregon_scientific_sl109h)
DECL(oregon_scientific_sl109h) \
DECL(acurite_606)

typedef struct {
char name[256];
Expand Down
107 changes: 107 additions & 0 deletions src/devices/acurite.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "rtl_433.h"
#include "util.h"
#include "pulse_demod.h"
#include "data.h"

// ** Acurite 5n1 functions **

Expand Down Expand Up @@ -623,6 +624,95 @@ static int acurite_986_callback(bitbuffer_t *bitbuf) {
return 0;
}

// Checksum code from
// https://eclecticmusingsofachaoticmind.wordpress.com/2015/01/21/home-automation-temperature-sensors/
// with modifications listed in
// http://www.osengr.org/WxShield/Downloads/Weather-Sensor-RF-Protocols.pdf
//
// This is the same algorithm as used in ambient_weather.c
//
uint8_t Checksum(int length, uint8_t *buff) {
uint8_t mask = 0xd3;
uint8_t checksum = 0x00;
uint8_t data;
int byteCnt;

for (byteCnt = 0; byteCnt < length; byteCnt++) {
int bitCnt;
data = buff[byteCnt];

for (bitCnt = 7; bitCnt >= 0; bitCnt--) {
uint8_t bit;

// Rotate mask right
bit = mask & 1;
mask = (mask >> 1) | (mask << 7);
if (bit) {
mask ^= 0x18;
}

// XOR mask into checksum if data bit is 1
if (data & 0x80) {
checksum ^= mask;
}
data <<= 1;
}
}
return checksum;
}


static int acurite_606_callback(bitbuffer_t *bitbuf) {
data_t *data;
bitrow_t *bb = bitbuf->bb;
float temperature; // temperature in C
int16_t temp; // temperature as read from the data packet
int battery; // the battery status: 1 is good, 0 is low
int8_t sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed


local_time_str(0, time_str);

if (debug_output > 1) {
fprintf(stderr,"acurite_606\n");
bitbuffer_print(bitbuf);
}

// throw out all blank messages
if (bb[1][0] == 0 && bb[1][1] == 0 && bb[1][2] == 0 && bb[1][3] == 0)
return 0;

// do some basic checking to make sure we have a valid data record
if ((bb[0][0] == 0) && (bb[1][4] == 0) && (bb[7][0] == 0x00) && ((bb[1][1] & 0x70) == 0)) {
// calculate the checksum and only continue if we have a maching checksum
uint8_t chk = Checksum(3, &bb[1][0]);

if (chk == bb[1][3]) {
// Processing the temperature:
// Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2
// upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)
temp = (int16_t)((uint16_t)(bb[1][1] << 12) | bb[1][2] << 4);
temp = temp >> 4;

temperature = temp / 10.0;
sensor_id = bb[1][0];
battery = bb[1][1] & 0x8f >> 7;

fprintf(stderr, "%s Acurite 606TX sensor 0x%04X bat %d %3.1f C\n", time_str, sensor_id, battery, temperature);
data = data_make("time", "", DATA_STRING, time_str,
"model", "", DATA_STRING, "Acurite 606TX Sensor",
"id", "", DATA_INT, sensor_id,
"battery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, temperature,
NULL);
data_acquired_handler(data);

}
}

return 0;
}

r_device acurite5n1 = {
.name = "Acurite 5n1 Weather Station",
.modulation = OOK_PULSE_PWM_RAW,
Expand Down Expand Up @@ -718,3 +808,20 @@ r_device acurite_986 = {
.disabled = 0,
.demod_arg = 2,
};

/*
* Acurite 00606TX Tower Sensor
*
* Temperature only
*
*/
r_device acurite_606 = {
.name = "Acurite 606TX Temperature Sensor",
.modulation = OOK_PULSE_PPM_RAW,
.short_limit = 3500,
.long_limit = 7000,
.reset_limit = 10000,
.json_callback = &acurite_606_callback,
.disabled = 0,
.demod_arg = 0,
};

0 comments on commit a203075

Please sign in to comment.