We controlled any AV technique with phone. An IR transceiver for Raspberry
On the sly I does the house a little bit more cleverly. At first making control of light with phone by means of a board of the extension of RaZBerry (Z-Wave) for Raspberry, then programming of AVR microcontrollers were fond and collecting the small meteorological station show temperature on the LED display. Now queue reaching control of TV by means of iPhone.
As a mediaplayer I uses Raspberry with the distribution kit of Xbian, therefore at once understanding as I will control the TV set. Raspberry costed on a shelf under the TV set in direct visibility. On GPIO one of outputs it are necessary to install an IR of LED from the panel and to submit on it signals whom my TV set understood. In implementation the invention appearing not difficult!
Further it will be a question of how to solder a board of an IR of the transceiver for Raspberry and how to adjust a software that with phone to switch channels, to regulate volume, to switch on and off the TV set.
For control of TV the IR the transmitter are necessary and to learn what signals to transfer to TV it are necessary to scan it the panel, the IR the receiver, therefore a board for Raspberry are for this purpose necessary will contain both the receiver and the transmitter. The board should take not enough place and be put on GPIO. The receiver used GPIO 11, the GPIO 9 transmitter, plus a supply 3.3В and the earth, total are involv a 4th output.
Here the schematic diagram of a board:
Into it composition entered:
1) R1 — 1 kOhm (the resistor, restricted a current of basis to 2.5мА, the maximum current of basis who could withstand GPIO and not burn down 16мА)
2) R2 — 33 Ohm (the resistor, restricted a current on a LED to 50мА, thanks to it a signal the strong, range more than 5 meters)
3) Q1 — BC547 (the transistor for gain of a signal)
4) D1 — IR LED from the panel of 36-38 KHz (an IR the transmitter)
5) IR — TSOP1738 (an IR the receiver)
In a picture it are mark what zone of GPIO occupied the unit and what outputs used.
The board are ready and install, as a minus I will mark, the IR the receiver too unwieldy and in the transparent Raspberry case are not located, it are possible to use any other more compact IR the receiver on 38Кгц.
Now a software, in sequence I will decompose that are necessary for us:
1) Lirc for schityvny of the panel and for transmission of an IR of commands
2) The server who accepted HTTP of a command, sent an IR signals through lirc
3) The client application for phone, sen HTTP of a command to the server
To begin with we will inform what outputs lirc for reception should use and sending of an IR of signals, for this purpose we will correct / etc/modules that the necessary units boot:
[email protected] ~ $ of cat/etc/modules
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. # Parameters can be specified after the module name. lirc_dev lirc_rpi gpio_in_pin=11 gpio_out_pin=9
We rebooted, we installed lirc if it the demon are triggered we stopped it. Whether we checked our unit worked as a command:
[email protected] ~ $ of sudo mode2 – d/dev/lirc0
space 16777215 pulse 4534 space 4421 pulse 621 space 1642 pulse 582 space 1648
If digits spread when pushing buttons, the IR the receiver meant worked.
Now we considered the panel as a command:
[email protected] ~ $ of sudo irrecord tv_samsung.conf
Follow helps of the program and you to receive a config of tv_samsung.conf with a dial-up of the codes from your panel.
We moved the receiv config in / etc/lirc/remotes/.
Here my config for the main buttons:
[email protected] ~ $ of cat/etc/lirc/remotes/tv_samsung.conf
# Please make this file available to others # by sending it to <[email protected]> # # this config file was automatically generated # using lirc-0.9.1-git(default) on Tue Sep 3 19:29:12 2013 # # contributed by # # brand: /home/xbian/lircd2.conf # model no. of remote control: # devices being controlled by this remote: # begin remote name TV bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 4532 4422 one 591 1650 zero 591 540 ptrail 595 pre_data_bits 16 pre_data 0xE0E0 gap 107530 toggle_bit_mask 0x0 begin codes KEY_POWER 0x40BF KEY_UP 0x48B7 KEY_DOWN 0x08F7 KEY_VOLUMEUP 0xE01F KEY_VOLUMEDOWN 0xD02F KEY_MUTE 0xF00F end codes end remote
Now we will check up the transmitter. We launched a demon of lirc. To send an IR of a command it are possible:
[email protected] ~ $ of irsend SEND_ONCE TV KEY_POWER
SEND_ONCE — the directive to send an once
TV — the Name of the TV set from file/etc/lirc/remotes/tv_samsung.conf
KEY_POWER — a title of a command from file/etc/lirc/remotes/tv_samsung.conf
After execution of this command the TV set should turn on or be ungear, if all worked, we passed to control with phone.
The server who will accept HTTP requests are necessary to us and to execute a command of irsend, I for this purpose lifting Apache http server and adjusting execution of cgi-bin of scripts. In my distribution kit of Xbian it became in file/etc/apache2/sites-enabled/000-default, resolving execution of cgi-bin of scripts and specifying where for them to search
.... ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ....