How i installed it before below wasn't reliable, it stopped working after around a year, so I went a slightly different route.
Bought a DS18B20 from ebay, stainless steel one, see it in the picture below. Search for "waterproof ds18b20"
The top of the picture shows the adapter I bought to install the ds18b20.
The stainless steel probe goes into the adapter, but won't make it all the way through.
The tricky part is that I had to drill out the threaded end of the adapter. Only drill out the part that is threaded, stopping before you hit the middle section.
Used a 1/4" drill bit. I have a drill press, and a used a vice to hold the adapter in place while I drilled. Then I manually turned the bit by hand to do the final little bit, I didn't want to go in too far and damage the rubber gasket.
Drill until you can push the probe into the adapter and the metal comes out the other end.
There are three wires to connect, red for +3.3V, black for ground and yellow for signal.
To tap out the hole in the pool pipe, I used a Vermont American model number 20371, Hand Tap, Pipe, 1/8-27, NPT. Should install to the heater inlet pipe.
It needs a 11/32" size drill bit. If you are not used to taping holes, get a piece of scrap pipe, and practice first. Google to buy, link I used is dead. You also need a tap holder or use a wrench to turn the tap. Plastic is soft, so easy to tap.
Screw the sensor into the hole, and then I used a hose clamp to hole the conduit to the sensor/adapter.
WIRING IT UP
Look here for how the pins should be connected, and esp easy setup: Setup Info
Connect as follows:
Ground to Ground, (black wire)
3.3 VDC to VDD (red wire) and a GPIO pin to D (yellow wire) on the DS18B20
I soldered the wires, and a 4.7k pullup resistor between red and yellow wires on the DS18B20.
SETUP IN ESP EASY
I connected this to my ESP setup, then setup ESP Easy with their web interface.
At first it didn't work, got NAN on screen instead of a temperature. Found out NAN stands for Not a Number.
Had to delete the temp sensor by setting device to "blank" (top of the pick list), saving that, and then picking DS18b20 again.
When I did it the 2nd time, it worked fine.
Settings are as shown above.
Note that later I deleted the formula temperature box information. I have Domoticz perform the conversion, so the data is sent from here in C, and Domoticz converts to F.
Original method (not recommended to epoxy the sensor like I did here, it failed after a while, the sensor used above is better)
For the temperature sensor, I had a choice between using a DS18B20 or a 10k thermistor. The advantage of the thermistor is that you can get them ready to install in a pipe, like a Pentair PN 520272. The DS18B20 has built in support in ESP Easy, so its easy to make it work once you get it installed.
At first I was going to use a thermistor, but then changed my mind and went with a DS18B20.
Bought the part from Mouser
The DS is in a to-92 package with 3 pins that is 0.175" wide
I had something similar to this in my plumbing drawer, the DS just fits inside of it.
I cut out/removed the push to connect end of it. It was a little small, so I took a drill bit, and hand twisted it inside the fitting to remove some rubber and make it a little larger inside. After this, I was able to insert the DS18B20 inside the fitting, all the way through it.
Wire it up per the instructions below, and make sure it works. Then epoxy it in place. Put epoxy all around it, to make sure it won't get wet after installation. I also made a hole in a scrap piece of pipe, and inserted into the hole to make sure the epoxy didn't get into the threads. I put a thin layer of epoxy over the top of the 18b20, enough to protect it, but you want it to see the temp changes, so don't make it a thick layer that would insulate the sensor from the water temp.
EDIT: I just installed the 2nd one I built (for the pool) , and the temps swing too much. Get high during the day, and low at night. After thinking about it, I figured I put too much epoxy on this one, and its too insulated from the water. So its measuring the pipe temp more than the water temp. Pipe gets mid day sun, so heats up during the day and cools off at night. Water will also heat up during the day, but not very much as its a 20,000 gal pool. I see swings from over 90 to 65 in one day.
I was going to make another one, but then I came up with an idea to take this one out, file off some epoxy until I get to the sensor, hopefully keeping the seal intact.
If I don't update this again, I successfully removed, filed, reinstalled, and got temperature readings that make sense.
2nd EDIT: So I filed off the epoxy until I reached the top of the temp sensor, and its better now, its closer but still not perfect. Just took a few secs to file it down.
trimming-down-dallas-ds18b20s Found this page, so I will file some more down, so the top plastic from the body is gone, so then it will be much closer to the water, and react better to the water temp
I will also screw the sensor farther into the hole, so it reaches further into the water stream, and away from the pipe.
Let the epoxy dry, I gave it overnight. I cut a piece of watertight conduit to the correct length, and then inserted the sensor into the end, and pushed the wire through the conduit.