Gpio - IR Receiver


5 posts
by puchacz » Fri Mar 01, 2013 7:46 pm
Hello, i've got IR receiver which i want to use with my raspberry pi but not sure how :)

IR Rec: tsop 31238

My connection to RPi :

+ 3.3v -> R220Ohm -> 2 pin on receiver
- Gnd on 1 pin on receiver
Data 3 -> R2.2KOhm -> 3 Header pin / 8 wiring pi pin on my raspberry

thats my program:

...
pinMode(8, INPUT);
while(digitalRead(8))
{
std::cout<<"no signal"<<std::endl;
}
std::cout<<"pin state changed"<<std::endl;
...

it doesnt work :) How to run this receiver :)
Last edited by puchacz on Fri Mar 01, 2013 9:15 pm, edited 1 time in total.
Posts: 18
Joined: Wed Feb 13, 2013 2:19 pm
by joan » Fri Mar 01, 2013 9:10 pm
Any specs for that device? I can't find tsop 3128 as an IR receiver.
User avatar
Posts: 5427
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by puchacz » Fri Mar 01, 2013 9:14 pm
oh, i made a mistake. Its 31238
[url]
http://datasheet.octopart.com/TSOP31238 ... -10544.pdf[/url]
Posts: 18
Joined: Wed Feb 13, 2013 2:19 pm
by joan » Fri Mar 01, 2013 9:36 pm
Connections seem OK.

It'd be worth double checking that the software pin 8 maps onto the pin you are using on the gpio header.

Your code fragment seems incomplete.

You need something like

Code: Select all
pinMode(8, INPUT);
pinState = -1;

while (true)
{
   newPinState = digitalRead(8);
   if (newPinState != pinState)
   {
      pinState = newPinState;
      print pinState;
   }
}
User avatar
Posts: 5427
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by puchacz » Fri Mar 01, 2013 9:41 pm
i quess something must be wrong (too big resistors?) becouse even lirc_rpi dont react on any ir pilot. I will check it
Posts: 18
Joined: Wed Feb 13, 2013 2:19 pm