NodeMCU V3 and DS18B20

Hello everyone,

Just need to ask a simple question as i am not very familiar with electronics. I would like to build a Temperature sensor for my aquarium and integrated it with Home Assistant. I have found this link that looks promising that uses a NodeMCU V3 and a DS18B20 sensor and ESP Home integration. The only difference is that i am planning to use this sensor

My question is, why do we need a resistor between the power and the data? Also, does it have to be a 4.7K or it can be as well a 3.3K? I have a 3.3K available at home from another project but the 4.7K is very difficult to find in my area.

Thanks for your answers
Kind Regards
M

The sensor you linked above is simply a packaged BS18B20 sensor. Therefore, yes, it will work just fine.

The 4.7KOhm resistor is required, and is usually very easy to source. Looks like you could buy a kit of components from the same vendor, that includes some 4.7K resistors for not too much more money. https://techfun.sk/produkt/resistorledcapacitor-kit-plastovy-organizer/

Best of luck with your project!

It will work with a 3.3K pull-up. Particularly if you only have one sensor on the bus. If you have more it might self heat the sensors causing your readings to be very slightly high.

The upper limit

This gives us the upper limit on the resistance that works. It needs to be low enough, given the capacitance of the wires and attached sensors, to bring the voltage on the line high before the host checks the value. For a single device, and a short length of wire, 100k is likely low enough, 50k is low enough for 3 devices and a meter of wire (or thereabouts), or 1 device and 10m of wire. Also, you can cheat and attach a second pin in pull-up mode if you need more power delivery.

This assumes are are running a dedicated power line, using it in parasitic power mode you have to account for the power draw of the device on the other end, which willrequire looking at the applicable data sheets.

The Lower Limit

As for the lower limit, there isn’t one for restoring the high signal, the moment the line is quiet, it’s safe to drive it high. The problem comes if you drive it high while one of the slave devices is trying to “talk”, the amps you put in through your pull-up resistor must be drained by the slave, depending on the internal resistance of the slave while it’s pulling the line low, and its thermal limits, it will either cook the slave, or fail to pull the signal low. Which failure mode you get, and the minimum safe resistance, can usually be be figured out from the slave device’s spec sheet. As a general rule, I usually aim to keep those sorts of components in the <10mA range (assuming they have 0 internal resistance while pulling the line low). This means the minimum resistance you want on your pull-up (assuming 5V drive) is 500Ω. It’s likely reasonably safe to go a bit higher, depending on ambient temperature, and how often the slave “talks”, but for temperature sensors, you will skew your reading if you feed enough current through the sensor that it warms up.

Last reply here: https://electronics.stackexchange.com/questions/62092/1-wire-and-the-resistor

More reading:

https://wp.josh.com/2014/06/23/no-external-pull-up-needed-for-ds18b20-temp-sensor/

https://www.maximintegrated.com/en/design/technical-documents/tutorials/1/148.html

1 Like

Hi Tom,

Thanks for the reply, although i have to admit that i have no idea what the pull-up is, i will give it a try with the 3.3K resistor i already have. Before doing so, i will try to go through the links you shared to educate myself better.

@ ogiewon

Thanks for your reply too i much appreciate it. However, the NodeMCU + DS18B20 costs 7.09€ and the kit on that same vendor costs 11.90€ which for the use of just one resistor (and maybe nothing else from that kit) i consider it too expensive.

The vendor had a box of several resistors that includes the 4.7K for just 2.50€ but is out of stock. I would be willing to pay that if it would be available!

Anyways, thank you all very much

1 Like

Hello,

for providing closure to the question above, i would like to let you know that it works with a 3.3K resistor as well. Already installed in the tank and measuring.

Time to set some alert notifications!!!

1 Like

Hello again,

i am returning back to one of my older posts as i would like to update the sensor i have already built with a fan to cool down the tank during the warmer months or in case of a temperature increase.

Since the fan is going to sit on the aquarium lid, i will need a waterproof fan which usually are 12v. The idea here, is to power both the fan and the nodeMCU ESP8266 from the same 2A, 12v power supply.

My current set up is the following:

But i would like to reach to the below configuration but not using the PID but the DS18B20 probe i already have and use only one fan instead of 2:

Obviously, in the above image, a 12v power supply is used that feeds power to the fans and then it goes to step-down converter outputing 3.3v for the NodeMCU having a common ground.

My questions are:

  1. Where do i connect the 3.3V (which pins) output from the step-down converter on the NodeMCU to power it up? I have exactly the one from the picture above.
  2. Which pin can i use to send the signal to the fan to start?
  3. My code is as follows:
esphome:
  name: "aquarium-temp"

esp8266:
  board: nodemcuv2

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

captive_portal:

dallas:
  pin: D7
    
    
sensor:
  - platform: dallas
    address: 0xd73c01f09631db28
    name: "Aquarium Temperature"

Can anyone help me with the code i need to add so that the fan will turn on above 25.1 degrees Celsius and turn off below 24.9 degrees Celsius?

Thank you very much
Kind Regards
M

Ok, i think i solved my first question. The difference is that on my setup, i have an ESP8266 and the on the other picture its and ESP32. So according to the picture below i should:

  1. Step-down from 12V to approx 9V and plug it on VIN and Ground (right side top pins on the above picture). This will provide power to the NodeMCU without the USB.
  2. The DS18B20 can stay as is with its positive on a 3.3c pin and negative on a ground. D7 can remain for data.

Remaining to be solved:

  1. Where do i connect the data cable for the fan.
  2. The code used in addition to what i have already

If all the above is correct, it should work, if not, then it will be a nice boom in the house! :slight_smile: