Steelmate tpms improvements#3271
Steelmate tpms improvements#3271zuckschwerdt merged 9 commits intomerbanan:fix-steelmate_TPMSfrom buxtronix:fix-steelmate_TPMS
Conversation
| unsigned bitpos = bitbuffer_search(bitbuffer, row, 0, preamble_pattern, 24); | ||
| if (bitpos >= row_len - 64) | ||
| continue; // DECODE_ABORT_EARLY | ||
| b = &b[bitpos / 8]; |
There was a problem hiding this comment.
We should either bitbuffer_extract_bytes() or make sure bitpos % 8 == 0
There was a problem hiding this comment.
Updated to use better bit wrangling.
| //Temperature is stored in Fahrenheit. Note that the datasheet claims operational to -40'C, but can only express values from -17.8'C | ||
| uint8_t tempFahrenheit = ~reverse8(b[6]); | ||
| //Temperature is sent as degrees Celcius + 50. | ||
| uint8_t v1 = ~reverse8(b[6]); |
There was a problem hiding this comment.
These can simply be ints.
|
Thanks! Yes, let's keep output units for now, but after this is merged please prepare a PR with the pressure_PSI to pressure_kPa and temperature_F to temperature_C change. |
| unsigned bitpos = bitbuffer_search(bitbuffer, row, 0, preamble_pattern, 24); | ||
| if (bitpos > row_len - 72) | ||
| continue; // DECODE_ABORT_EARLY | ||
| bitbuffer_extract_bytes(bitbuffer, row, bitpos, b, 72); |
There was a problem hiding this comment.
Remove the uint8_t *b = bitbuffer->bb[row]; above and add directly before extract:
uint8_t b[9];
| //Temperature is stored in Fahrenheit. Note that the datasheet claims operational to -40'C, but can only express values from -17.8'C | ||
| uint8_t tempFahrenheit = ~reverse8(b[6]); | ||
| //Temperature is sent as degrees Celcius + 50. | ||
| int tempCelcius = b[6] - 50; |
There was a problem hiding this comment.
should be all snake_case, i.e. temp_c
| continue; // DECODE_FAIL_MIC | ||
| //Battery voltage is stored as 100*(3.9v-<volt>). | ||
| uint8_t b1 = b[7]; | ||
| int battery_mV = (int)3900 - ((double)b1 * 10.0f); |
There was a problem hiding this comment.
preferably all lower case battery_mv
| continue; // DECODE_FAIL_MIC | ||
| //Battery voltage is stored as 100*(3.9v-<volt>). | ||
| uint8_t b1 = b[7]; | ||
| int battery_mv = (int)3900 - ((double)b1 * 10.0f); |
There was a problem hiding this comment.
All good for merge, though I'd like to mention that this is perhaps not doing what is intended:
(int)3900 is already int but will be promoted to double because of the right side.
10.0f will be promted to double because of the casted b1.
I guess it would suffice to calc: int battery_mv = 3900 - b1 * 10;, right?
There was a problem hiding this comment.
You're right, i got carried away a little and simplified it now. Tests still pass.
* Fix Steelmate pressure formula * Improve Steelmate TPMS readouts (merbanan#3271) * Change Steelmate TPMS to native units BREAKING CHANGE (merbanan#3274) --------- Co-authored-by: buxtronix <bbuxton@gmail.com>
Improvements to this protocol per discussions in #3200. I'm adding this to the existing pending branch.
I did some fairly thorough analysis on the bench involving a bike pump, power supply, fridge, 3d printer heated bed and a transmitter. The following changes are made:
I also have ensured rtl_433_tests are updated/passing and will send a PR for this.