How to add IR remote support on VIM4?

We want to use an IR remote for our application running on a VIM4 board.
However, we noticed that VIM3 board has 2-channel IR receiver, whereas VIM4 board does not have any in-built IR receiver.
Can you please guide us on how to add this support and how can we use the IR remote with the VIM4 board?
Thank you

You can attach an external IR module to 40PIN Header PIN39 which is IR_IN pin.

Hello, thanks for the suggestion.
Can you also suggest any compatible IR module?

Android firmware turns on IR by default. Therefore, khadas IR (IRM-3638N3) remote control is supported by default.
If you want to add other IR remote controls, please refer to the following addition:

How to add IR for VIM4

This guide is about how to add IR on Android.

Hardware Connectity

IR_IN(Infrared remote control output) pin in 40 pins header is pin39 GPIOD_15:

Software Configuration

  1. Add the mapping from remote control code value to key value, enable remote control driver configuration in common/arch/arm64/boot/dts/amlogic/meson-ir-map.dtsi:
--- a/arch/arm64/boot/dts/amlogic/meson-ir-map.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-ir-map.dtsi
@@ -6,11 +6,12 @@
 / {
        custom_maps: custom_maps {
-               mapnum = <4>;
+               mapnum = <5>;
                map0 = <&map_0>;
                map1 = <&map_1>;
                map2 = <&map_2>;
                map3 = <&map_3>;
+               map4 = <&map_4>;
                map_0: map_0{
                        mapname = "amlogic-remote-1";
                        customcode = <0xfb04>;
@@ -199,5 +200,27 @@
                                REMOTE_KEY(0x49, KEY_YELLOW)
                                REMOTE_KEY(0x4C, KEY_BLUE)>;
+               map_4: map_4{
+                       mapname = "amlogic-remote-khadas";
+                       customcode = <0xff00>;
+                       release_delay = <80>;
+                       vendor = <0x0003>;
+                       product = <0x0003>;
+                       version = <0x0300>;
+                       size  = <13>;
+                       keymap = <REMOTE_KEY(0x14,KEY_POWER)
+                               REMOTE_KEY(0x13,KEY_MENU)
+                               REMOTE_KEY(0x03,KEY_UP)
+                               REMOTE_KEY(0x02,KEY_DOWN)
+                               REMOTE_KEY(0x0e,KEY_LEFT)
+                               REMOTE_KEY(0x1a,KEY_RIGHT)
+                               REMOTE_KEY(0x07,KEY_ENTER)
+                               REMOTE_KEY(0x58,KEY_VOLUMEDOWN)
+                               REMOTE_KEY(0x5c,KEY_F5)
+                               REMOTE_KEY(0x5b,KEY_F5)
+                               REMOTE_KEY(0x0b,KEY_VOLUMEUP)
+                               REMOTE_KEY(0x01,KEY_BACK)
+                               REMOTE_KEY(0x48,KEY_HOME)>;
+               };
  1. Add Android kl file:
  • Record the ID number of your infrared device, such as the ID number added in the previous steps (as vendor=0x0003, product=0x0003)
+                       vendor = <0x0003>;
+                       product = <0x0003>;
  • Create one new files:device/khadas/common/keyboards/Vendor_xxxx_Product_xxxx.kl (as Vendor_0003_Product_0003.kl)
vi device/khadas/kVIM4/files/Vendor_0003_Product_0003.kl
key 116   POWER
key 139   MENU
key 103   DPAD_UP
key 108   DPAD_DOWN
key 105   DPAD_LEFT
key 106   DPAD_RIGHT
key 232    DPAD_CENTER
key 114   VOLUME_DOWN
key 63   F5
key 115   VOLUME_UP
key 158     BACK
key 102   HOME
  • Check if pairing was successful
kvim4:/ # dumpsys input
INPUT MANAGER (dumpsys input)

Input Manager State:
  Interactive: true
  System UI Visibility: 0x8708
  Pointer Speed: 0
  Pointer Gestures Enabled: true
  Show Touches: false
  Pointer Capture Enabled: false
    8: ir_keypad
      Classes: 0x00000029
      Path: /dev/input/event6
      Enabled: true
      Descriptor: a6893ab22828f3b8b792fe40bc0d6df2b2725f26
      Location: keypad/input0
      ControllerNumber: 0
      Identifier: bus=0x0010, vendor=0x0003, product=0x0003, version=0x0300
      KeyLayoutFile: /vendor/usr/keylayout/Vendor_0003_Product_0003.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      HaveKeyboardLayoutOverlay: false
      VideoDevice: <none>  

As shown above, when the value KeyLayoutFile: is followed by the .kl file name Vendor_0003_Product_0003.kl, pairing is successful.

Hello, thanks for the detailed explanation.
However, can you also suggest which IR receiver module will be compatible with VIM4 board?
Can you share any specific brands or specs that we can purchase?

We used this infrared receiver + khadas infrared remote controller to verify.

Which external IR module we need to purchase for this? Is it available from Khadas?
Can you send the part number/module number? @numbqq

Hello @Parul

As @goenjoy mentioned, you can use IRM-3638N3.


@goenjoy and @numbqq, can you share the IR module number which is inbuilt in VIM3 board?
So, whether this module is compatible for VIM4 ?
We have got some Khadas remote and this is working fine with the VIM3 board. So, I suppose it will work the same way with VIM4 as well.
Can you pls suggest?

@numbqq @goenjoy
IRM-3638N3 does not seem to be easily available. Is there any other compatible IR receiver which works with Khadas remote control on VIM4?


The IR module number which is inbuilt in VIM3 board is IRM-V838M3-C/TR1.
VIM4 only reserved the PIN of IR interface on the 40PIN Header. No matter which type of IR receiver you use, you need to build circuit for it (power supply, filter capacitor, etc.).

@Totti , can you share a sample circuit for any generic IR receiver for the VIM4 device, for our reference ?

Pllease refer to the following figure:

@Totti , thanks for the sample circuit.
The suggested 2 IR receivers are not available here locally and also for shipping.
However, I got 2 IR receivers in the local market: TSOP1738 and TSOP1838.

Can you please suggest if any of these can be suitable for VIM4 device and if we can use the above circuit to interface the same?

We cannot judge whether they can be used only by the model. Please provide detailed device specifications.

@jasonl @goenjoy @numbqq @Totti

We need to get Khadas IR remote working with Khadas VIM4 for a demo.
We can nowhere find the recommended IR receiver i.e. IRM-3638N3, can Khadas help in providing this IR receiver or even a board with IR receiver which can work with VIM4? or some alternative component?

This is critical component for the demo. Please help.

@Totti , below links provide the specifications of the 2 sensors that are available in the local market.

Kindly check and let us know if any of these sensors would be suitable for VIM4 board.

The TSOP1838 will be OK;
The Operating Voltage can be set to 3.3V;

Thanks for your quick reply!!
We will check & try that.

@Totti We have implemented the circuit as you suggested using TSOP1838 and it’s working (IR remote is working)

But now while operating remote with VIM4 board some function are not working.

1.Home key not working (we are not able access home function using remote)
2.Virtual Keyboard (we are not able to access virtual keyboard using remote)
3.Settings App (we are not able to select any option in setting)
3.Permission Pop-up Allow/Deny (we are not able to select Allow/Deny option for Application’s using remote)