Sonoff mini and DS18b20

1,315 views
Skip to first unread message

gl alone

unread,
Jan 2, 2022, 7:15:57 PM1/2/22
to TasmotaUsers
I'm trying to connect a ds18b20 to a sonoff mini (fw tasmota.bin 8.3.1)...without success: I'm able to read the temperature but
1) it's way too high (in house temperature around 100° C while should be around 22° C)
2) it's not stable: it quickly fluctuates between 95° and 104° C

What I did
wiring is done in parasite mode: gnd and vcc on S1 and data on S2
sonoff mini as base for the configuration template with GPIO4 DS18x20 (4) and ADC0 (FLAG)= 2 (temperature)
configuration module as in picture

What is wrong ?

 
module parameters.pngtemplate.png

Philip Knowles

unread,
Jan 2, 2022, 10:39:20 PM1/2/22
to gl alone, TasmotaUsers
DS18B20s give a high reading when the connection is poor. Do you have a pullup resistor?

Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of gl alone <gianluca...@gmail.com>
Sent: Monday, January 3, 2022 12:15:57 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Sonoff mini and DS18b20
 
--
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/aa84381b-357d-4b5d-89fd-c9156d6f6735n%40googlegroups.com.

Philip Knowles

unread,
Jan 2, 2022, 10:42:37 PM1/2/22
to gl alone, TasmotaUsers
BTW ADC0 Temperature is for when you are measuring a temperature on the Analogue input
From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 3:39:15 AM
To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20
 

Philip Knowles

unread,
Jan 2, 2022, 10:48:23 PM1/2/22
to gl alone, TasmotaUsers
From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 3:42:32 AM

gl alone

unread,
Jan 3, 2022, 1:14:40 AM1/3/22
to TasmotaUsers
Thanks for your prompt reply. Back to your questions/suggestions:
I do not have a pullup resistor as I've read that it's mandatory only in case of multiple da18b20. Am I wrong ?
If I don't set ADC0 to 2 (temperature) I don't see any temperature at all

Philip Knowles

unread,
Jan 3, 2022, 2:27:58 AM1/3/22
to gl alone, TasmotaUsers
Can you attach a screenshot of the UI I suspect the reading you are seeing is the voltage on the ADC. If you read the page it tells you that you need to use a SetOption to bring in the internal pull up.

Regards

Phil K


Sent: Monday, January 3, 2022 6:14:40 AM
To: TasmotaUsers <sonof...@googlegroups.com>

gl alone

unread,
Jan 3, 2022, 2:51:36 AM1/3/22
to TasmotaUsers
I knew the SetOption74 command and I used it; unfortunately it doesn't change anything. B.T.W. I said something wrong: ADCO = 2 is not the only way to read the temperature: I attach per your request the UI with  SetOption74 ON and ADCO = 0
NB I really appreciate your efforts !

main.png

Philip Knowles

unread,
Jan 3, 2022, 3:23:25 AM1/3/22
to gl alone, TasmotaUsers
That is from the ADC not the DS18B20. It would be prefixed by DS18B20 if it was the sensor. Need to check your wiring and the page I sent
Sent: Monday, January 3, 2022 7:51:36 AM

Philip Knowles

unread,
Jan 3, 2022, 3:36:45 AM1/3/22
to gl alone, TasmotaUsers
BTW I'm not sure whether parasitic mode has been implemented on Tasmota yet so may be worth trying with a 3 wire connection 
From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 8:23:20 AM

gl alone

unread,
Jan 3, 2022, 8:15:32 AM1/3/22
to TasmotaUsers
I'm quite sure parasite mode has been implemented in Tasmota but yes, you've totally right: temperature doesn't come from DS18B20. It seems that the sensor is not seen by the sonoff mini: if I use as a base for the template "sonoff TH (4)" and I go to the "configure module" , sensor DS18B20 doesn't show up in GPIO4 and even if I select it from the drop down list, it's not retained.

I don't know how to proceed... 

Philip Knowles

unread,
Jan 3, 2022, 9:34:36 AM1/3/22
to gl alone, TasmotaUsers

Well there’s no mention of parasitic mode in the release notes back to V8.4. It is implemented in Arduino but that doesn’t mean it works in Tasmota.

 

If you have a Template activated it can cause issues with what you are able to select. Deactivate any Template you have, go to Configuration>Configure Module and select Generic. After it reboots select the D18x20 against GPIO4 and connect the DS18B20 in the normal 3 connections mode – it may work without a pullup if the cable is short.

 

If it doesn’t appear try the SetOption to see if that helps.

 

One you have it working with conventional wiring you can then try parasitic mode.

 

Regards

 

Phil K

 

 

 

Sent from Mail for Windows

 

From: gl alone
Sent: 03 January 2022 13:15
To: TasmotaUsers
Subject: Re: Sonoff mini and DS18b20

 

I'm quite sure parasite mode has been implemented in Tasmota but yes, you've totally right: temperature doesn't come from DS18B20. It seems that the sensor is not seen by the sonoff mini: if I use as a base for the template "sonoff TH (4)" and I go to the "configure module" , sensor DS18B20 doesn't show up in GPIO4 and even if I select it from the drop down list, it's not retained.

 

I don't know how to proceed... 

 

Il giorno lunedì 3 gennaio 2022 alle 09:36:45 UTC+1 knowles...@gmail.com ha scritto:

BTW I'm not sure whether parasitic mode has been implemented on Tasmota yet so may be worth trying with a 3 wire connection 

From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 8:23:20 AM


To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20

That is from the ADC not the DS18B20. It would be prefixed by DS18B20 if it was the sensor. Need to check your wiring and the page I sent

 

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of gl alone <gianluca...@gmail.com>
Sent: Monday, January 3, 2022 7:51:36 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20

 

I knew the SetOption74 command and I used it; unfortunately it doesn't change anything. B.T.W. I said something wrong: ADCO = 2 is not the only way to read the temperature: I attach per your request the UI with  SetOption74 ON and ADCO = 0

NB I really appreciate your efforts !

 

 

Il giorno lunedì 3 gennaio 2022 alle 08:27:58 UTC+1 knowles...@gmail.com ha scritto:

Can you attach a screenshot of the UI I suspect the reading you are seeing is the voltage on the ADC. If you read the page it tells you that you need to use a SetOption to bring in the internal pull up.

 

Regards

 

Phil K

 

Sent: Monday, January 3, 2022 6:14:40 AM
To: TasmotaUsers <sonof...@googlegroups.com>


Subject: Re: Sonoff mini and DS18b20

Thanks for your prompt reply. Back to your questions/suggestions:

I do not have a pullup resistor as I've read that it's mandatory only in case of multiple da18b20. Am I wrong ?

If I don't set ADC0 to 2 (temperature) I don't see any temperature at all

 

Il giorno lunedì 3 gennaio 2022 alle 04:48:23 UTC+1 knowles...@gmail.com ha scritto:

From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 3:42:32 AM


To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20

BTW ADC0 Temperature is for when you are measuring a temperature on the Analogue input

 

From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 3:39:15 AM
To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20

 

DS18B20s give a high reading when the connection is poor. Do you have a pullup resistor?

 

Regards

 

Phil K

 

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of gl alone <gianluca...@gmail.com>
Sent: Monday, January 3, 2022 12:15:57 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Sonoff mini and DS18b20

 

I'm trying to connect a ds18b20 to a sonoff mini (fw tasmota.bin 8.3.1)...without success: I'm able to read the temperature but
1) it's way too high (in house temperature around 100° C while should be around 22° C)
2) it's not stable: it quickly fluctuates between 95° and 104° C

What I did
wiring is done in parasite mode: gnd and vcc on S1 and data on S2
sonoff mini as base for the configuration template with GPIO4 DS18x20 (4) and ADC0 (FLAG)= 2 (temperature)

configuration module as in picture

 

What is wrong ?


 

--
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/aa84381b-357d-4b5d-89fd-c9156d6f6735n%40googlegroups.com.

--
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.

--
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/e80bac3d-8555-4ec5-b729-d306812133fcn%40googlegroups.com.

--
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.

AKS-Gmail-IMAP

unread,
Jan 3, 2022, 5:25:47 PM1/3/22
to TasmotaUsers
I currently have three of these DS18b20s running on NodeMCUs wired using the three wire fashion with the pull-up resistor as described in documentation. They work just fine. 

I discovered the hard way, which might be what Phil alludes to with "If you have a Template activated it can cause issues with what you are able to select., that you can break the ESP and Tasmota when experimenting with various additional config settings you add to an existing config. This was a NodeMCU already setup and running a connected DS18b20 to which I was adding an ADC voltage input on GPIO17 that was from a photocoupler in a divider circuit. The problem occurred when I attempted to see what each GPI017 selection (v9.5.0.8) did to how the ADC value gets reported. On one selection, which one I do not remember, the NodeMCU very unexpectedly failed to restart. It was dead in the water. I had to reflash it.  

On Jan 3, 2022, at 8:34 AM, Philip Knowles <knowles...@gmail.com> wrote:

Well there’s no mention of parasitic mode in the release notes back to V8.4. It is implemented in Arduino but that doesn’t mean it works in Tasmota.
 
If you have a Template activated it can cause issues with what you are able to select. Deactivate any Template you have, go to Configuration>Configure Module and select Generic. After it reboots select the D18x20 against GPIO4 and connect the DS18B20 in the normal 3 connections mode – it may work without a pullup if the cable is short. 
 
If it doesn’t appear try the SetOption to see if that helps.
 
One you have it working with conventional wiring you can then try parasitic mode.
 
Regards
 
Phil K
 
 
 
Sent from Mail for Windows
 
From: gl alone
Sent: 03 January 2022 13:15
To: TasmotaUsers
Subject: Re: Sonoff mini and DS18b20
 
I'm quite sure parasite mode has been implemented in Tasmota but yes, you've totally right: temperature doesn't come from DS18B20. It seems that the sensor is not seen by the sonoff mini: if I use as a base for the template "sonoff TH (4)" and I go to the "configure module" , sensor DS18B20 doesn't show up in GPIO4 and even if I select it from the drop down list, it's not retained. 
 
I don't know how to proceed...  
 
Il giorno lunedì 3 gennaio 2022 alle 09:36:45 UTC+1 knowles...@gmail.com ha scritto:
BTW I'm not sure whether parasitic mode has been implemented on Tasmota yet so may be worth trying with a 3 wire connection  
 
<23E17C7FAE6F4596AA97C45C5D36555C.png>
From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 8:23:20 AM

To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20
That is from the ADC not the DS18B20. It would be prefixed by DS18B20 if it was the sensor. Need to check your wiring and the page I sent 
 
<23E17C7FAE6F4596AA97C45C5D36555C.png>
From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of gl alone <gianluca...@gmail.com>
Sent: Monday, January 3, 2022 7:51:36 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20

 

I knew the SetOption74 command and I used it; unfortunately it doesn't change anything. B.T.W. I said something wrong: ADCO = 2 is not the only way to read the temperature: I attach per your request the UI with  SetOption74 ON and ADCO = 0
NB I really appreciate your efforts ! 
 
 
Il giorno lunedì 3 gennaio 2022 alle 08:27:58 UTC+1 knowles...@gmail.com ha scritto:
Can you attach a screenshot of the UI I suspect the reading you are seeing is the voltage on the ADC. If you read the page it tells you that you need to use a SetOption to bring in the internal pull up.
 
Regards
 
Phil K
 
<6DACA2AD26F547B8834DAAB4F233919A.png>
From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of gl alone <gianluca...@gmail.com>
Sent: Monday, January 3, 2022 6:14:40 AM
To: TasmotaUsers <sonof...@googlegroups.com>

Subject: Re: Sonoff mini and DS18b20
Thanks for your prompt reply. Back to your questions/suggestions: 
I do not have a pullup resistor as I've read that it's mandatory only in case of multiple da18b20. Am I wrong ?
If I don't set ADC0 to 2 (temperature) I don't see any temperature at all
 
Il giorno lunedì 3 gennaio 2022 alle 04:48:23 UTC+1 knowles...@gmail.com ha scritto:
 
<5BAF5FA5DC634C2A864AC6323A3AF6C4.png>
From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 3:42:32 AM

To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20
BTW ADC0 Temperature is for when you are measuring a temperature on the Analogue input 
 
<5BAF5FA5DC634C2A864AC6323A3AF6C4.png>
From: Philip Knowles <knowles...@gmail.com>
Sent: Monday, January 3, 2022 3:39:15 AM
To: gl alone <gianluca...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Sonoff mini and DS18b20

 

DS18B20s give a high reading when the connection is poor. Do you have a pullup resistor?
 
Regards
 
Phil K
 
<68E1E394BE6149A8AA7862742982F177.png>

Eric Jansen

unread,
Feb 19, 2022, 3:22:46 PM2/19/22
to TasmotaUsers
Tasmota supports onewire parasite mode for the  DS18b20  ,  use the following template for the sonoff mini:
{"NAME":"Sonoff Mini","GPIO":[32,0,0,0,1,0,0,0,224,320,0,0,1,0],"FLAG":0,"BASE":1}
GPIO4 (external swich connection on the sonoff mini) already has internal pullup enabled, connect the DS18b20 in parasite mode to the 2 black terminals.
Under Tasmota 'Configure Model' assign GPO4 as 'DS18x20'
sm.jpg

Philip Knowles

unread,
Feb 20, 2022, 2:58:37 AM2/20/22
to Eric Jansen, TasmotaUsers

Yes, but the point was that it wasn’t working. I said get it working in the ‘normal’ mode before trying parasitic. It’s best to try to fix one thing at a time.

 

Sent from Mail for Windows

 

From: Eric Jansen
Sent: 19 February 2022 20:22
To: TasmotaUsers
Subject: Re: Sonoff mini and DS18b20

 

Tasmota supports onewire parasite mode for the  DS18b20  ,  use the following template for the sonoff mini:


{"NAME":"Sonoff Mini","GPIO":[32,0,0,0,1,0,0,0,224,320,0,0,1,0],"FLAG":0,"BASE":1}
GPIO4 (external swich connection on the sonoff mini) already has internal pullup enabled, connect the DS18b20 in parasite mode to the 2 black terminals.
Under Tasmota 'Configure Model' assign GPO4 as 'DS18x20'

gl alone

unread,
Feb 20, 2022, 1:46:52 PM2/20/22
to TasmotaUsers
Eric, thanks a lot for your help. Although sonoff mini does support parasite mode with DS18B20 what Phil says is correct: I have not been able to have it working. The approach Phil was suggesting (use it in normal mode) makes sense but is against what I was looking for: a simple solution without the need of a hardware mod. For this reason I gave up.

I also read somewhere that there are a lot of fake DS18B20 sensors and many of them don't support parasite mode, may be I have one of them. Thanks anyhow for your support, I really appreciated it !

Eric Jansen

unread,
Feb 24, 2022, 6:56:58 PM2/24/22
to TasmotaUsers
I used the Arduino sketch as instructed here:  cpetrich/counterfeit_DS18B20: How to tell original from fake DS18B20 temperature sensors. (github.com)
This is great to check for 'fake' ds18b20 units, even most fakes do read temperature ok, indeed as you mentioned, not all fakes support parasite mode. 
I use the sonof minis installed inside my wall sockets and used hot melt glue to attach a ds18b20 sensor to the back of the faceplates, this gives me a safe and very accurate and reliable (+2 years) room thermostat in each of my appartment's rooms. The temperature readings are used to calibrate my Tuya zigbee radiator valves and I have one ds18b20 reading outside temperature to adjust my boiler water temperature automatically, ie weather compensation.
Shame you had to give up, as the sonof mini is easy to hide inside a wall socket and using gpio4 and gnd (S1, S2) is safe as all other sonof mini ground points are connected to mains supplied ground.

Good luck.

Reply all
Reply to author
Forward
0 new messages