Rule trigger problem for DS18B20 temperature sensor

42 views
Skip to first unread message

Rod Nussbaumer

unread,
Apr 20, 2024, 4:08:48 PMApr 20
to TasmotaUsers
Hi All.

I'm trying to get a rule to trigger on a DS18B20 reading update. As much as I can tell, I'm using the same code as the example given in the documentation. I'm trying to publish the new data to a specific MQTT topic, using a JSON formatted payload.

Rule1
    ON System#Init DO Var1 0.00 ENDON
    ON DS1820#Temperature!=%Var1% DO backlog
        publish RN_IOT_DAQ/D1Mini {"Temperature":%value%} ;
        Var1 %value%
    ENDON

The sensor works fine, and I get MQTT #/SENSOR publications on my MQTT broker. The published temperature values are realistic and I feel 100% confident that there are no problems with the sensor or wiring. I'm using a 4K7 pullup on the data pin, although it seems to work equally well without it. 

No errors or warnings are printed on the console when I create the rule, and the rule is enabled. I see no evidence whatsoever that the trigger is ocurring.

I'm using a recent version of the sources, built with additions for ESP32 BLE. This problem is ocurring on a Wemos D1Mini.

My best guess is that there is some additional configuration required, but I cannot seem to find anything after considerable searching.

Thanks.
   ---   rod.



Justin Adie

unread,
Apr 21, 2024, 2:29:44 AMApr 21
to Rod Nussbaumer, TasmotaUsers
Could you try adding a "B" between the 18 and the 20 in the rule?




--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/8026ff4b-c6ca-4a22-8a5c-75d5ae189595n%40googlegroups.com.

Philip Knowles

unread,
Apr 21, 2024, 2:39:13 AMApr 21
to Rod Nussbaumer, TasmotaUsers
It looks like you are wanting to publish only if the temperature has changed since the last value. Is that correct?
If so you are better using a 'delta' than an exact value.
There's a golden rule when creating rules. Try each individual command in Console first.
So enter your publish statement and check you see it at the other end.
Create a rule which ONLY changes var1 and check that works (you will see it change in Console).
In this case the trigger is incorrect should be on DS18B20#temperature


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Rod Nussbaumer <then...@gmail.com>
Sent: Saturday, April 20, 2024 9:08:47 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Rule trigger problem for DS18B20 temperature sensor
 

Rod Nussbaumer

unread,
Apr 21, 2024, 11:12:32 AMApr 21
to TasmotaUsers
That has solved it. Is the documentation incorrect, or is the rule sensitive to the actual sensor moought del implemented, or...?
I was following the documentation example, and I thought I had originally used '18B20', but changed it when it didn't work as expected. Must have been multiple errors on my part.

Thanks for your help.
   ---   rod.

Rod Nussbaumer

unread,
Apr 21, 2024, 11:17:08 AMApr 21
to TasmotaUsers
I'm not 100% sure what I need/want. I was simply duplicating what was in the documentation example. Thanks for the tip about deltas, nevertheless. I had followed the method of divide and conquer, testing each component individually. Just needed the correct sensor ID, although I thought I had tried that as well.

Thanks,
   ---   rod.

Philip Knowles

unread,
Apr 21, 2024, 2:04:23 PMApr 21
to Rod Nussbaumer, TasmotaUsers
There's an example in Rules


Sent: 21 April 2024 16:17
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Rule trigger problem for DS18B20 temperature sensor
 

AKS-Gmail-IMAP

unread,
Apr 24, 2024, 3:42:13 PMApr 24
to TasmotaUsers
This is the simple rule I use to show locally that the DS18B20 is working by blinking the power LED. For one, the trigger I use is "ds18B20#temperature”, not “ds1820#temperature”. Second, I wanted the verification to show only when there is a significant temperature change. You will need to compile to have “if” logic. It is worth learning how to do it using the online compiling method. Your publish part looks ok at a glance to me.

Rule1 
on ds18B20#temperature do var1=%value%-var2 endon
on ds18B20#temperature do if ((var1>=0.24) or (var1<=-0.24)) backlog var2=%value%; power1 on; delay 4; power1 off; endif endon


 

Philip Knowles

unread,
Apr 24, 2024, 4:12:05 PMApr 24
to AKS-Gmail-IMAP, TasmotaUsers
You don't need to compile with if. The following example is simplified from the rules page

Rule1
ON DS18B20#temperature>%var1% DO Backlog var1 %value%; publish tele/ds1820/SENSOR {"Temperature":%value%}; var2 %value%; add1 0.5; sub2 0.5 ENDON
ON DS18B20#temperature<%var2% DO Backlog var2 %value%; publish tele/ds1820/SENSOR {"Temperature":%value%}; var1 %value%; add1 0.5; sub2 0.5 ENDON

It moves the delta trigger to +/-0.5 of the last value 

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of AKS-Gmail-IMAP <akse...@gmail.com>
Sent: 20 April 2024 23:23

To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Rule trigger problem for DS18B20 temperature sensor
Reply all
Reply to author
Forward
0 new messages