Pull-up power is not as magic as it sounds. Here's a
really simplified description:
- The controller is told to read the digital pin. It will either be "high" (~3v3) or "low" (0V). In reality, the voltages are slightly different but let's use these for the sake of argument
- The sensor will send its data digitally through a series of 1's (low) or 0's (high)
- Having said that, the sensor doesn't actually "send" data, it effectively grounds out the data line making the detected value 0V
Q: What's the value of the data pin when the sensor is not "grounding" it?
A: It could be anything. With (almost) no load on that line, the controller can see it high, low, or warbling in between. I've seen 200+ volts "indicated" on a bare wire laying on my desk. Touch it and it will not shock you of course, but referenced to earth, it could be a lot higher than you think.
This is why we need the pull-up; to provide a definite referenceable voltage.
- A pull-up is like a hose, filling a bucket of water. It "pulls up" the line, imagine that as filling a bucket
- The sensor will empty that bucket (set the line low) to send data
- The hose is not big enough (pull-up is not strong enough) to keep the bucket filled when the sensor is emptying it, so the value is read as 0
- When the sensor is not emptying the bucket, it needs to fill up fast enough so we will see it as high nearly immediately
The pull-up values are chosen based on the data device (the DS18B20 in this case) and its capabilities. The 4K7 for 5V0 lines and 2K2 for 3V3 lines are not magical, and sometimes you need a stronger pull-up (bigger hose) to get the value up cleanly/fast enough. When we say a "stronger pull-up" we mean a lower resistance which allows more current to pass.
So, when people are having issues, a stronger pull-up is sometimes the answer.