0
$\begingroup$

I have the following data from a generic rain gauge / temperature sensor captured using an Arduino validated against raw data captured using Audacity.

Similar to this question Decoding of binary signal from a temperature sensor I am looking for assistance understanding how these binary values relate to temperature measurements. Temperatures given below are from sensors original display.

22.6 degrees: 11001001 10001101 10001101 11111111 11111111 00000000 01010011 0011101
22.5 degrees: 11001000 00001101 10001110 11111111 11111111 00000000 00101011 1001001
22.4 degrees: 11001000 00001101 10001111 11111111 11111111 00000000 10110000 0001100
22.3 degrees: 11001000 00001101 10010000 11111111 11111111 00000000 00000110 0110111
11.1 degrees: 11000110 00011110 00000000 11111111 11111111 00000000 11101110 1101011
10.8 degrees: 11000110 00011110 00000011 11111111 11111111 00000000 01110010 0101110

Some observations I have made about the bytes that make up this data (from left to right)

  • First byte appears to be sensor ID, changes every time batteries are inserted.
  • Upper nibble of 2nd byte also part of sensor ID?
  • First bit of 2nd byte lower nibble changes to 0 when battery is low, 2nd bit never seems to change even when temperature reading is below 0, possible indicating unit temperature is transmitted in? Remaining 2 bits change related to temperature, see example where temperature drops to 11.1 degrees
  • 3rd byte seems to change relative to temperature.
  • Remaining 5 bytes appear to be related to rainfall measurement and possibly error checking, they do not seem to change in a logical manner vs temperature.

This is probably quite trivial and I am missing something glaringly obvious but any assistance would be appreciated.

$\endgroup$
3
  • 2
    $\begingroup$ Do you have a the datasheet / name of your sensor? $\endgroup$
    – XaC
    Jan 5, 2023 at 7:03
  • $\begingroup$ You are not missing something obvious. These codes can be complicated and without the datasheet this will be difficult to reverse engineer. I you have to do this, than do it in an organized way. Take readings for all temperatures of interest using a known-good reference. $\endgroup$
    – Hilmar
    Jan 5, 2023 at 14:01
  • $\begingroup$ No datasheet unfortunately, this is the sensor in question foshk.com/Rain_Gauge/WH0530.html $\endgroup$
    – TomW
    Jan 5, 2023 at 21:05

1 Answer 1

1
$\begingroup$

After some thinking I believe I have solved this myself.

The user manual indicates the sensor operates from -40 to +65 at a resolution of .1 degrees C giving 1050 potential values (65 + 40 / .1)

To fit 1050 values would need 11 bits, 11 bits would give a total range from 0 to 2047.

With this in mind the I took the last 3 bits of the 2nd byte and 3rd byte (i.e. 11 bits) e.g. 10110001111 and converted to decimal.

10110001111 = 1423 in decimal, I subtract this value from 2047 to give 624 then subtracted 400 to give 224 which when divided by 10 gives the temperature in degrees Celsius (22.4) which matches the sensors original receiver / display.

I stuck the sensor in the freezer to simulate negative readings and also heated it to simulate high temperature readings which all calculated correctly vs the temperatures being reported by the original display.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.