Wiring temperature sensor resistor in without breadboard

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.

sorry thats just a diagram I followed, that worked. Heres my actual sensor I am using, and wiring on breadboard to match that doc.

I just used one of these but with three “parts”.

image

That way I could just place the resistor between the 5 volt and data screw terminals and then everything is wired correctly.

HeyImAlex wrote a very good post a few days ago why this pull-up is needed.
I can see if I can find the thread.

Edit: Can someone educate me on resistors used on sensors in ESPhome?

Managed to find the an image of the wiring.
You can see the resistor on the left side.

(Note the wiring above is for parasite mode, meaning the VCC is grounded and only the data pin is high)

Got a link to that terminal strip thing?

And so you have the red and black wires from the sensor going to the same terminal, which then conmnects to the browinish wire?

And the yellow wire from sensor going to yellow wire.

And theres nothing on the other end of the red wire?

Like below?
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

But look at his pictures, it looks like red and black coming from the sensor go to the same ‘terminal’

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:

So could I place the resistor directly on the d1 mini between 5v and D4 terminals?

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).

2 Likes

I use this:

s-l400

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.

Mine is using an ESP8266 but you get the idea.

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.

1 Like

got a link?

All solutions are valid

1 Like

I don’t recall saying they weren’t valid. :man_shrugging:

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. :wink:

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.

and don’t forget that the OP said:

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) :grin:

1 Like

connectors are notoriously among, if not the top reason for system failures.

1 Like