How to connect a BC547 with Arduino, sensor give only 2.5v and I need 5v

Hello,
I use the HC-SR501 Passive Infrared (PIR) Motion Sensor (from Velleman).
The problem is that the pin 'out' give only 2,5 volts and the Arduino wait 5 volts like input.

I thinking to use a transistor like BC547 but I don't understand how to connect it.

I already use this transistor to light a led or other component but here I stuck up because it's the Arduino have to use his-self the voltage from himself!

Do you have any idea?

Thanks in advance.
Remy

(sorry for my bad english)

You don't need a transistor for that, a transistor amplifies current and not voltage.

Try using a level shifter from 3.3V - 5V and see if that solves your problem. As long as the 5V arduino "sees" 3V or higher on its input (ip to 5V), it'll register as a High.

Thank you for your prompt response.

I was thinking of using the transistor as a relay.
Trigger the transistor with the output of 2.5volts at the ‘base’ (with a resistance of 10K) and connect to the ‘emitter’ of the 5 volts and recover to the ‘connector’ the 5 volts but I don’t see how to do it.

Actually as if you are turning on a 12 volt motor and you are using the transistor as a relay.

Yes, a transistor will do the job. The sensor across the base emitter junction, collector to the input of the Arduino with a pull up resistor. You will need a base resistor that will depend on the transistor you select, although it isn't critical. It should work with something 50-100k.

Thank you very much, it reassures me.

I put a picture, is it possible for you to give me the diagram?

If not, I understand.

Arduino_bc547.png

AJLElectronics:
Yes, a transistor will do the job. The sensor across the base emitter junction, collector to the input of the Arduino with a pull up resistor. You will need a base resistor that will depend on the transistor you select, although it isn’t critical. It should work with something 50-100k.

The device has an internal 1k resistor so you don’t need any base resistor. You also don’t need a pullup resistor because you can enable the internal pullup on the Arduino input. So it’s emitter to ground, base to sensor, collector to Arduino. All you need right there.

The signal logic will be inverted.

Thanks a lot for your help.
I appreciate.

Fair comment about internal pull up. I never use them as I prefer to see a physical component there. I forgot to point out the logic inversion though.

Thank you very much for all your interventions.

Something is wrong here. This should be your module, HC-SR501 PIR MOTION DETECTOR. The data sheet includes a schematic of the module and the output data which when high is 3.3 volts and low is 0 volts. As to the Arduino a logic high is:
a voltage greater than 3.0V is present at the pin (5V boards)
a voltage greater than 2.0V volts is present at the pin (3.3V boards)
So working directly into a digiutal input of your Arduino the PIR logic High should be adequate and if you are getting less than 3.3 volts something isn’t quite right.

Ron

Even at 3.3V, it is only 10% above threshold. I would still be buffering it regardless.

I agree and if I were going to eventually be facing multiple channels I would just likely opt for getting a logic level shifter board [like this one](http://Logic Level Converter Bi-Directional Module 3.3V to 5V). They seem to all be based on the BSS138 -Channel Logic Level Enhancement Mode Field Effect Transistor. Buyong on Amazon under $1.00 USD per board and each board has 4 channels.

Either way I would thing the thread starter should be seeing greater than 2.5 volts when there should be about 3.3 volts.

Ron

AJLElectronics:
Even at 3.3V, it is only 10% above threshold. I would still be buffering it regardless.

3.3V is absolutely reliable for a high reading. No need to buffer at all.

I thought HC-SR501 modules have open collector output? That means you need a pull-up resistor to get it up to Vcc (and also that any voltage measurement when the output is not active is meaningless). Internal resistor is the most convenient, of course you can go through the effort of adding an external one if you must but it's mostly a waste of effort.

Open collector outputs also generally are active low.

Ron_Blain:
As to the Arduino a logic high is:

as per data sheet: 0.6*Vcc. Note: if you power a 5V board (Uno, Mega, Nano) through the USB connection the actual operating voltage is more like 4.5V due to the diode drop, and a guaranteed high is at 2.7V or more.

In case of open collector output adding the transistor as suggested in #5 won't work; that relies on the output being a push-pull output.

wvmarle:
3.3V is absolutely reliable for a high reading. No need to buffer at all.

If you can be absolutely certain of seeing 3.3V, then maybe, but it is still only a 10% margin with 5V rail. Even for a Schmidt Trigger input, it is too close to the threshold for me to be comfortable, especially when a junk box transistor will give reliable rail to rail switching.

wvmarle:
I thought HC-SR501 modules have open collector output? That means you need a pull-up resistor to get it up to Vcc (and also that any voltage measurement when the output is not active is meaningless). Internal resistor is the most convenient, of course you can go through the effort of adding an external one if you must but it's mostly a waste of effort.

If they are open collector, then a simple pull up is all that is required. It is a logic output after all.

wvmarle:
Open collector outputs also generally are active low.

Yes, true. However, a PNP can be used to ensure that the logic polarity remains, if the program could not / should not be amended.

wvmarle:
as per data sheet: 0.6*Vcc. Note: if you power a 5V board (Uno, Mega, Nano) through the USB connection the actual operating voltage is more like 4.5V due to the diode drop, and a guaranteed high is at 2.7V or more.

Yes and that would certainly add some threshold margin.

wvmarle:
In case of open collector output adding the transistor as suggested in #5 won't work; that relies on the output being a push-pull output.

Not sure why you think that is?

Sorry about the orientation of this, it seems such a struggle getting images displayed and I have run out of patience!

AJLElectronics:
If you can be absolutely certain of seeing 3.3V, then maybe, but it is still only a 10% margin with 5V rail.

And, really, that is enough. A Serial output from a 3.3V part is reliably read by an Arduino running at 5V. No problems there. Remember also that 3.0V is a guaranteed level; the actual cut-off is well below that. 3.3V is in spec for a logic high. It simply works.

Yes, true. However, a PNP can be used to ensure that the logic polarity remains, if the program could not / should not be amended.

No, that'd mess up the output logic for an active LOW sensor.

This is a typical beginner's mistake: assuming that HIGH means ACTIVE. It's NOT. It's just one state, with one meaning. For some sensors active is HIGH or 1, for others it's LOW or 0. Buttons are also normally wired active LOW. In the end it really doesn't matter, the Arduino doesn't care, nor should you. Adding components just because you can't get your head around this is just bad practice.

wvmarle:
And, really, that is enough. A Serial output from a 3.3V part is reliably read by an Arduino running at 5V. No problems there. Remember also that 3.0V is a guaranteed level; the actual cut-off is well below that. 3.3V is in spec for a logic high. It simply works.

It may well do, but personally I think it is sailing close to the wind.

wvmarle:
No, that'd mess up the output logic for an active LOW sensor.

By mess up, you mean "invert".

wvmarle:
This is a typical beginner's mistake: assuming that HIGH means ACTIVE. It's NOT. It's just one state, with one meaning. For some sensors active is HIGH or 1, for others it's LOW or 0. Buttons are also normally wired active LOW. In the end it really doesn't matter, the Arduino doesn't care, nor should you. Adding components just because you can't get your head around this is just bad practice.

I'm no beginner. I just like to build in reliability margins. A 5V TTL input should be fed with that, anything less even though just over threshold needs buffering in my opinion. The tiny cost of a junk box transistor is not going to break the bank. Same as internal pull ups etc which I prefer to see physically. When the Arduino is off the board, the Voltages remain where they should be for testing. It also removes one potential bug if the internal resistor didn't get set.

I accept that it isn't your opinion, so we will just have to agree to disagree.

The main ball game chip on this PIR module looks to be a BISS0001 Infrared Human Body Alert IC DIP. The mention of output is Output: Pulse/ level output. This runs with the data sheet I posted earlier for the module which is using the linked chip.Nothing in any of that would lead me to believe the output is open collector. The module link does show the complete circuit where power in is applied through a diode and to a 7133-1 voltage regulator. The regulator out is 3.3 volts which powers the module.

Nothing I can find in any of this points to a need for an external pullup on the module output. All things considered this module should be outputting a logic high of 3.3 volts. Now if the user is getting 2.5 volts they may wish to disconnect the module from the Arduino and measure the output open circuit to eliminate any possible mis wiring or loading. That 0.8 volts is going somewhere or the module is faulty.

Lastly in the data sheet they stated:
Automatic induction: to enter the sensing range of the output is high, the person leaves the sensing range of the automatic delay off high,
output low.

That leads me to believe an Active High so when something like a person is in range the output pin goes High.

Ron

wvmarle:
And, really, that is enough. A Serial output from a 3.3V part is reliably read by an Arduino running at 5V.

That is a nominal voltage. Right now I am measuring 4.83V on an UNO powered by USB, no loads attached. That will reduce the 3.0V logic threshold. Running from the DC jack, it will be different. Since supply voltage can change, it's not a good practice to gamble with the logic levels.

wow, a huge thank you to everyone, really thank you very much for your interventions and help.

Remy

AJLElectronics:
Fair comment about internal pull up. I never use them as I prefer to see a physical component there.

I can see that this fellow is going to be trouble! :astonished: