Merge remote-tracking branch 'merbanan/master'
This commit is contained in:
commit
f05c840173
5 changed files with 112 additions and 36 deletions
19
README.md
19
README.md
|
@ -3,6 +3,12 @@ rtl_433
|
|||
|
||||
rtl_433 turns your Realtek RTL2832 based DVB dongle into a 433.92MHz generic data receiver
|
||||
|
||||
How to add support for unsupported sensors
|
||||
------------------------------------------
|
||||
|
||||
Read the Test Data section at the bottom.
|
||||
|
||||
|
||||
Installation instructions:
|
||||
--------------------------
|
||||
|
||||
|
@ -114,11 +120,20 @@ Examples:
|
|||
|
||||
This software is mostly useable for developers right now.
|
||||
|
||||
|
||||
Test Data
|
||||
------------
|
||||
|
||||
Test data files for supported devices can be found here: https://github.com/merbanan/rtl_433_tests
|
||||
Please add test data for all devices added to the code to facilitate regression testing.
|
||||
Recordings of the transmitted signals are vital in trying to figure out the signal format. So before you
|
||||
request anything make sure you have recorded a proper set of test signals (10 maybe) together with
|
||||
with the decoded reference values. Then take pictures of the device, preferable even the pcb. Then
|
||||
document as much as possible about the device. Now when you have all this, check out the rtl_433_tests
|
||||
repository.
|
||||
|
||||
https://github.com/merbanan/rtl_433_tests
|
||||
|
||||
Follow the existing structure as best as possible and send a pull request.
|
||||
Now you can add an issue about wanting support for an unsupported format.
|
||||
|
||||
Google Group
|
||||
------------
|
||||
|
|
|
@ -62,18 +62,17 @@ int byteParity(uint8_t inByte);
|
|||
/// @param buf: output buffer, long enough for YYYY-MM-DD HH:MM:SS
|
||||
void local_time_str(time_t time_secs, char *buf);
|
||||
|
||||
/**
|
||||
* convert unit from celsius to fahrenheit
|
||||
* @param celsius input temperature in Celsius
|
||||
* @return temperature value in Fahrenheit
|
||||
*/
|
||||
float celsius2fahrenheit(float celsius);
|
||||
|
||||
|
||||
/// Convert Celsious to Fahrenheit
|
||||
/// Convert Celsius to Fahrenheit
|
||||
///
|
||||
/// @param celsius: temperature in Celsius
|
||||
/// @return temperature value in Fahrenheit
|
||||
float celsius2fahrenheit(float celsius);
|
||||
|
||||
|
||||
/// Convert Fahrenheit to Celsius
|
||||
///
|
||||
/// @param celsius: temperature in Fahrenheit
|
||||
/// @return temperature value in Celsius
|
||||
float fahrenheit2celsius(float fahrenheit);
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ bin_PROGRAMS = rtl_433
|
|||
|
||||
rtl_433_SOURCES = baseband.c \
|
||||
bitbuffer.c \
|
||||
data.c \
|
||||
pulse_demod.c \
|
||||
pulse_detect.c \
|
||||
rtl_433.c \
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "rtl_433.h"
|
||||
#include "data.h"
|
||||
#include "util.h"
|
||||
|
||||
static float
|
||||
get_temperature (uint8_t * msg)
|
||||
|
@ -96,6 +98,16 @@ static int
|
|||
ambient_weather_parser (bitbuffer_t *bitbuffer)
|
||||
{
|
||||
bitrow_t *bb = bitbuffer->bb;
|
||||
float temperature;
|
||||
uint8_t humidity;
|
||||
uint16_t channel;
|
||||
uint16_t deviceID;
|
||||
|
||||
time_t time_now;
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
data_t *data;
|
||||
time(&time_now);
|
||||
local_time_str(time_now, time_str);
|
||||
|
||||
if(bitbuffer->bits_per_row[0] != 195) // There seems to be 195 bits in a correct message
|
||||
return 0;
|
||||
|
@ -119,24 +131,24 @@ ambient_weather_parser (bitbuffer_t *bitbuffer)
|
|||
*/
|
||||
|
||||
if ( (bb[0][0] == 0x00) && (bb[0][1] == 0x14) && (bb[0][2] & 0x50) ) {
|
||||
fprintf (stderr, "\nSensor Temperature Event:\n");
|
||||
fprintf (stderr, "protocol = Ambient Weather\n");
|
||||
|
||||
if (validate_checksum (bb[0], BITBUF_COLS)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float temperature = get_temperature (bb[0]);
|
||||
fprintf (stderr, "temp = %.1f\n", temperature);
|
||||
|
||||
uint8_t humidity = get_humidity (bb[0]);
|
||||
fprintf (stderr, "humidity = %d\n", humidity);
|
||||
|
||||
uint16_t channel = get_channel (bb[0]);
|
||||
fprintf (stderr, "channel = %d\n", channel);
|
||||
temperature = get_temperature (bb[0]);
|
||||
humidity = get_humidity (bb[0]);
|
||||
channel = get_channel (bb[0]);
|
||||
deviceID = get_device_id (bb[0]);
|
||||
|
||||
data = data_make("time", "", DATA_STRING, time_str,
|
||||
"device", "", DATA_INT, deviceID,
|
||||
"channel", "", DATA_INT, channel,
|
||||
"temperature_F", "", DATA_FORMAT, "%.1f", DATA_DOUBLE, temperature,
|
||||
"humidity", "", DATA_INT, humidity,
|
||||
NULL);
|
||||
data_acquired_handler(data);
|
||||
|
||||
uint16_t deviceID = get_device_id (bb[0]);
|
||||
fprintf (stderr, "id = %d\n", deviceID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -149,6 +161,15 @@ ambient_weather_callback (bitbuffer_t *bitbuffer)
|
|||
return ambient_weather_parser (bitbuffer);
|
||||
}
|
||||
|
||||
static char *output_fields[] = {
|
||||
"time",
|
||||
"device",
|
||||
"channel",
|
||||
"temperature_F",
|
||||
"humidity",
|
||||
NULL
|
||||
};
|
||||
|
||||
r_device ambient_weather = {
|
||||
.name = "Ambient Weather Temperature Sensor",
|
||||
.modulation = OOK_PULSE_MANCHESTER_ZEROBIT,
|
||||
|
@ -158,4 +179,5 @@ r_device ambient_weather = {
|
|||
.json_callback = &ambient_weather_callback,
|
||||
.disabled = 0,
|
||||
.demod_arg = 0,
|
||||
.fields = output_fields
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* the data is grouped in 9 nibles
|
||||
* [id0] [rid0] [rid1] [data0] [temp0] [temp1] [temp2] [humi0] [humi1]
|
||||
*
|
||||
* id0 is always 1001,9
|
||||
* id0 is 1001,9 or 0110,5
|
||||
* rid is a random id that is generated when the sensor starts, could include battery status
|
||||
* the same batteries often generate the same id
|
||||
* data(3) is 0 the battery status, 1 ok, 0 low, first reading always say low
|
||||
|
@ -19,12 +19,24 @@
|
|||
* The sensor can be bought at Clas Ohlson
|
||||
*/
|
||||
#include "rtl_433.h"
|
||||
#include "util.h"
|
||||
#include "data.h"
|
||||
|
||||
static int prologue_callback(bitbuffer_t *bitbuffer) {
|
||||
bitrow_t *bb = bitbuffer->bb;
|
||||
int rid;
|
||||
data_t *data;
|
||||
|
||||
time_t time_now;
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
|
||||
uint8_t rid;
|
||||
uint8_t id;
|
||||
uint8_t channel;
|
||||
uint8_t button;
|
||||
uint8_t battery;
|
||||
int16_t temp2;
|
||||
float temp;
|
||||
uint8_t humidity;
|
||||
|
||||
/* FIXME validate the received message better */
|
||||
if (((bb[1][0]&0xF0) == 0x90 && (bb[2][0]&0xF0) == 0x90 && (bb[3][0]&0xF0) == 0x90 && (bb[4][0]&0xF0) == 0x90 &&
|
||||
|
@ -32,25 +44,51 @@ static int prologue_callback(bitbuffer_t *bitbuffer) {
|
|||
((bb[1][0]&0xF0) == 0x50 && (bb[2][0]&0xF0) == 0x50 && (bb[3][0]&0xF0) == 0x50 && (bb[4][0]&0xF0) == 0x50 &&
|
||||
(bb[1][3] == bb[2][3]) && (bb[1][4] == bb[2][4]))) {
|
||||
|
||||
/* Get time now */
|
||||
time(&time_now);
|
||||
local_time_str(time_now, time_str);
|
||||
|
||||
/* Prologue sensor */
|
||||
id = (bb[1][0]&0xF0)>>4;
|
||||
rid = ((bb[1][0]&0x0F)<<4) | ((bb[1][1]&0xF0)>>4);
|
||||
battery = bb[1][1]&0x08;
|
||||
channel = (bb[1][1]&0x03) + 1;
|
||||
button = (bb[1][1]&0x04) >> 2;
|
||||
temp2 = (int16_t)((uint16_t)(bb[1][2] << 8) | (bb[1][3]&0xF0));
|
||||
temp2 = temp2 >> 4;
|
||||
fprintf(stdout, "Sensor temperature event:\n");
|
||||
fprintf(stdout, "protocol = Prologue, %d bits\n",bitbuffer->bits_per_row[1]);
|
||||
fprintf(stdout, "button = %d\n",bb[1][1]&0x04?1:0);
|
||||
fprintf(stdout, "battery = %s\n",bb[1][1]&0x08?"Ok":"Low");
|
||||
fprintf(stdout, "temp = %s%d.%d\n",temp2<0?"-":"",abs((int16_t)temp2/10),abs((int16_t)temp2%10));
|
||||
fprintf(stdout, "humidity = %d\n", ((bb[1][3]&0x0F)<<4)|(bb[1][4]>>4));
|
||||
fprintf(stdout, "channel = %d\n",(bb[1][1]&0x03)+1);
|
||||
fprintf(stdout, "id = %d\n",(bb[1][0]&0xF0)>>4);
|
||||
rid = ((bb[1][0]&0x0F)<<4)|(bb[1][1]&0xF0)>>4;
|
||||
fprintf(stdout, "rid = %d\n", rid);
|
||||
fprintf(stdout, "hrid = %02x\n", rid);
|
||||
temp = temp2/10.;
|
||||
humidity = ((bb[1][3]&0x0F)<<4) | (bb[1][4]>>4);
|
||||
|
||||
data = data_make("time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "Prologue sensor",
|
||||
"id", "", DATA_INT, id,
|
||||
"rid", "", DATA_INT, rid,
|
||||
"channel", "Channel", DATA_INT, channel,
|
||||
"battery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
|
||||
"button", "Button", DATA_INT, button,
|
||||
"temperature_C", "Temperature", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp,
|
||||
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
|
||||
NULL);
|
||||
data_acquired_handler(data);
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *output_fields[] = {
|
||||
"time",
|
||||
"model",
|
||||
"id",
|
||||
"rid",
|
||||
"channel",
|
||||
"battery",
|
||||
"button",
|
||||
"temperature_C",
|
||||
"humidity",
|
||||
NULL
|
||||
};
|
||||
|
||||
r_device prologue = {
|
||||
.name = "Prologue Temperature Sensor",
|
||||
.modulation = OOK_PULSE_PPM_RAW,
|
||||
|
@ -60,4 +98,5 @@ r_device prologue = {
|
|||
.json_callback = &prologue_callback,
|
||||
.disabled = 0,
|
||||
.demod_arg = 0,
|
||||
.fields = output_fields
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue