Open patrikhall opened 2 years ago
I wish support for this sensor type too. If I would now how the initial value is calculated by reveng tools (as mentioned in the whb.cpp file) I could try to add that by myself. Is the checksum for the whole byte stream? Or does it start after id? I don't know. I had no success with the reveng tool yet.
I did first verify reveng functionality with a known sensor and a known init crc value, like this:
#7106 1675763487 L=33 4b 2d d4 2b 1a 09 5f 4a 26 33 a1 37 77 00 b3 00 b4 0a 24 00 b3 00 b4 0a 24 0d da 75 14 4c 80 5b 0d RSSI 77 WHB09 ID 95f4a2633a1TEMP 17.9 HUM 36 TEMP2 18, PTEMP 17.9 PHUM 36 PTEMP2 18
The type of sensor is 9, the init value should be 0xa7a41254.
4b 2d d4 2b is the init bytes, 1a is the length. 1a is also the first byte in the crc calculation. I found out that leaving out the three last bytes 80 5b 0d results in 0x00000000 as end value, and this is what we would like to accomplish.
The command for verify would look like this:
$ ./reveng -c -w 32 -p 0x04c11db7 -i 0xa7a41254 1a095f4a2633a1377700b300b40a2400b300b40a240dda75144c
00000000
Ok, next step would be to search for algorithm with reveng. We need many samples. I collected some samples from my sensor, and serching will be done like this:
./reveng -w 32 -s 241839908d49c940029400da1d27c400da1d27c50205070a0b0c000000000000d09d833c00 241839908d49c940029500db1e27c300da1d27c40206080a0c0d0000000000007249601000 241839908d49c9404d6d00d71c27aa00d71c27ac03070a0a0d0f01010101010176415bec00 241839908d49c9404d6c00d71c27ac00d71c27ac010608090b0e030303030303bbbce01b00
width=32 poly=0x04c11db7 init=0xca0abb08 refin=false refout=false xorout=0x00000000 check=0x5fd65594 residue=0x00000000 name=(none)
The init crc value for the sensor seems then to be 0xca0abb08
Thanks a lot for the response. But I got it by myself. It was not mentioned where the crc-32 starts. Because there is the initial code which obviously not belongs to the crc range. That was my problem. I had a look into the whb.cpp and saw that first 4 bytes are skipped. That helps. I own a WHB07 which is already supported. With these information I was able to to calculate initial crc value for WHB07, finally for WHB18 and added WHB18 to the code. I also added the battery status for command line output. WHB18 also contains information of previous data (temp, hum, barometric pressure). Somebody interested in these code?
I would be interested, sure, as I also have a WHB18 myself. I would like to get temp, humidity and pressure fed as parameter to external script using -e option.
I've forked code and mad a pull request for my additions for WHB18.
I did see your fork, you might consider using cvs_temp with extended range like this:
sd.pressure=cvt_temp(bp, 1);
...to get better range for air pressure. The range is probably even bigger than 10 or 11 bits, so creating another cvt_pressure with 16 bit would be appropriate. Just my thoughts.
type 0x18 sensor seems to be the only weatherhub that support barometric air pressure. The display shows air pressure in HPa, temperature and humidity.
According to MobileAllerts gateway inary upload document, the sensor sends a 3-byte tx counter, temperature as a word, humidity as a byte and air pressure as another word.
Typical debug output:
CRC-32 init value for the sensor is 0xf39c8e73.