Send & Receive Infrared with GPIO

Moderators: mdrjr, odroid

Send & Receive Infrared with GPIO

Unread postby thiakil » Sat Oct 05, 2013 5:40 pm

To send and receive IR, all you need are a few components; now that the driver is in the 3.8 git repo. (pull request was here)

  • IR Receiver (active low)
  • 1N4148 Diode
  • IR LED
  • NPN transistor (e.g. BC548)
  • Resistor (I used 220R)

Attached is both the circuit diagram, and a photo of it on a breadboard (apologies for messiness). In the driver the pull up resistor is enabled, so we use the diode to protect the gpio from 5v (make sure it PREVENTS current from getting to the gpio pin).
IR LED is connected much as you would expect.

I believe you will need to compile your own kernel; it's not enabled by default.
Code: Select all
CONFIG_LIRC=y (or m)
Device Drivers > Multimedia support > Remote controller decoders > LIRC interface driver

CONFIG_LIRC_STAGING=y
Device Drivers > Staging drivers > Media staging drivers > Linux Infrared Remote Control IR receiver/transmitter drivers

CONFIG_LIRC_ODROID=m
Linux Infrared Remote Control IR receiver/transmitter drivers > Homebrew GPIO Port Receiver/Transmitter for the Odroid


The driver is based on the RasberryPi's lirc_rpi, and has the same config options.
Code: Select all
debug, gpio_out_pin, gpio_in_pin, sense, softcarrier.

gpio_out_pin, gpio_in_pin are the ones you will want to play with. (see viewtopic.php?f=52&t=202)
In pin can be any INTERRUPT capable pin, default 209 (GPX2.1, extension header pin 4)
Out can probably be any of them, default 203 (GPX1.4, extension header pin 9)

/etc/lirc/hardware.conf should contain the following (change /dev/lirc0 if it differs from your install, this was done on ubuntu)
Code: Select all
#Chosen Remote Control
REMOTE="Home-brew (odroid gpio)"
REMOTE_MODULES="lirc_dev lirc_odroid"
REMOTE_DRIVER=""
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="Home-brew (odroid gpio)"
TRANSMITTER_MODULES="lirc_dev lirc_odroid"
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE="/dev/lirc0"
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""

LOAD_MODULES="true"


If all works, you should get something like the following in dmesg - if it does not say active low, something is wrong!
Code: Select all
[    3.945000] lirc_dev: IR Remote Control driver registered, major 250
[   18.925000] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   18.925000] lirc_odroid lirc_odroid.0: lirc_dev: driver lirc_odroid registered at minor = 0
[   18.925000] lirc_odroid: driver registered!
[   19.835000] lirc_odroid: auto-detected active low receiver on GPIO pin 209


To test, make sure lirc is stopped and the module is loaded.
Code: Select all
sudo mode2 -d /dev/lirc0

Press a button on a remote, and you should get some pulse, space message.

After that you should be able to configure lirc as per normal.

If you lack soldering skills, I may be able to make one to sell you.
Attachments
breadboard-ir.jpg
Breadboard photo
ircircuit.png
Circuit diagram
thiakil
 
Posts: 12
Joined: Wed Mar 13, 2013 9:27 pm
languages_spoken: English, Italian
ODROIDs: Odroid-x

Re: Send & Receive Infrared with GPIO

Unread postby odroid » Sat Oct 05, 2013 8:23 pm

Great posting.

Please let me know the part number of IR sensor and IR LED.
I want to make one. ;)

One question of the direction of 1N4148 diode.
I think it blocks the signal from IR sensor.
Is it wrong? Or is it a sort of level shifter?
User avatar
odroid
Site Admin
 
Posts: 24992
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Send & Receive Infrared with GPIO

Unread postby thiakil » Sat Oct 05, 2013 8:35 pm

The lirc_rpi link has some parts numbers I believe; http://aron.ws/projects/lirc_rpi/
Adafruit's tutorial is also good reference http://learn.adafruit.com/ir-sensor/overview

For the LED, as long as it output infrared light it should work fine.

These work fine for me
http://dx.com/p/5mm-ir-led-emitters-20-pack-2399
http://dx.com/p/universal-ir-infrared-r ... pcs-169048 - These particular receivers appear to not like RCMM-32 however, but work with RC6 and other more common protocols in this setup.

odroid wrote:One question of the direction of 1N4148 diode.
I think it blocks the signal from IR sensor.
Is it wrong? Or is it a sort of level shifter?

Most receivers are active low; I'm no electrical engineer, but it seems that even with the voltage drop it manages to pull the GPIO low, whilst preventing the receiver's 5v output from reaching it.
thiakil
 
Posts: 12
Joined: Wed Mar 13, 2013 9:27 pm
languages_spoken: English, Italian
ODROIDs: Odroid-x

Re: Send & Receive Infrared with GPIO

Unread postby cogitator » Fri Oct 30, 2015 2:08 am

Hey thiakil,

sorry for picking up this old thread out again.
I'm new to odroid/ubuntu and tried to send ircommands via gpio using your tutorial.
I followed the instructions of this link: http://odroid.com/dokuwiki/doku.php?id=en:xu3_building_kernel#linux1
to compile the kernel. In the ./config i added the flags you mentioned in your post:

CONFIG_LIRC=y
CONFIG_IR_LIRC_CODEC=y
CONFIG_LIRC_STAGING=y
CONFIG_LIRC_ODROID=m


After compiling and booting nothing habend. Then I searched for the changes in the kernel source you mentioned in your pull request and found none of them. After that I added the file drivers/staging/media/lirc/lirc_odroid.c and made the changes the other files(drivers/staging/media/lirc/Makefile, drivers/staging/media/lirc/Kconfig), compliled again, but after reboot
dmesg | grep lirc
alsways returns
lirc_dev
but not
lirc_odroid


I hope you can help me a little bit.

Thank you very much in advance.

David
cogitator
 
Posts: 6
Joined: Wed Oct 28, 2015 9:53 pm
Location: Mönchengladbach, Germany
languages_spoken: english german
ODROIDs: 4x XU4

Re: Send & Receive Infrared with GPIO

Unread postby thiakil » Fri Oct 30, 2015 9:44 am

This was designed and added for the original X, most likely we'll have to make some modifications to the gpio port / platform code.

I'll take a look
thiakil
 
Posts: 12
Joined: Wed Mar 13, 2013 9:27 pm
languages_spoken: English, Italian
ODROIDs: Odroid-x

Re: Send & Receive Infrared with GPIO

Unread postby tobetter » Fri Oct 30, 2015 11:51 am

cogitator wrote:Hey thiakil,

sorry for picking up this old thread out again.
I'm new to odroid/ubuntu and tried to send ircommands via gpio using your tutorial.
I followed the instructions of this link: http://odroid.com/dokuwiki/doku.php?id=en:xu3_building_kernel#linux1
to compile the kernel. In the ./config i added the flags you mentioned in your post:

CONFIG_LIRC=y
CONFIG_IR_LIRC_CODEC=y
CONFIG_LIRC_STAGING=y
CONFIG_LIRC_ODROID=m


After compiling and booting nothing habend. Then I searched for the changes in the kernel source you mentioned in your pull request and found none of them. After that I added the file drivers/staging/media/lirc/lirc_odroid.c and made the changes the other files(drivers/staging/media/lirc/Makefile, drivers/staging/media/lirc/Kconfig), compliled again, but after reboot
dmesg | grep lirc
alsways returns
lirc_dev
but not
lirc_odroid


I hope you can help me a little bit.

Thank you very much in advance.

David

If you are running with XU3, the you could refer the driver source below.
https://github.com/tobetter/linux/blob/ ... -ir-recv.c

This is the driver to use IR receiver on ODROID-CludShell and you can specify the GPIO number when your load the module - gpioplug-ir-recv.
Just for reference, https://github.com/tobetter/odroid-clou ... shell.conf
tobetter
 
Posts: 2079
Joined: Mon Feb 25, 2013 10:55 am
Location: Kitchener, ON, Canada
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Send & Receive Infrared with GPIO

Unread postby thiakil » Fri Oct 30, 2015 8:10 pm

@cogitator: my driver was made on an older version of the kernel (and for Odroid-X). To even try compiling it you would need to copy the source file and add the Kconfig changes. See https://github.com/hardkernel/linux/pull/29

Your best bet would probably be to use tobetter's driver on the XU3 (which I have no idea how it works)
thiakil
 
Posts: 12
Joined: Wed Mar 13, 2013 9:27 pm
languages_spoken: English, Italian
ODROIDs: Odroid-x

Re: Send & Receive Infrared with GPIO

Unread postby cogitator » Sat Oct 31, 2015 1:16 am

Thank you guys for your response.

As far as I understood gpioplug-ir-recv is only able to receiver IR signals not to send them.

Now it is working. What I did:

git clone frome the current xu3 kernel (odroidxu3-3.10) then I made the changes mentioned in your pull request in:

Add to /root/linux/drivers/staging/media/lirc/Kconfig
Code: Select all
config LIRC_ODROID
   tristate "Homebrew GPIO Port Receiver/Transmitter for the Odroid"
   depends on LIRC
   help
     Driver for Homebrew GPIO Port Receiver/Transmitter for the Odroid X/X2


Add to /root/linux/drivers/staging/media/lirc/Makefile
Code: Select all
obj-$(CONFIG_LIRC_ODROID)         += lirc_odroid.o

#
Put https://github.com/thiakil/linux/blob/c345104118aa6726b08f2412ce581b829e8c9da4/drivers/staging/media/lirc/lirc_odroid.c into /root/linux/drivers/staging/media/lirc/lirc_odroid.c

The i followed the instructions from: http://forum.odroid.com/viewtopic.php?f=111&t=14201&p=110750&hilit=ir#p110750

Code: Select all
make menuconfig

Enable the lirc_odroid module in:
Device Drivers > Staging drivers > Media staging drivers > Linux Infrared Remote Control IR receiver/transmitter drivers > Homebrew GPIO Port Receiver/Transmitter for the Odroid.

Code: Select all
make modules
After this Loooooooooong process finished, you can copy the lirc_ordroid.ko from /root/linux/drivers/staging/media/lirc/

Add the modules in /etc/modules
lirc_dev
lirc_odroid


I had to load the module with: insmod /lib/modules/3.10.82+/kernel/drivers/media/rc/lirc_odroid.ko
You can finde your Kernelversion with: uname -r

After that i was able to send IR Commands using irsend.

Hope that helps someone ;-)
Last edited by cogitator on Sat Nov 14, 2015 3:01 am, edited 2 times in total.
cogitator
 
Posts: 6
Joined: Wed Oct 28, 2015 9:53 pm
Location: Mönchengladbach, Germany
languages_spoken: english german
ODROIDs: 4x XU4

Re: Send & Receive Infrared with GPIO

Unread postby odroid » Mon Nov 02, 2015 10:27 am

Thank you for the nice instruction. :D
User avatar
odroid
Site Admin
 
Posts: 24992
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Send & Receive Infrared with GPIO

Unread postby odroid-goat » Thu Mar 16, 2017 6:30 am

Thank you! Very valuable thread!
I was able to build a IRDA blaster based on it. For some reason I could not use PIN 7 on my C1+. Instead PIN 11 worked fine.
I can now control my receiver and TV by my openhab smart home automation :)

If anybody is interested in the parts I used:
- IRDA LED SFH 409
- transistor BC547
- 50 Ohm resistor

I used PIN 1 (3.3V) for power input.

I soldered all on a small cape-board and attached it on my C1+. Works quite well!!

Code: Select all
root@homedroid:~# cat /etc/modules
lirc_dev
lirc_odroid


Code: Select all
root@homedroid:~# cat /etc/modprobe.d/irda.conf
options lirc_dev
options lirc_odroid gpio_out_pin=88 softcarrier=1 invert=1



Cheers!
Image Image Image
odroid-goat
 
Posts: 3
Joined: Thu Mar 16, 2017 6:17 am
languages_spoken: english
ODROIDs: C1+, C2

Re: Send & Receive Infrared with GPIO

Unread postby odroid » Thu Mar 16, 2017 7:39 am

I hope this WiKi page is useful too.
http://odroid.com/dokuwiki/doku.php?id= ... io_blaster
User avatar
odroid
Site Admin
 
Posts: 24992
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Send & Receive Infrared with GPIO

Unread postby odroid-goat » Sat Mar 18, 2017 6:00 am

odroid wrote:I hope this WiKi page is useful too.
http://odroid.com/dokuwiki/doku.php?id= ... io_blaster



Yes, of course I saw this wiki as well. Thanks for the updated post including the graphic!
Is the resistor between the GPIO and the transistor needed? Didn't use one :?
In the wiki there's a statement: "R1 is included in the RET". What does this mean?
odroid-goat
 
Posts: 3
Joined: Thu Mar 16, 2017 6:17 am
languages_spoken: english
ODROIDs: C1+, C2

Re: Send & Receive Infrared with GPIO

Unread postby odroid » Sat Mar 18, 2017 6:23 am

RET is Resistor Equipped Transistor.
So it means the R1 is embedded in PBRN123Y Transistor and you don't need to use any resistor between base pin and GPIO.
gpio_ir_blaster.png
(92.71 KiB) Downloaded 632 times
User avatar
odroid
Site Admin
 
Posts: 24992
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Send & Receive Infrared with GPIO

Unread postby odroid-goat » Fri Mar 24, 2017 4:16 am

Ahh. Thanks :)
odroid-goat
 
Posts: 3
Joined: Thu Mar 16, 2017 6:17 am
languages_spoken: english
ODROIDs: C1+, C2


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 1 guest