I am planning to use several Dallas temp sensors with ESPhome to monitor a hydronic radiant heat system. The instructions call for a 4.7K resistor between the data and 3.3v wire. Can someone explain to me why that is needed? I tested with and without the resistor and did not get a noticeably different temperature reading.
A resistor limits the amount of power that can flow through it. In this scenario it’s used as a power injection for the data line. It amplifies the signal by sending a small amount of power to that pin. It helps ensure a strong signal.
Thanks! So, it’s not about the accuracy but more about reliability?
Your question inspired me to lookup the datasheet for the dallas sensor.
So it looks like for the sensor to work at all it does need a pullup resistor in order for the sensor to communicate with the MCU. At times the bus master pulls data wire low and the rest of the time the resistor pulls it high. If yours works well without the resistor I suspect your setup is a module with 4.7komh already in place.
There is also a parasitic mode for this sensor where it uses voltage supplied by pullup resistor for it’s power.
It uses a tristate open drain bus, so a weak pullup is always required because the leakage current of a high impedance GPIO configured as input is not enough when the bus is in read mode. That’s pretty typical of open drain outputs.
That mode looks complicated to manage, as the MCU needs to switch from weak to strong pullup depending on what the sensor is doing, so that it gets enough power when doing power hungry operations. Which needs special firmware support and an additional mosfet on the data line. Better to supply VDD directly.
Thankfully you didn’t, that would indicate a serious hardware failure It’s all digital, the temperature is sent with lots of 0’s and 1’s. It’s not analog, so the resistor will not change the data. If it’s too big (or absent), the reading may become unreliable (intermittent or no communication), because the MCU will have trouble talking to the sensor.
My understanding is power injection makes the sensor more reliable, in the sense that it reduces the chance of error. Having power on the data line ensures that the line is pulled high as fast as possible.
Depending how long the signal is pulled low determines whether it’s a 1 or 0. If it lags slightly (fractions of a second) it won’t return a value.
In a way that’s correct. But the delay is not something that is intentional. It’s mostly due to parasitic capacitance of the (long) cables. Look up open drain circuits. On the most basic level, an open drain circuit has a mosfet that connects to ground. When the sensor wants to transmit data, it opens and closes the mosfet, which connects the data line to ground or to nothing (it floats in a high impedance state). Like an open or closed switch to ground. When the mosfet is open, the data output literally floats, it behaves as if it’s not connected to anything. And not connected means no closed circuit, no electron flow, no signal flow. The pullup is used to close the circuit to VDD in that case.
That high impedance state is very important for busses, where multiple devices talk to each other on the same signal line and must not interfere with each other. It’s also important in low power devices, as an open drain doesn’t have any leakage current (or a very very low one).
Now the entire scenario is made more complex with cables that act as a capacitors. When the device changes state, it will first have to charge / discharge the ‘cable capacitor’ before the signal reaches the MCU or vice-versa. In extreme cases this can mess up signal timing, especially at high frequencies. A stronger pullup will counter this effect, as more current flows and the filling of the parasitic capacitance is faster.
That depends on the protocol. Most simple protocols will just use the voltage level on the line. Relying on signal lengths is very inaccurate, unless you have a separate clock signal to sync all devices connected to the bus (like SPI or I2C have). Without a clock line, you’ll be limited to rather low data speeds (which in the case of a simple device like a thermometer is not a big deal).
Wow. I came in looking for a short lesson and left with a master’s degree. Thanks, everyone!