The below diagram works, but I’d like to take the breadboard of out the equation. I just dont know how I would wire direcectly from sensor to the d1 mini without the breadboard.
I know I can just connect the ground wire from the sensor directly to G terminal on the d1 mini. But Im not sure about the 5V and D4 terminals.
Not as important, but why is the resistor neccessary?
Looks like it’s a 4K7 pullup resistor for pin D4.
Even though you could define D4 as using its built-in pullup, the sensor itself may need more bias than that pullup can supply.
Can you provide the part # for that sensor - it’s hard to read in the image.
Sensor Red to 5v on the ESP
Sensor Black to Gnd on the ESP
Sensor yellow to yellow to D4 on the ESP
Resistor as you have it here, between red and yellow
It looks like that, and the comment below it says it’s for “parasite mode” but your breadboard was not wired in that mode. So you’ll want to replicate what your breadboard wiring was doing.
I have edited my comment above - it now lists what should go to what.
Yes the Dallas sensor has two ways of wiring and parasite mode means VCC and gnd is connected to gnd.
Data is connected to a 5 volt supply with a resistor in series.
Exactly as you painted Jim.
Perhaps your model is different, but the one I got had parasite mode as the recommend wiring.
If the wiring you originally posted works, then use that.
I don’t know enough to recommend one over the other.
I don’t have a link for those Jim, I just managed to find an image from a local store.
But you can probably solder it just fine also.
The resistor doesn’t know if it’s on one end or the other.
So if you put the resistor on the ESP between 5 volt and the pin or at the sensor side probably doesn’t matter.
From the Dallas sensors datasheet about parasite mode:
electrically it makes no difference, as long as the things it connects to are D4 and 5v. Whether that’s at the board, or on the wires downstream, it’s the same result.
I would advise against using parasitic mode with an ESP, unless you really really only have 2 wires available. If you have 3, run the sensor in normal power mode instead. It’s going to be more reliable and avoid weird hard to find bugs that only happen sometimes.
Why ? because the ESP does not have the circuitry normally required to make this mode work reliably (which is described in the last part of the specs Hellis81 posted above) and to supply enough power to the sensor in certain operation modes. It can be made to work with an ESP (by switching the gpio to output as a kind of improvised power source just before the sensor does the operation and back when it’s done), but thats very hackish and can make the sensor unreliable when longer cables are used, when your solder joints aren’t that perfect or it may not work on another ESP board or gpio pin (because internal pullups or tolerances are different).
If it was me (and I do this too) I would try to get a bit less hacky and use real solder connections where feasible or more robust terminals where necessary.
for the mounting base I use perf board. it comes in many different sizes and you can get a multi-pack on Amazon.
You will use screw terminals soldered to the perfboard to connect the sensor and resistor combination.
the esp module will use the male-female header strip to connect to the perfboard. The ESP literally just plugs in to the header.
that way any of the devices that might fail will be very easily replaceable without de-soldering.
Then just solder small wires to the pins that poke thru the underside of the perfboard to make the various connections.
here is a kit that should have everything you need:
and you will have extras for the next project too.
Just make sure your perfboard is big enough to span the length and width of your ESP module.
Here is how I made mine for the exact device you are using (a DS18B20) for my fish tank temperature.
then I just put the electronics portion you see inside a case and it’s protected a bit.
interestingly if the place where you have it is out of sight I’ve found that the ~$1 plastic soap boxes from Walmart work pretty well to house things and they are easy to get and dirt cheap.
And if you need something a bit more classy and/or durable Amazon has some waterproof plastic project boxes available.
I just said solder joints would be more robust where they can be made and then as a second choice would be screw terminals for better mechanical connections.
Less robust terminations are headers to plug things into. But they are useful for easily removing and replacing parts that might fail or in the case of an ESP where they can be removed to be reprogrammed later if necessary.
breadboards and dupont cables will usually be the least robust in terms of durability. If durability is the goal then it’s probably best to not use them.
I’ve never seen any industry that relies on electronics to use breadboards and dupont cables for constructing their equipment.
And no I’m not saying we should adhere to industrial practices but if they worked as well as other connection types then they would use them since they are likely WAY cheaper to make.
That said I still have a couple of device builds where in the beginning I used breadboards and dupont cables for connections. They still work so will likely stay that way until they fail then I’ll rebuild using solder/screw connections.
Yeah it’s also kind of a natural progression in your electronics tinkerer and maker career. You start with breadboards, dupont cables and preassembled modules, then learn proper soldering and move on to project boards like the ones you linked to and eventually end with designing your own multilayer PCBs full of SMD components soldered in your professional DIY reflow oven (formerly pizza oven in a previous life)