Consumer IR/en: различия между версиями

Материал из Wiren Board
(Новая страница: «After completing configuration, restart the service '''lirc''' and '''wb-mqtt-lirc''' <pre> root@wirenboard:~# service lirc restart && service wb-mqtt-lirc restar…»)
(Новая страница: «=== MQTT interface ===»)
Строка 56: Строка 56:
</pre>
</pre>


=== MQTT-интерфейс ===
=== MQTT interface ===


'''wb-mqtt-lirc''' создает устройство ''/devices/wb-lirc/'', принятые нажатия публикуются в топике ''/devices/wb-lirc/controls/Key'' в формате '''<название_пульта>:<название_кнопки>:<повтор>'''. После отпускания кнопки в этом топике публикуется сообщение с пустым телом.
'''wb-mqtt-lirc''' создает устройство ''/devices/wb-lirc/'', принятые нажатия публикуются в топике ''/devices/wb-lirc/controls/Key'' в формате '''<название_пульта>:<название_кнопки>:<повтор>'''. После отпускания кнопки в этом топике публикуется сообщение с пустым телом.

Версия 16:33, 3 июля 2019

Другие языки:

This article describes how to receive and transmit signals from home appliances that operate in the infrared (that is, most of the remotes from TVs, air conditioners, etc).

Hardware

IR receiver
IR transmitter

Warning! In revisions 5.8 and older IR-port (to connect the transceiver) is missing!

On Wiren Board 5 (before revision 5.6.1) the required signals are output to the 3.5 mm mini-jack connector with the following Pinout:

  • Tip (left audio channel) - 5V power/IR transmission.
  • Ring (right audio channel) - IR reception
  • Sleeve (ground) - ground

Pinout connector allows you to connect common IR receivers and transmitters from home appliances.

To receive IR signals, you need to connect the receiver (combined WB-CIR-TR transceiver). The nominal carrier frequency of the receiver must be approximately the same as the carrier frequency of the used remote control, otherwise the signal from the remote control may deteriorate or be completely impossible to receive.

To transmit IR signals it is recommended to use a ready combined IR transceiver WB-CIR-TR, Samsung IR Blaster bn96/26652a or similar.

Technical details

Mini-jack 3.5 mm Pinout on Wiren Board 5 :

  • Tip (left audio channel) - 5V power/IR transmission.
  • Ring (right audio channel) - IR reception
  • Sleeve (ground) - ground

To receive IR signals, receivers of the type TSOP1738, AX-1838HS or similar are used. The IR led is used to transmit IR signals, the current limiting resistor is not required (built into the controller) When transmitting, the supply voltage will be modulated by the transmitted signal and the carrier. The WB-CIR-TR transceiver contains a TSOP type receiver and an IR led. Parasite power is used to power the receiver.


Hardware

At the kernel level for the work with IR to Wiren Board 5 the driver meets the lirc-pwm. It provides the / dev/lirc1 device.

This device interacts with daemon lircd from package LIRC that provides decoding of the pulse sequence in the event pressed on the remote control buttons according to the configuration files, remotes. This daemon is also capable of performing a reverse conversion to transmit button push signals to controlled devices.

Finally, the stream of events from lircd in message MQTT and back runs the demon wb-mqtt-lirc

Installation and configuration

Required packages (wb-mqtt-lirc, lirc-scripts, wb-mqtt-lirc), as well as the correct config file /etc/lirc/hardware.conf is installed in a standard image starting from version 201512070633.

  • Download or generate the remote configuration file and put it in /etc/lirc/lircd.conf.d/.

Download ready remote config

root@wirenboard:~# irdb-get update
root@wirenboard:~# irdb-get find 687C
sony/RM-687C.lircd.conf
root@wirenboard:~# irdb-get download sony/RM-687C.lircd.conf
Downloaded https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/sony/RM-687C.lircd.conf as RM-687C.lircd.conf
root@wirenboard:~# mv RM-687C.lircd.conf /etc/lirc/lircd.conf.d/

Creating a new remote config

After completing configuration, restart the service lirc and wb-mqtt-lirc

root@wirenboard:~# service lirc restart && service wb-mqtt-lirc restart

MQTT interface

wb-mqtt-lirc создает устройство /devices/wb-lirc/, принятые нажатия публикуются в топике /devices/wb-lirc/controls/Key в формате <название_пульта>:<название_кнопки>:<повтор>. После отпускания кнопки в этом топике публикуется сообщение с пустым телом.

Пример:

root@wirenboard:~# mosquitto_sub -v -t '/devices/wb-lirc/#'
/devices/wb-lirc/meta/name IR Remote Control
/devices/wb-lirc/controls/Key/meta/order 1
/devices/wb-lirc/controls/Key/meta/type text
/devices/wb-lirc/controls/Key Sony_RM-687C:KEY_7:0
/devices/wb-lirc/controls/Key Sony_RM-687C:KEY_7:1
/devices/wb-lirc/controls/Key Sony_RM-687C:KEY_7:2
/devices/wb-lirc/controls/Key Sony_RM-687C:KEY_7:3
/devices/wb-lirc/controls/Key (null)

Для отправки нажатия кнопки следует опубликовать сообщение в формате <название_пульта>:<название_кнопки> в топике /devices/wb-lirc/controls/Key/on

Устранение неисправностей

Не работает прием

  • Убедиться что драйвер "видит" импульсы от приемника.
    • Остановить сервис lirc (командой service lirc stop)
    • root@wirenboard:~# mode2 -d /dev/lirc1
      Должны бежать цифры при нажатии кнопок на пульте, если нет - проблема в "железе" или в несоответствии несущей пульта и приемника. Следует попробовать использовать другой приемник.
  • Убедиться что lirc может декодировать последовательности импульсов согласно конфигу пульта:
    • Запустить обратно lirc (service lirc start)
    • root@wirenboard:~# irw
      Должные бежать строчки при нажатии кнопок на пульте. Если mode2 работает, а irw - нет, то проблема с конфигом пульта. Стоит попробовать использовать другой конфиг, либо создать новый.

Не работает передача

  • Попробовать передавать обращаясь к LIRC напрямую:
root@wirenboard:~# irsend SEND_START Sony_RM-687C KEY_3
...
root@wirenboard:~# irsend SEND_STOP Sony_RM-687C KEY_3

(названия пульта и кнопки должны соответствовать используемому конфигу).

  • Убедиться что аппаратная часть работает - например, можно посмотреть на ИК-светодиод через камеру смартфона (светодиод должен мигать при передаче)