LaFonera Hardware IR Receiver

From DD-WRT Wiki

Jump to: navigation, search

You are here: DD-WRT wiki mainpage / LaFonera / Hardware / IR Receiver

[edit] La Fonera with IR receiver

Using DIY IR receiver with GNU/Linux is quite simple. All you need is a TSOP receiver, a diode, a resistor and a78L05 regulator as explained here. But this wont work with USB/serial adapter and it need a kernel module to directly drive DCD line.

But there is Paul Fox’s avrlirc project, using AVR Attiny2313 to connect IR receiver to the serial RX line. It can be used with USB/serial and embedded system with simple serial port like… La Fonera.


Hardware part is very simple. You need an AVR Attiny2313 from Atmel, a TSOP1736 receiver, a 14.7475 Mhz quartz, 22pf ceramic capacitors and, if you want, led and 330 Ohm resistor. You can also use internal 8 Mhz resonator from the AVR (low speed, 9600bps) but you will get better results with a quartz (115200bps, see page 140 of the Attiny2313 datasheet).

Beware ! Never connect AVR to serial TX of RS232 interface. Voltages are very different. You may burn the AVR. You can use a MAX232 circuit to connect the AVR and RS232 or use you homemade Fonera console adapter to convert TTL/RS232. See Paul’s code for more information.

Software is in two parts. First you have the firmware for the AVR. Configure sources like explained by Paul, compile and burn the AVR Flash with AVRdude. Second part is avrlirc2udp. It’s the host part that run on your computer, listen the serial port and send IR data to lircd.

Register new remote with :

 % ./avrlirc2udp -H -t /dev/ttyUSB0 -h localhost

Then :

% sudo irrecord --driver=udp my_file

Just follow what’s appear on the screen and copy the generated file to /etc/lirc/lircd.conf then configure /etc/lirc/hardware.conf :


Create your ~/.lircrc to associate buttons and actions for softwares that’s support Lirc (xmms, mplayer, etc). Everything work via UDP and you can run Paul’s code on one computer and Lirc demon on another. Because of using RX serial line, we can run Paul’s code on La Fonera.


Look at the serial console connector inside the router :


Just connect pin 3 of the AVR to RX pin, add the ground and get +5V from inside the router, close to the power connector. You cannot use Vcc here, it’s +3.3V.

You need to build a new OpenWRT from source to deactivate serial console :

  • Configure the kernel by make kernelconfig and change default kernel command string, deleting console use (Kernel Hacking / Default kernel command string).
  • In the kernel configuration too, remove serial console : Device Drivers / Character devices / Serial drivers / Console on 8250/16550 and compatible serial must be unchecked.
  • Remove serial login support by deleting the ttyS0 line in package/base-files/files/etc/inittab.

Build and upload the firmware via RedBoot. After the first boot you can login with Telnet. Add password for root, this remove telnet support and add SSH.

Configure ipkg and install avrlirc2udp :

And run :

avrlirc2udp -H -t /dev/ttyS0 -h

You can still use RedBoot with serial port at boot time. But, if you want you can use IP by contacting RedBoot on port 9000 via telnet. You need to send ^C to stop the boot process :

% cd /tmp
% cat > break


% nc -vvv 9000 < break; telnet 9000

Ugly, i know. But it works.

[edit] Refrences

this page was made by wildblue!