3 /* Inovalley kw9015b rain and Temperature weather station
5 * Copyright (C) 2015 Alexandre Coffignal
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 extern uint8_t reverse8(uint8_t x);
14 static int kw9015b_callback(bitbuffer_t *bitbuffer) {
15 bitrow_t *bb = bitbuffer->bb;
23 if(bitbuffer->bits_per_row[i]!=36){
26 //AAAAAAAA BBBBBBBB BBBBBBBB CCCCCCCC DDDD
32 device=reverse8(bb[i][0]);
33 fTemp=(float)((signed short)(reverse8(bb[i][2])*256+reverse8(bb[i][1]))) /160;
34 iRain = reverse8(bb[i][3]);
35 chksum=((reverse8(bb[i][0])>>4)+(reverse8(bb[i][0])&0x0F)+
36 (reverse8(bb[i][1])>>4)+(reverse8(bb[i][1])&0x0F)+
37 (reverse8(bb[i][2])>>4)+(reverse8(bb[i][2])&0x0F)+
38 (reverse8(bb[i][3])>>4)+(reverse8(bb[i][3])&0x0F));
40 if( (chksum&0x0F) == ( reverse8(bb[i][4]) &0x0F)){
41 fprintf(stdout, "\nSensor = Temperature and rain event\n");
42 fprintf(stdout, "Device = %d\n", device);
43 fprintf(stdout, "Temp = %f\n",fTemp);
44 fprintf(stdout, "Rain = %d\n",iRain);
45 fprintf(stdout, "checksum = %02x==%02x\n",chksum&0xF,reverse8(bb[i][4]));
46 fprintf(stdout, "Received Data = %02X %02X %02X %02X %02X\n",
65 .name = "Inovalley kw9015b rain and Temperature weather station",
66 .modulation = OOK_PULSE_PPM_RAW,
70 .json_callback = &kw9015b_callback,