Adding an infrared remote: lirc + mic input

Discussion about my Wifi Radio project at http://mightyohm.com/wifiradio/ or my WL-520gU talk at NOTACON.
danitool
Posts: 11
Joined: Tue Dec 01, 2009 9:02 am

Adding an infrared remote: lirc + mic input

Post by danitool »

First of all I'm using a bcm63xx board (livebox dv4210). The Openwrt version I'm using is one of latest trunks: bleeding edge, r27198
The board has not many differences with the wl-520gu, small ram (16 MiB), small processor (mips 256 MHz), one usb 1.1, and a b43 minipci wifi with opensource drivers ( it works quite fine in latest trunks).

For getting it work i used this schematic for the IR receiver:
http://files.myopera.com/danitool/liveb ... rcalsa.jpg

Probably you don't need to solder the mic input ground, because the usb is already grounded to it and shares the ground with the board, I didn't and it works. Consequently you only need to solder one wire to the usb card. Or if you prefer make an external receiver to plug it with a stereo jack, I did it the first time for testing, but I don like stuff hanging on the board, so finally i fitted it inside my router.

The second thing is to prepare the lirc package. Unfortunatelly the receiver type is hardcoded into the makefile package, and in the trunk I'm using there are some lost utilities, I fixed it, this is the makefile and my files for the lirc package (located under trunk/feeds/packages/utils/lirc/) , it includes my remote keys, and irexec commands for the remote.
http://files.myopera.com/danitool/liveb ... ackage.zip


Because the new mpd is fat as a cow, and my board has little resources, I ported and striped mpd 0.13.2 to this trunk I'm using. (trunk/feeds/packages/sound/mpd/)
http://files.myopera.com/danitool/liveb ... ackage.zip

Finally I compiled unselecting stuff I don't need (ie: I dont need ssh or iptables..). You know mpd is a RAM eater, little kernels, and elimiating daemons will give you more available ram.

Ok for making the receiver work first lets launch the lircd:

Code: Select all

lircd --driver=audio_alsa -d plughw@12000
You need to calibrate the reception, it can be done adjusting the Mic input in alsamixer (capture devices pressing F4). For me putting Mic to 62 does the job. You can set it with the command:

Code: Select all

amixer set Mic capture 62%
launch the irexec daemon for executing the stuff you want on receiving IR signals:

Code: Select all

irexec --daemon /etc/wifiradio/lircrc
I used spare parts for the Ir circuit, also the remote is an unused one I had (almost every remote can work with alsa), Then the cost was 0 € for me, except some hours of fun ;) . Ok, all working fine, I can select internet radios with the remote and I love it, isn't it cool?. Also as an extra and because I didnt build the lcd panel I added the package ssmtp, associated with a button at the remote. When I listen a cool song i like i press that button and automagically my wifiradio sends an email to my account with the title of the song, artist, etc. Also I soldered a buzzer to a gpio, for beeping on some events (just fun).

and this is the result
Image
I can provide more details if someone interested

User avatar
gerben
Posts: 164
Joined: Sat Oct 16, 2010 8:41 am
Location: Netherlands

Re: Adding an infrared remote: lirc + mic input

Post by gerben »

Very cool. Didn't know it was possible to use the mic for IR input. I would love IR on my radio, but I think this is solution is way over my noob-head. Thanks for sharing though. I love it.

Muffinman
Posts: 17
Joined: Thu Mar 03, 2011 1:51 pm

Re: Adding an infrared remote: lirc + mic input

Post by Muffinman »


danitool
Posts: 11
Joined: Tue Dec 01, 2009 9:02 am

Re: Adding an infrared remote: lirc + mic input

Post by danitool »

Almost every remote should work. BTW I've read the ones which uses rc5 protocol are more convenient for lircalsa.

Here is a list of working remotes with lirc:
http://lirc.sourceforge.net/remotes/

If you don't find yours in the list, you'll can record your keys with the lirc receiver.

dext3r
Posts: 10
Joined: Wed Nov 17, 2010 11:32 pm

Re: Adding an infrared remote: lirc + mic input

Post by dext3r »

:evil: danitool (and anyone else who can help!),

I am trying to add the lirc package to my OpenWRT developer setup but i am having the WORST luck.

I have the sources for 8.09. I put your Makefile into

Code: Select all

/feeds/packages/utils/lirc
and i run

Code: Select all

make menuconfig
but it doesn't show up in the package list!

I tried a different makefile from here:
https://forum.openwrt.org/viewtopic.php?id=13339

Code: Select all

#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 5624 2007-09-04 00:29:07Z Dottout $

include $(TOPDIR)/rules.mk
# we use the $LINUX_DIR variable, which is defined in kernel.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=lirc
PKG_VERSION:=0.8.3pre1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://lirc.sourceforge.net/software/snapshots
PKG_CAT:=bzcat

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(INCLUDE_DIR)/package.mk

define  Package/lirc/Default
    SECTION:=utils
    CATEGORY:=Utilities
    URL:=http://lirc.org/
endef

define  Package/lirc
    $(call Package/lirc/Default)
    TITLE:=LIRC - Linux Infrared Remote Control
    MENU:=1
endef

define Package/lirc/description
  LIRC is a package that allows you to decode and send 
  infra-red signals of many (but not all) commonly used 
  remote controls.
  
  This package contains only lircd and lircd.conf!
endef


define  Package/lircdaemonadd
    $(call Package/lirc/Default)
    DEPENDS:=lirc
    TITLE:=Daemon Additional Files
endef

define Package/lircdaemonadd/description
  Contains those additional daemon-tools:
   -irrecord
   -lircmd
endef



define  Package/lirctools
    $(call Package/lirc/Default)
    DEPENDS:=lirc    
    TITLE:=LIRC tools
endef

define Package/lirctools/description
  This package contains those lirc-tools:
   -ircat:   prints config strings to standard output, can be used to provide remote control input to scripts
   -irexec:  execute programs according to the pressed remote control buttons
   -irpty:   pseudo tty driver. Connects to lircd via socket to receive infra-red codes and converts them to key strokes
   -irsend:  application for sending IR-codes via lirc
   -irw:     watch the codes as lircd recognize them
   -lircrcd: daemon that manages current mode for all applications
   -mode2:   shows the pulse/space length of a remote button
endef

#    --with-driver="all" \
  
CONFIGURE_ARGS += \
    --disable-nls \
    --disable-static \
    --with-kerneldir="$(LINUX_DIR)" \
    --with-driver="alsa_usb,sir" \
    --without-x \
    --with-pic \
    --with-gnu-ld \
    --enable-sandboxed \

define Package/lirc/conffiles
/etc/lircd.conf
endef


MAKE_FLAGS += \
    DESTDIR="$(PKG_INSTALL_DIR)" \
    all \

define  Package/lirc/install
    $(INSTALL_DIR) $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/daemons/lircd $(1)/usr/sbin/
    $(INSTALL_DIR) $(1)/etc
    $(INSTALL_CONF) $(PKG_BUILD_DIR)/contrib/lircd.conf $(1)/etc/
endef

define  Package/lircdaemonadd/install
    $(INSTALL_DIR) $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/daemons/irrecord $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/daemons/lircmd $(1)/usr/sbin/    
endef
#     $(INSTALL_BIN) $(PKG_BUILD_DIR)/daemons/{lircmd,irrecord} $(1)/usr/sbin/    

define  Package/lirctools/install
    $(INSTALL_DIR) $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/ircat $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/irexec $(1)/usr/sbin/    
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/irpty $(1)/usr/sbin/    
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/irsend $(1)/usr/sbin/    
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/lircrcd $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/irw $(1)/usr/sbin/    
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mode2 $(1)/usr/sbin/
endef

$(eval $(call BuildPackage,lirc))
$(eval $(call BuildPackage,lircdaemonadd))
$(eval $(call BuildPackage,lirctools))
and this shows up in the menu...so I select to build package...

Code: Select all

make[3]: Entering directory `/home/dext3r/8.09/feeds/packages/utils/lirc'
Makefile:124: *** missing separator.  Stop.
...which means I need TAB at line 124, right?

I add a TAB...

Code: Select all

dext3r@dext3r-VirtualBox:~/8.09$ make menuconfig
Collecting package info: package/feeds/packages/lircERROR: please fix package/feeds/packages/lirc/Makefile
...and it won't show up in the menu again! WTF!

:( :evil:

danitool
Posts: 11
Joined: Tue Dec 01, 2009 9:02 am

Re: Adding an infrared remote: lirc + mic input

Post by danitool »

Don't use my makefile for an older version of Openwrt. Try to install lirc instead:

Code: Select all

./scripts/feeds update -a
./scripts/feeds install lirc lirctools lircdaemonadd 
Then modify the makefile

Code: Select all

	--with-driver="audio_alsa"
Btw, I don't know if lirc-alsa works in that old Openwrt version. Good luck

dext3r
Posts: 10
Joined: Wed Nov 17, 2010 11:32 pm

Re: Adding an infrared remote: lirc + mic input

Post by dext3r »

thanks for your response! :D
danitool wrote:Don't use my makefile for an older version of Openwrt. Try to install lirc instead:

Code: Select all

./scripts/feeds update -a
./scripts/feeds install lirc lirctools lircdaemonadd 
Then modify the makefile

Code: Select all

	--with-driver="audio_alsa"
i think i did this originally but then it never showed up in the menuconfig menu...i'm gonna delete some stuff and try fresh...
Btw, I don't know if lirc-alsa works in that old Openwrt version. Good luck
no worries, i need to patch it for a different driver anyways.

dext3r
Posts: 10
Joined: Wed Nov 17, 2010 11:32 pm

Re: Adding an infrared remote: lirc + mic input

Post by dext3r »

dang, it didnt work. :?

i deleted the lirc directory from feeds/packages/util and then re-updated from the feeds (feeds update -a) to make sure i had an 'unfcked with' version

did

Code: Select all

./scripts/feeds/install lirc lirctools lircdaemonadd
went off without a complaint...

...then running:

Code: Select all

menu makeconfig
..and lirc doesn't show up in the list of packages to build.


hrm.. :?:

(it sucks i have to use this old version of openwrt...backfire isn't compatible with my router :| )

dext3r
Posts: 10
Joined: Wed Nov 17, 2010 11:32 pm

Re: Adding an infrared remote: lirc + mic input

Post by dext3r »

i noticed backfire DOES work with my router. i grabbed backfire RC5 from the sources and eventually figured out how to build all this stuff. i have lirc working now with my USB IR Toy from Dangerous Prototypes :D :D

Ghostpilot
Posts: 7
Joined: Tue Jan 29, 2013 4:05 am

Re: Adding an infrared remote: lirc + mic input

Post by Ghostpilot »

Sorry to dig upp this post. But it is along the theme of my question so instead of posting a new thread, I post here.

So... What did you do for lirc to show up in menuconfig? I am trying to compile backfire with lirc. Alsalib, alsa-utils and of course lirc are all installed, but lirc doesn't show up in menuconfig.
Do I have to install them one at a time for it to work or am I missing something crucial here?

Post Reply