-->
Page 1 of 1

Can I use pin D4 as input for DS18B20 temperature shield?

PostPosted: Wed Oct 30, 2019 3:50 pm
by HobbyDev
I am combining some shield to control the temperature in a room with a WEMOS D1 mini pro (V1.0.0). Since I want to be independant from external time stamps I want to use a real time clock. The shield I am using is a combination of RTC and SD-Card. This shield is using the most of the available pins, even pin D2 which is normaly used for DS18B20 sensor. So it turns out that only pin D3 and D4 are still open to use. On D3 I connected the relay shield already so pin D4 is the last one I can use - I thought. Everthing is solderd so far :( But now I red in https://https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ that pin D4 is pulled up and I don't know what this means in my case. Can I still use it for temperature input or not? Is it only pulled up (to 5V I think) during boot phase or will it stay that way?

Thank you in advanced!

Re: Can I use pin D4 as input for DS18B20 temperature shield

PostPosted: Thu Oct 31, 2019 5:10 pm
by btidey
D4 on a NodeMCU is GPIO2. This pin must be sensed as a high during boot. The NodeMCU has a 12K pull up to the 3.3V supply to ensure this.

This is NOT in conflict with using D4 (GPIO2) as means of driving a DS18B20 sensor which can be run from any of the GPIO pins. The sensor should be run from the 3.3V supply to be consistent with the logoc levels of the ESP8266. Normally the signal wire of the DS18B20 would be pulled up to the supply (3.3V) via something like a 4k7 resistor. The value is not critical so you could still use a 4k7 or you could increase it a bit to say 6k8 as it is in parallel with the on-board 12K.

Re: Can I use pin D4 as input for DS18B20 temperature shield

PostPosted: Sat Nov 02, 2019 10:17 am
by HobbyDev
Surry about for answering that late but I was off for the last days. Thank you very much for your answer!
So comming back to the power supply. I connected a 230->5V power supply from Hi-Link (hlk pm01) to the 5V Pin at the WEMOS Modul. The DS18B20 Shield normally connects at 5V, too. And the 4,7k Resistor is already on board. Shall I run a wire from the 3.3V Pin at the WEMOS shield to the 5V Pin at the DS18B20 shield?

Re: Can I use pin D4 as input for DS18B20 temperature shield

PostPosted: Sun Nov 03, 2019 7:40 am
by btidey
I am not familiar with the shield version of the ds18b20 as I just use the TO-92 raw versions myself.

However, you should not just connect the 3.3V to the 5V on the shield as yyyyyyyou would likely just short things out.

If the shield is running the ds18b20 from 5V that is not good as it means the signal level going into the esp8266 is 5v rather than 3.3V.

I would check the shield and if the 5V is going to the supply pin of the ds18b20 and is pulling up the signal pin to 5V as well then I would cut the trace to the 5V connection on the shield and then jumper the 3.3V pin on the shield to the now isolated side of that trace.