Samuel Gfeller
Samuel Gfeller

Reputation: 1010

Can I use android phone with IR to control light stripe

I have a LED stripe with a classic IR controller (image) and asked myself if I could control it with my Samsung Galaxy s21 Ultra which can emit infra-red light for its ToF camera. Now there are two issues.

  1. Does Samsung provide an API access to control this IR emitter? (The remote control apps I downloaded all say that the phone doesn't have the necessary hardware (IR) for this)?
  2. Is it physically possible, would the IR beam be even strong enough to control the LED stripe driver?

Upvotes: 0

Views: 1406

Answers (3)

itdoq
itdoq

Reputation: 11

It is definitely possible! You'll be able to control your LED devices with IRDA receiver (typical LED stripes/lamps from Amazon/Aliexpress/TEMU etc.) with Android, even from scripts or an Android remote SSH terminal (for sure, having the device pointed to its IR beam to a target IR receiver)! I managed to do that. U'll need:

  • Termux + Termux API installed from F-Droid (recommended rather than from Google Play) on your Android;
  • Android app like irplus : it will allow you to send IR signals. Unfortunately, you'll have to guess-chose the compatible controller from lists there (likely in LED name group), but don't give up, you'll recognize layout needed by an external look, same as IRDA remote, which usually goes in a product set. It took 2 attempts for me. Export the corresponding device codes, in my case it appeared compatible with Led Lights - Liluco remote controls, which is a very typical layout for the "noname" LED strips; before export layout code, tick the Export with native codes
  • after that, pick the exported file (in my case LED Lights - Liluco.irplus) and open with e.g Notepad, you'll see:
<irplus>
 <device manufacturer="LED Lights" model="Liluco" columns="4" format="WINLIRC_RAW">
  <button label="&#61829;-" labelSize="25.0" labelColor="FF000000" backgroundColor="FFFFFFFF">9022 4498 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 572 572 1690 572 1690 572 1690 572 1690 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 39702 9022 2262 572 95992</button>
  <button label="&#61829;+" labelSize="25.0" labelColor="FF000000" backgroundColor="FFFFFFFF">9022 4498 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 572 572 1690 572 1690 572 1690 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 39702 9022 2262 572 95992</button>
  <button label="OFF" labelSize="18.0">9022 4498 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 572 572 1690 572 1690 572 1690 572 572 572 1690 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 572 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 39702 9022 2262 572 95992</button>
  <button label="ON" labelSize="25.0" backgroundColor="FFED2E33">9022 4498 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 572 572 1690 572 1690 572 1690 572 1690 572 1690 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 39702 9022 2262 572 95992</button>
...
  <button label="SMOOTH" labelSize="18.0">9022 4498 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 1690 572 1690 572 1690 572 572 572 1690 572 1690 572 1690 572 1690 572 1690 572 1690 572 572 572 1690 572 572 572 572 572 572 572 572 572 572 572 572 572 1690 572 572 572 1690 572 1690 572 1690 572 39702 9022 2262 572 95992</button>
 </device>
</irplus>

Almost there! This way you'll be able to filter out all the codes needed to form corresponding shell/bash aliases for every control action, including power ON/OFF, Volume Up/Down, etc. Frequency 38000 (38kHz):

alias led-dn='termux-infrared-transmit -f 38000 9022,4498,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,572,572,1690,572,1690,572,1690,572,1690,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,39702,9022,2262,572,95992'
alias led-up='termux-infrared-transmit -f 38000 9022,4498,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,572,572,1690,572,1690,572,1690,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,39702,9022,2262,572,95992'
alias led-off='termux-infrared-transmit -f 38000 9022,4498,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,572,572,1690,572,1690,572,1690,572,572,572,1690,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,572,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,39702,9022,2262,572,95992'
alias led-on='termux-infrared-transmit -f 38000 9022,4498,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,572,572,1690,572,1690,572,1690,572,1690,572,1690,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,39702,9022,2262,572,95992'
...
alias led-smooth='termux-infrared-transmit -f 38000 9022,4498,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,1690,572,1690,572,1690,572,572,572,1690,572,1690,572,1690,572,1690,572,1690,572,1690,572,572,572,1690,572,572,572,572,572,572,572,572,572,572,572,572,572,1690,572,572,572,1690,572,1690,572,1690,572,39702,9022,2262,572,95992'

I believe you can use same approach to control any other device. I'm posting this just for humanity, cause love Termux a lot, but absolutely NO ANY info anywhere on how to use some of the API methods including IRDA =))) Enjoy!

Upvotes: 1

Eddy Talvala
Eddy Talvala

Reputation: 18137

This is unlikely. The ToF IR pulse has to be very specific in length and shape, and likely controlled at the very low level (possibly by the sensor hardware itself).

So it's not likely that there's a way to customize the pulse shape or duration.

Upvotes: 1

C B J
C B J

Reputation: 1868

Well, it might be possible to turn the IR emitter on and off via some api (maybe the standard camera2 API or a special Samsung API) but IR transmitters commonly use a transmitting protocol which requires quite fast switching. That might be difficult.

There is some fairly detailed information about some IR Remote control protocols here: Data Formats for IR Remote Control from Vishay Semiconductors

I have seen projects which use the headphone socket of older phones connected to an IR LED to emit RC commands by outputting the signal as Audio.. pretty neat.

Upvotes: 1

Related Questions