Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Schou 72543 Rain sensor #2686

Merged
merged 19 commits into from
Nov 8, 2023
Merged

Conversation

36jemini
Copy link
Contributor

Hi,

I have tried to my best ability to write up a decoder for my Schou rain sensor (model: 72543).
The code is not 100% done, but it is at a stage where I would like to request some help.

I have added a pull request with test samples and a longer device description to the rtl_433_tests project,
which has not yet been merged in, so please find it here until then: https://github.com/36jemini/rtl_433_tests/tree/master/tests/Schou

I would like some guidance on,

  • In which file should I "register" the schou_72543_rain.c file?
  • Have I made the right approach to extract the data from the bitbuffer?

Comments, feedback and guidance will be highly appreciated.

@36jemini
Copy link
Contributor Author

Also, should this be a "draft" Pull request? I'm still new to both git and github

//Assuming option #1

// Full data is 3 rows, two are required for data validation
if(bitbuffer->num_rows < 2){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space after keywords (if) and before braces.

uint8_t micSum = b[7]; // Checksum as read
uint8_t calSum = 0; // Checksum as calculated

for(i = 0; i<7; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use int cal_sum = add_bytes(b, 7);

@zuckschwerdt
Copy link
Collaborator

* In which file should I "register" the _schou_72543_rain.c_ file?

include/rtl_433_devices.h then stage or commit and call ./maintainer_update.py. Compile and call ./maintainer_update.py again.

2) schou_72543_rain added to include/rtl_433_devices.h
 Conflicts:
	include/rtl_433_devices.h
 Solution:
        rearrange schou_72543_rain after tmps_nissan
@@ -70,7 +69,7 @@ static int schou_72543_rain_decode(r_device *decoder, bitbuffer_t *bitbuffer)
//Assuming option #1

// Full data is 3 rows, two are required for data validation
if(bitbuffer->num_rows < 2){
if (bitbuffer->num_rows < 2){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and a space near the end :)

rain_mm = ((b[4] << 8 ) & b[3]) / 10.0f;
temp_F = (((b[6] << 8 ) & b[5]) / 10.0f) - 90;
temp_F = (((b[6] << 8 ) & b[5]) / 10.0f) - 90;
Copy link
Collaborator

@zuckschwerdt zuckschwerdt Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be better written as (((b[6] << 8 ) | b[5]) - 900) * 0.1f;
also above, and note to use | not &

rain_mm = ((b[4] << 8 ) & b[3]) / 10.0f;
temp_F = (((b[6] << 8 ) & b[5]) / 10.0f) - 90;
temp_F = (((b[6] << 8 ) & b[5]) / 10.0f) - 90;

/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "Schou 72543 rain sensor",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model needs to be just "Schou-72543"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @zuckschwerdt for the comments. I seriously appreciate the support!
And I am sorry for the amount of commits. I still did not get the "squish" i think it is called of multiple- to one commit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to help. No need to squash. We'll do it on merge anyway.

…ully tested with the rtl_433_tests/tests/Schou/g*.cu8 files
* model name under r_device section and data_make section aligend to schou_72543
…r schou_72543_rain

Updates
 - schou_72543 is now schou_72543_rain everywhere
 - temp_F has become temperature_F to simplify integration with Home Assistant
 - schou_72543_rain has device number 250 after merging changes from the merbanan/rtl_433 master branch
@36jemini
Copy link
Contributor Author

36jemini commented Nov 7, 2023

Hi @zuckschwerdt,
I have made a few final touches to the code and would consider it done from my side.
I merged in the latest changes from the merbanan/rtl_433 master and have made a final commit.
Can you tell me if i need to do more to get this pull request closed/merged?
BR Jesper

@zuckschwerdt zuckschwerdt merged commit bd452d9 into merbanan:master Nov 8, 2023
5 checks passed
@jsiidorov
Copy link

Hi Jesper & co,

This decoder looks similar to MTX rain gauge sold in Finland by Motonet (Product code: 86-01352) and MarQuant Wireless Rain Gauge (Product code: 014369) sold by JULA AB, Sweden.
A couple suggestions to decoder (End of this comment section):

Rain gauge range 0 .. 9999mm. (Display range)
Temperature range -40 .. 70C (-40 ..158F)

When running MTX device: rtl_433.exe -X n=MTX_RAIN,m=OOK_PWM,s=992,l=2696,r=2684,g=0,t=0,y=7088,bits=65,rows=3,repeats=2

Modulation: OOK_PWM
Short pulse: 992
Long pulse: 2696
Reset: 2684
gap: 0
Tolerance: 0
Sync: 7088
Rows: 3
Repeats: 2

Sample Data:

time : 2023-11-25 15:16:22
model : MTX_RAIN count : 2 num_rows : 3
rows :
len : 65 data : 3fcd0ef8ff0a041f0,
len : 65 data : 3fcd0ef8ff0a041f0,
len : 71 data : 3fcd0ef8ff0a041f02
codes : {65}3fcd0ef8ff0a041f0, {65}3fcd0ef8ff0a041f0, {71}3fcd0ef8ff0a041f02

Rain count is starting at power up as described from fff6, it is rotated to 0000 after ffff

  1. Rain count is 0.108 mm / each gauge flip (instead of 0.1mm) according to my tests - can this be changed?
  2. Now decoder is returning temperature in Fahrenheits and rain in mm. Could temperature to be reported in Celsius to be consistent? (Just change temperature_F to temperature_C and add - 32 / 1.8 to end.

Thanks

@zuckschwerdt
Copy link
Collaborator

  1. Rain count is 0.108 mm / each gauge flip (instead of 0.1mm) according to my tests - can this be changed?

You can change that in the code and recompile. https://github.com/merbanan/rtl_433/blob/master/src/devices/schou_72543_rain.c#L80
We don't offer "calibration", maybe you can use a bridge, see https://github.com/merbanan/rtl_433/tree/master/examples

  1. Now decoder is returning temperature in Fahrenheits and rain in mm. Could temperature to be reported in Celsius

Use -C si or convert si in a conf file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants