axlan / sainlogic-sdr

Project to reverse engineer Sainlogic weather station wireless data and provide GNU Radio reciever
7 stars 4 forks source link

Sainsmart Weather Station #2

Open firebovine opened 2 years ago

firebovine commented 2 years ago

Heya,

I went down the rabbit hole of trying to understand your code in order to get rtl_433 to be able to parse our weather stations. Turns out my model has a different preamble than yours, and the CRC8 algorithm works for both of our datas if we do the (correct) CRC8 without the preamble (in your case, 0xffd4). My preamble is the same as in the code, 0x014 (0x0140 but only the most significant 12 bits count).

This website is a nice calculator, too: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html if you want to generate the table for polynomial=0x31,init=0xc0 (I tested with your data, it works if you first exclude the 0xffd4 preamble, which might really be 0xfd4 or something, since they're 12 bits...?).

It may be useful for you to know rtl_433 already supports our devices (maybe not yours due to preamble). You may want to consider modifying the code to include your pre-amble if you have the time to test and submit a PR.

Regardless, I've confirmed our data gets parsed the same way, so this reference may be illuminating to you:

https://github.com/merbanan/rtl_433/blob/master/src/devices/cotech_36_7959.c#L28-L44

I have a Sainlogic WS019T station transmitter (sensors).

Thanks for your code (and blog), it helped me understand lots of things that I know nothing about!

(For reference, here's how I can get the good datas with rtl_433 with the flexible decoder): rtl_433 -R 0 -X 'n=name,m=OOK_MC_ZEROBIT,s=500,l=0,r=1200,gap=1200,preamble={12}0x014'

PS: if you wouldn't mind adding a LICENSE file, we'd all appreciate, although I didn't end up needing to 'borrow' any of your code :).

swilsonnc commented 7 months ago

I have the WS0835 station and am using a rtlsdr and rtl_433. Mine is showing up as a Cotech-367959 which is ID 153. My command line is rtl_433 -C customary -R 153 -F "mqtt://192.168.1.37:1883". I then pull the data into Homeassistant using the MQTT integration. I am reading Temp, Humidity, Rain, Wind avg, wind gust, wind direction and battery. I wish it would read barometric pressure but I am guessing it is getting that data right out of a sensor in the display unit. You may have to update your rtl_433 to get ID 153 to work correctly.