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!
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?
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".
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.
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 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
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
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.
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
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:
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.
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.