IRremote Infrared Transmitting for IOT Device Control

I recently bought an IR transmitter/receiver pair with the intention of creating my own universal remote to control devices around my room. I have managed to get and store all the IR HEX codes via the receiver without any problems. However the issue now is that I cannot seem to transmit these codes.

I can see there are various parts of the library including sendNEC, sendSony etc. However my devices are a Hitachi TV, OrbitSound speaker, and LED strips, fan and A/C unit from more niche brands so none of those "send..." variations apply to me. Does that mean this task is not possible? Surely there is a way to send the signal if their natural remotes are already doing it in the first place.

The code I'm currently using as per a tutorial is the following, however it does not work:

#include <IRremote.hpp>
IRsend irsend(3);
void setup(){
  Serial.begin(9600);
}
void loop(){
  for (int i=0; i<10; i++){
    irsend.sendNEC(0x639C7F80, 32); // AC on
    Serial.println("AC on");
    delay(2000);
  }
}

It's worth noting that I have also connected the receiver and merged the code with the above to test if it was transmitting anything and it does, sometimes there are various codes but 90% of the time it returns 1FE39C6 which of course isn't the intention, but is this simply a encoding issue then?

Disclaimer: I am new, very new, to Arduino so if there are any obvious answers or silly things I'm not understanding please bear with! :slight_smile:

What about the library example sketches?

How do you know that the transmitter hardware is connected correctly and working?

The transmitter just has 3 pins, I have connected them to 5V, ground, and pin 3 on the Elegoo Mega directly without the use of a breadboard. I assume that's correct?

Don't try to use words. Show us.
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#schematics-or-circuit-diagrams

"the transmitter" - there must be hundreds of different kinds. What do you have? Show us.

What is "a tutorial"? Show us.

  1. Tutorial: Using IR Signals to Control TV - YouTube

  2. I am aware there are hundreds of different kinds which is why I did show you, I literally linked the transmitter in the original question.

  3. Here it is without words, it's a very basic setup, hence the use of words. Have tried with breadboard and without. https://arduinomodules.info/wp-content/uploads/Arduino_KY-005_Keyes_Infrared_transmitter_module_connection_diagram-1024x568.png

People have said stuff like that here hundreds of times, and then it turned out they missed some detail. Even when they say, "I followed the diagram exactly". :slight_smile:

In fact, looking at the diagram and transmitter that you posted, I can see that they don't use the same transmitter. So that is not helpful.

Your best move would be to post a clear photo of your connections.

Keep in mind, your stated issue is, "it won't transmit".

Edit - since you did a loopback test, it appears to prove that it works, but that wouldn't test the long range results. Did you use two Arduinos for that?

As a first day user your replies are limited in number by the forum software. So it's important to convey as much as you can in each reply.

I would call that unreliable operation. I haven't seen what you did yet, so I will withhold judgement until I do.

In the Amazon link the transmitter is called a receiver and the receiver is called a transmitter. It doesn't exactly inspire confidence.

Correct, it's a KY-005 in the diagram but since there were no diagrams using my transmitter, and it of course has the exact same pins, I assumed it would be more than helpful. Because as new as I am, I'm not going to connect 5V to anywhere else but 5V, or ground to anywhere but ground :slight_smile: I'm posting here from my PC and are unable to take a picture hence the diagram which is why I explicitly tried to describe my connections. It is simply 3 wires, going from GRD->GRD, VCC->5V, DAT->pin 3.

Further down in the question details I did mention that it is transmitting, but not the right code, which is why I asked if it was an encoding problem. Or if I was even looking in the right place by using sendNEC? Because there are several different protocols so I'm wondering if my error is there?

I haven't managed to test long range but the A/C unit is 1ft away from the Arduino setup so it would definitely reach, however I'm pretty sure the reason it's not responding is because the IR code from the decodedIRData.decodedRawData line is different from the one I'm sending. I just don't understand how it is going from 639C7F80 to 1FE39C6

Have you successfully received codes using the receiver? How did you do that? The code you posted won't do it.

Yes, I didn't want to overcomplicate the original question but this is a version I used for the loopback test:

#include <IRremote.hpp> //include the library
IRrecv IR(13);
IRsend irsend(3);

void setup(){
  IR.enableIRIn();
  Serial.begin(9600);
}

void loop(){
    irsend.sendNEC(0x639C7F80, 32); // AC on
    Serial.println("AC on");

    if (IR.decode()){
      Serial.println(IR.decodedIRData.decodedRawData, HEX);
      delay(1000);
      IR.resume();
    }
    delay(2000);
}

This is what's returned in the serial monitor:

A�on
1FE39C6
AC on
AC on
1FE39C6
AC on
�on
1FE39C6
AC on
AC on
3ADDA97D
AC on
AC on
1FE39C6
AC on
�on
1FE39C6

Looping back on the same processor isn't a good test. The TX/RX is interrupt driven, but even so, it's too much to expect simultaneous TX and RX. That is why I asked about two Arduinos.

Not only can there be software timing conflicts, but the TX signal can "leak" into the RX through the power supply, even if no light is emitted.

Ah, would that explain why sometimes even the "AC on" isn't even output correctly? So many occasions it'll show "�on" or another partial variation.

Unfortunately I don't have another Arduino to test on. Although given the consistency of 1FE39C6 coming up 80-90% of the time, I'm guessing that'd be the uninterrupted version that's initially being transmitted? As it's the only version that repeats, any other output is a one-off string so appears an evident anomaly

You are not surprised that you send one code

and receive another?

why not buy it, it costs a couple of dollars in total

And one more note - for the first tests, try to control not the air conditioner, but the TV.
Air conditioners are a special group, to control them, as a rule, it is not enough to send an intercepted code.

Yes, everyone should have a small pile of disposable clones.

The first test was on my TV but that yielded the same result, I was sending the code "10D0" which for my Hitachi TV is Vol+, and 9/10 times the response my receiver was getting was:

B08000j
AC on
AC n
B0800�j
AC on
AC �5
B0800�j

I don't understand what's causing different codes to be received, am I simply using the wrong library in sendNEC? Or am I not running a decode function I need to be running?

Also I intend to purchase another Arduino but today is my first day using one, so I haven't had time to and was hoping I could solve this problem without

I told you, your loopback test is likely invalid.

Okay, so my hunch was right about it being transmitted/encoded wrongly, after changing the receiver results to be more detailed as well as show the protocol, I was able to gather the following info:

Protocol=NEC Address=0x1 Command=0x3 Raw-Data=0xFC03FE01 32 bits LSB first

Therefore I changed the sendNEC line in the transmitter code to the following:

irsend.sendNEC(0x1, 0x3, 2); // AC on

I bought a new Arduino by the way, and put the receiver on that, the loopback test went exactly the same way. I believe the varying results were simply down to distance/interference between the two, as I don't think the transmitter will work well beyond 5-10cm.

Now, both when pressing the button on the remote, and by receiving my transmitter's value, we get the same outcome from both.

Protocol=NEC Address=0x1 Command=0x3 Raw-Data=0xFC03FE01 32 bits LSB first

This suggests the transmitter code is now correct and everything is working as it should be, however this still doesn't turn on my devices.
As I said before, I don't think the range is more than 5-10cm because as soon as you pull the transmitter and receiver apart further than that, it starts showing different transmissions.

I can't test this on my soundbar or A/C unit because I can't locate exactly where the receivers are, so cannot get within the 5cm range. The one on my TV however is clear, but it uses a different protocol (RC5) and I'm not sure which function sends that?

So two questions remain:

  1. How can I send RC5 protocols with the IRremote library? It's stated as a supported protocol here, and it must be for the receiver side to know it's RC5. However there's no sendRC5 function like there is sendNEC.
  2. What Arduino-compatible IR transmitters are there that are more heavy-duty? Ideally supporting 10m in range to future-proof it, however 2-3m (6-10ft) will suffice for current projects.

That's right. You bought the transmitters without transistor drivers. Those can't provide the normal amount of current for a typical IR LED. Just get some that have the transistor. I bought a few recently from an Asian vendor site. They are maybe 5 times more powerful.

What about the RC5 part? Any ideas on that? Because if I can transmit the TV's IR command successfully I can put that right in front of the TV's receiver and verify once and for all if everything works.

As for the transmitters with transistor drivers I'm currently doing some googling but I don't have any idea really what you mean or what one looks like. Also you mentioned buying one from an Asian vendor site, are there none available on Amazon? I like instant delivery haha.

Does yours have the small 3 terminal part labeled, "J3Y" on this device? Is the module same or different?
https://www.aliexpress.com/item/32861772061.html