Connecting PIR sensor to ESP32 over distance

Hi, I'm planning out an LED strip to illuminate the length of my staircase. It'll be triggered by a PIR sensor at either end of the stairs, and be controlled by an ESP32 on a PCB with some MOSFETs etc that will have the LED strip come on in different colours and brightnesses depending on the time of day. The ESP will be mounted at the top of the stairs as there's a power socket nearby that I can power it from.

I'm mostly planning to use male pin headers on the PCB and Dupont (female to female) jumper wires to connect the PIR sensors to the PCB headers. However, it's just occurred to me that doing it this way will involve a fairly long wire run, around 5m, between the ESP32 and the sensor at the bottom of the stairs.

Two questions:

  1. where can I find dupont cables in >5m length? My brief googling has turned up only the wire with no connectors in any length over 50cm. I could extend the cable by clipping it in two and soldering a long bit of wire between the two parts, but that seems a bit messy.

Other suggestions are welcome.

  1. will there be a significant enough voltage drop between the sensor and the ESP to cause operational issues?

Solder the wires to reduce probability of intermittent connections.

There is loss of power in distance, and long LED strips sometimes need "power injection" at some distance depending on LED density. If needed, run a VDC/GND pair to mid point if LEDs fade.

The question of using very long wires often comes up. Basically what happens with long wires is that the capactance in the wire degrades the signal integrity. It is not much to do with the resistance of the wire (voltage drop) as such.

The real answer is to extend the wires using a differential transmitter and receiver at each end of your cable.

This is a circuit I have used many times for this.

Note that an ESP32 only produces 3V3 signals so these need boosting up to 5V before you stand a chance of anything working.

Welcome to the forum

If your project is going to be installed permanently then do not use Dupont connectors. Solder the wires directly to the Arduino and sensor

1 Like

Use 22–26 AWG wire for long runs and crimp your own Dupont ends, or switch to sturdier connector types like JST or RJ. * Buy a 5–10 meter reel of 22–26 AWG stranded wire (e.g., ribbon cable or individual wires).
Get Dupont connector housings and female crimp pins.
Use a Dupont crimping tool (or a small needle-nose plier, carefully) to make your own custom-length jumper cables.
Recommended for cleaner and modular setups, especially for projects with long-term use. In case you need some help with basic coding of the ESP32 for interfacing PIR, you can see here. Motion Detection with ESP32 & PIR Sensor - The Engineering Projects

PIR sensors like the HC-SR-501 have a 3.3volt output, so a perfect match for an ESP.

No, an ESP input poses no load on the sensor's output signal, so there will be no voltage drop.
A PIR sensor draws almost no current, so any type of (thin) wire will do.
Twisted is preferred, so it will pick up less interference from the environment.
Cat-5 or Cat-6 is cheap and has four twisted pairs.
Leo..

Molex 'K' connectors or JST are secure and easy to make up. I would recommend getting a crimping tool for best results.

CAT 5 cable is cheap and a good source of thin, solid, multi-coloured cores or use low voltage alarm cable if you want a source of thin stranded cores.

Soldering can be an issue, despite additional flux. I think there is contamination or surface oxidation.

Hi! Welcome to the Forum.

Buy a small ESP32 like C3 mini and send the signal of the PIR dowstairs to the board upstairs via ESP-NOW protocol (wi-fi). No wires running.

The bad part of this approach is that you'll have to find something to feed the downstairs circuit. The good part is that the ESP can be put to sleep and be awakened by the PIR. This will keep the current consumption very low and allow it to be battery fed.

1 Like

Maybe because cheap Chinese cable is mostly CCA (copper clad aluminium) or CCS copper clad steel. A magnet will detect the latter.
Leo..

Make your project simpler and more likely to succeed by using ws2812 strips. No MOSFETs required. However, you will need a signal level shifter to increase the 3.3V data signal from the ESP to 5V for the strip. Do not use signal level shifters designed for i2c bus for this purpose, they are too slow. A chip such as 74HC14 or 74HCT14 will be fast enough.

As already mentioned, you won't find them and you should not want to use them anyway. They are for building temporary prototype circuits, not for final, installed projects.

Use multi-core wire such as was used for analog phone extensions, wired burglar alarm systems or network cable. Solder or crimp suitable connectors at the ends which will not become too easily disconnected over time.

No. As already mentioned, the currents through the wire will be very low and therefore any voltage drop will also be very low. The capacitance of this wire won't be a problem because it will not be carrying high frequency data signals. Interference induced into the wire from the environment is more likely to be an issue, but this can be avoided in your code (by only reacting to steady signal levels over several milliseconds, not reacting to any brief pulses).

1 Like

Yes, I've come across that in Chinese motors.
The windings are enameled so at first glance you can't tell the difference. Only when you scrape the enamel off can you see it's aluminium. The other clue is they crimp them.
The wire I have issues with is copper, plated and I guess it has oxidised. The rosin fluxes aren't aggressive enough to remove the contamination
I do a lot of plumbing soldering as well. Copper pipe is easy to clean up and uses an aggressive flux. The solder is heavy duty and isn't flux cored.
A lot easier than a fiddly wire.

This is all too real. I have purchased "pure copper" stranded, and got CCA. Soldering disintegrates the strands. I finally found a reliable copper wire source. Oh, how nice it wicks.

It's not just a question of soldering.
Recently wires from AE are more often cu plated steel than copper. And people here are trying to power motors with 30awg steel dupont wires..

It's all to do with cost.

Basic components like through hole resistors use steel leads now and even the UK low value coins, the pennies, are plated steel. They don't even make good washers at a pinch.

I have a personal interest in component materials as I have an implanted cardiac device. Normally, a bit of steel wouldn't matter, but it does when it comes to MRI scans. A field strength of 1.5 to 3.0 Tesla is commonly used. Even with all precautions taken, patients can experience localised heating or vibrations.

Devices can be certified as being safe for MRI, but are still put into a safe mode during the scan.

It's a weird feeling having your every heartbeat controlled by a sophisticated microcontroller. I won't be writing the code for that.

Cheers for that :slight_smile:
I have some MOSFETs between the output pins on the ESP and the relevant wire for each colour on the LED strip to get the signal up to power so no drama there, my concern is more with the signal from the PIR sensor still being ok by the time it gets to the ESP32, and not having degraded enough that the ESP won't detect it.

Nice! I've tons of "retired" cat5 cable. That'll do nicely