Smartthings Infrared input via Arduino and ST Anything?

Hello,

I am not sure if this is correct place to put this question, but I would like to use unused buttons on my IR TV remote to control things in SmartThings. It seems like I could use an Arduino ESP32 with an IR receiver that would then communicate with SmartThings and allow me to setup lighting or control or whatever I want to control in SmartThings. Is this possible?

Tagging @obycode :sunglasses:

Sure, it is possible… :wink: But it is not something that ST_Anything currently supports. You would need to add this functionality yourself.

ST_Anything is capable of sending ‘pushed’ and ‘held’ button events to SmartThings. You would simply need to create a new ST_Anything device that was capable of receiving IR signals and then sending the appropriate button events to ST, similar to the way the current IS_Button ST_Anything device does based on physical buttons connected to digital inputs.

You could even start with IS_Button.h and IS_Button.cpp as a starting point to create your own IS_IR_Button device.

1 Like

I’m not really sure how this would work. do you think you could make a quick example of how that would work?

Since you’re not the OP, may I please ask what your specific use-case for this functionality would be? Also, what is your level of Arduino C/C++ programming experience? Have you used ST_Anything for any projects yet?

The reason I ask is because it is very hard for me to ‘make a quick example’ of something which is somewhat ambiguous to me in the first place. And, since I do not have the requisite hardware to build the original poster’s IR Receiver, I really can’t whip up a quick example of anything. It will require an IR library that is capable of receiving specific commands from an IR remote control, and then interpreting them so the Arduino would know which ‘button event’ to send to SmartThings.

3 Likes

Just FYI, There are some IR library for Arduino. They are pretty easy to use.

I try the library below for an Arduino sample sketch.

You want an IR receiver. They sound complex but in actuality it is quite simple circuit to make. The library will basically let you read IRCode (decode the code for those that are common). You will basically get a number that represent the button your press on the remote. Once you have this figure out, you can abstract it as button (Map the code to a button). Once you got this part working. @ogiewon is the expert on delivering those data back and forth through his ST_Anything.

I make Zigbee sensors. The last incarnation can perform as Thingshield. This is the reason that I play around with Arduino IR. If you are interested on a demo, PM me. I do not have it running on ST hub but in another hub.

Thanks
Iman

2 Likes

Thank you all for your replies. @ogiewon, @Sean_leonard is my son. He very interested in Arduino programming and has several units. He likes to help me with integration and automation. We have SmartThings at our house and I do a lot with Webcore. We have a room where I would like to control SmartThings controlled rooms lights, lamps and a ceiling fan with an existing IR remote. I have a V1 Hub so using a wireless remote such as the Ikea TradFri is apparently not possible. My example is a Samsung TV remote with the four colored buttons (Red, Green, Yellow, Blue) that in my case are not used for anything. It seems that it would be easy enough to capture those IR codes then use those codes initiate toggles or held commands in SmartThings. @iharyadi, thanks for your response. We just need a little bit of inspiration to get us started since.I know nothing about the programming of Arduino.

2 Likes

Do you have any coding experience?

If you do, here the sketch that got me started. Arduino code (file) is called sketch. I think it is intended to do something simple in C/C++ in one file. I am a C++ developer. This arrangement is weird to me. The beauty is the rest of the code is mostly library which has been donated.

If you set everything correctly, the sketch will run your Arduino and able to read code from majority of TV remote (not all). I would take a look that sketch and see whether it is do able for you. This is a check point. If this code is trivial to you, you should not have any issue with this IR project. Look into the void dump(decode_results *results) function. You got your IR code there. Then, from that code, you can adapt it to ST_Anything as @ogiewon mention about the button.

Those are the happy case. There will be some troubleshooting here and there to eventually get it to work.

Here is what I got with playing around with the IRRemote library.

Thanks
Iman

2 Likes

thanks @iharyadi, but I am not really sure how to add ST to this or where i could specify a hex code so it would not respond to any LG remote.

Delivering the code to ST is the other half of equation.

You may want to look @ogiewon sketch where he has abstraction of a button. Essentially you will have small map in your sketch which look like.

struct MapButton{
uint32_t lgCode,
uint8_t ndx
};
const MapButton mapButtons[5] { {code1,button1}… so on};

You collect the code that you are interested and fill the map. Every time you got an IR code and decode it, you look on the map and find which button that you want to call on the ST_Anything .

This is one way to do it. Just FYI…I did mine differently. I send the whole remote code to a custom DTH. The DTH will map it into a button press. This is not difficult to do. But, you will loose a lot of the great work @ogiewon has done in handling lower level detail of delivering the button press. In addition, He has a lot of DTH written on the ST side ready to use.