# Help with Reflective IR Sensor circuit

**URL:** <https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306>\
**Category:** Raspberry Pi\
**Created:** [31 May 2021 04:58 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306 "2021-05-31T04:58:44Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [31 May 2021 04:58 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/1 "2021-05-31T04:58:44Z")

</div>

I recently bought an IR Reflective Sensor, but I was having trouble getting the wiring to work on a breadboard with the raspberry pi 4B.

I tried connecting it the similar to how the site has it connected to an arduino, but it still doesn’t work.

Would anyone be able to help me with the correct circuit diagram would be nice 🙂 thanks in advance

Link to sensor:

> **[Reflective IR Sensor with 470 and 10K Resistors](https://core-electronics.com.au/reflective-ir-sensor-with-470-and-10k-resistors.html)**
>
> This Reflective IR Sensor is a simple plastic casing with two elements - an IR LED and an IR phototransistor. You can control the IR LED and turn it on to bounce .. read more

Any help with the correct circuit diagram would be nice 🙂 thanks

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/9/9f68d732f5f00c8156cd6f847075da6f7a6696a3.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/0/0cfb9907cab6318177a5458677a23d1689c8c72d.jpeg)

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [31 May 2021 11:41 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/2 "2021-05-31T11:41:04Z")

</div>

Hi Azula  
This might sound like a stupid question but you are putting something white or light-coloured in front of the device to reflect IR aren’t you. There is no indication of anything in the pix and the text is a bit vague  
Cheers Bob

---

<div class="post-metadata">

**Author:** ![James](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/james/32/4400_2.png) [@James](https://forum.core-electronics.com.au/u/James)\
**Post date:** [1 June 2021 03:28 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/3 "2021-06-01T03:28:19Z")

</div>

Hi Azula,

~~Correct me if I’m wrong here, but the Pi doesn’t possess the hardware ADC required to use an analog sensor such as the reflectance sensor you’re using. You’d need to use an ADC such as [the MCP3002 Core stocks](https://core-electronics.com.au/analog-to-digital-converter-mcp3002.html). As for using it, [SparkFun have a great guide for Python and Pi use with this chip](https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/experiment-3-spi-and-analog-input).~~

I was completely wrong there, this sensor is an on-off affair, and I’ll have to take a closer look at this. Could you post a quick napkin-sketch of your breadboard wiring? I can’t quite make out some of the connections as they are hidden behind other wires. Could you also post any code you’re using, as that might be a problem as well.

Keen to see this working!  
-James

---

<div class="post-metadata">

**Author:** ![Liam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/liam/32/3562_2.png) [@Liam](https://forum.core-electronics.com.au/u/Liam)\
**Post date:** [1 June 2021 04:48 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/4 "2021-06-01T04:48:13Z")

</div>

Hey Azula,

Welcome to the forum! This sounds like an awesome project!  
I did some digging and came across [this tutorial](https://learn.adafruit.com/pro-trinket-tachometer/overview) on Adafruits site using the exact same sensor.

In both examples they are using a board with a logic level of 5V, I haven’t had a play around with the sensor myself but the output pin of the sensor might be driven to a dangerous level for the Pi (the Pins aren’t rated to be able to handle!  
I couldn’t find a hard maximum for the Pi’s, you can read more about logic levels here: [Logic Levels - learn.sparkfun.com](https://learn.sparkfun.com/tutorials/logic-levels/all)), and the pins also arent able to read analog signals - you need an [ADC](https://core-electronics.com.au/ads1015-24v-adc-breakout.html) for that!.

You can read the voltage of the pin using a multimeter if you keep the sensor activated to double-check.  
To get it up and running, a [logic level converter](https://core-electronics.com.au/logic-level-converter-bidirectional.html) between the output of the sensor (connecting into one of the inputs of the high side) and the ouput to the Pi with a current limiting resistor for best practice, should get you back on track!

Let us know how you go Azula, I’m keen to see where this project takes you!  
Liam.

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [1 June 2021 05:40 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/5 "2021-06-01T05:40:53Z")

</div>

> [@Liam](#):
>
> and the pins also arent able to read analog signals - you need an [ADC](https://core-electronics.com.au/ads1015-24v-adc-breakout.html) for that!

I think this device is either on or off. Not analog.

I don’t see why this has to run from 5V. Reduce the 470Ω resistor to a value that allows the required current through the IR LED for 3V3 if that is what you are working with. The output should be the open collector of the photo transistor so just return the 10kΩ resistor to 3.3V if that is required. It does not have to be 5V.  
Cheers Bob  
PS: I have not seen an answer to my previous question, I quote"

> [@Robert93820](#):
>
> This might sound like a stupid question but you are putting something white or light-coloured in front of the device to reflect IR aren’t you. There is no indication of anything in the pix and the text is a bit vague

---

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [1 June 2021 07:11 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/6 "2021-06-01T07:11:01Z")

</div>

Oh hey, yea I was putting so piece of white plasticcard about 5-10mm infront of it

---

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [1 June 2021 07:14 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/7 "2021-06-01T07:14:28Z")

</div>

Oh hey thanks so much for the resources, looks really interesting, I’ll definitely give it a read 🙂

---

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [1 June 2021 07:17 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/8 "2021-06-01T07:17:27Z")

</div>

Hey, sorry for the late reply, I was at work. Yea I’ll quickly draw that up when I get home and I’ll post it.

Thanks so much for the help everyone 🙂

---

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [1 June 2021 08:23 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/9 "2021-06-01T08:23:29Z")

</div>

![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/5/527d3b94e455daf0ae16dbfbf1c25818194dbf9e.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/0/07de3591ccf3a10bbfc50caaf452dae47af5154a.jpeg)

Here’s an attempt at a wiring diagram haha, sorry if it’s messy.

And that’s the test code 🙂

I’m fairly new to raspberry Pi projects, so If I’ve made a silly mistake, I apologise for wasting everyone’s time 😅

Again, thank you so much for the help everyone

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [1 June 2021 09:00 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/10 "2021-06-01T09:00:11Z")

</div>

I don’t know anything about RPi but you seem to have GPIO Pin 5 connected to Ground. Won’t do much there. Try connecting to phototransistor collector, in other words the other end of this transistor where the 10kΩ resistor connects.  
Cheers Bob

---

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [1 June 2021 09:32 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/11 "2021-06-01T09:32:52Z")

</div>

Hey, yea I tried that too but still didn’t work

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [1 June 2021 09:48 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/12 "2021-06-01T09:48:16Z")

</div>

Keep this in mind though. Any IO pin connected to ground is not going to do anything so don’t put it back  
Cheers Bob

---

<div class="post-metadata">

**Author:** ![azula](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@azula](https://forum.core-electronics.com.au/u/azula)\
**Post date:** [1 June 2021 10:19 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/13 "2021-06-01T10:19:25Z")

</div>

I will, thank you 😊

---

<div class="post-metadata">

**Author:** ![James](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/james/32/4400_2.png) [@James](https://forum.core-electronics.com.au/u/James)\
**Post date:** [3 June 2021 01:12 UTC](https://forum.core-electronics.com.au/t/help-with-reflective-ir-sensor-circuit/10306/14 "2021-06-03T01:12:43Z")

</div>

Hi Azula,

I’ve done some reading, and while there isn’t a datasheet on the product, I found [a stackoverflow page](https://electronics.stackexchange.com/questions/192264/how-to-compute-bias-resistor-for-phototransistor-value) that suggests using calculating the resistor value based on a forward voltage (unknown in your case but constant for the phototransistor), so you could experiment with gradually smaller resistance values, or use a 10K pot to try and adjust for the differing supply voltage of the Pi.

Still keen to see this working as always!  
-James

EDIT: Added link
