Issue with an IR led I'm trying to use to make a vizio remote

Recently I was trying to make an remote for my vizio tv. I obtained the power code for vizio which is “20DF10EF” and I send it at 32 bits. For my code I used the IRremote library by shirriff. My schematic includes, a button (I used 10k ohms resistor on it, and connected it to 5v and the ground), an ir led (connected to 3.3v, two 330 ohms parallel resistors which = 165 ohms; using ohms law this means I’m supplying it with 20 milliamps), and an ir receiver.

My problem is that when I use the .sendNEC method, my IR led, doesn’t turn on or send any code to the IR receiver. However, when I created a variable for the irled pin (which is always at 3 for this library), and set it to high, it turns on and the IR receiver receives random values. Using my phone’s camera I can see the purplish glow of the led.

I have attached a file including my code below. I don’t think this is a problem with the schematic as I copied it from a video from Dronebot Workshop. If anyone can help me I’d be very grateful and willing to provide any additional info towards solving this.

vizioRemote2.ino (1.05 KB)

I don't think you should be doing anything with D3. It will be used as timer output, and the library will control it.

You say the power code is 20DF10EF, but you are sending only DF10EF. Why is that?

During testing, it may help to temporarily replace the IR LED with a regular red LED so you can at least confirm that it's flashing.

You may need a lot more current than 20mA. But I think it should work well enough to confirm it's working right if you get very close to the Vizio's IR receiver.

You are sure about the code? Do you have a working Vizio remote that you could capture?

I would like to see the schematic.

Thank you for taking the time to check out my problem.

I accidentally left out the "20" in the power code.

I also incorrectly said that I connected the IR led to 3.3v. It is only connected to pin 3 and the Ground.

I replaced the IR led with a normal led and it did work. Also when I set the IR led to high, it does turn on so I know it works when I press the button

I don't own a vizio remote but I know the code because my friend has a phone with an IR blaster which he pointed at my IR receiver.

Also do you think its necessary for me to output an array with raw data?

I'm not good at drawing schematics but I tried to draw one. It is attached below:

So it still doesn't work when you add the "20" back in to your power code?

When you say "IR receiver", are you referring to the TV's IR detector? Does your friend's blaster turn on your TV?

The drawing looks ok. And the regular LED confirms it's putting out a code. That's assuming you don't have the IR LED oriented backwards. So it seems the code is not right. I've never had any luck with raw data in IRremote. , so I don't know what to suggest about that.

In the past I've always had a working remote that I know works with the TV, and I capture its output on my scope. I can derive the 32-bit hex value from that. But the IR receive function in your sketch should do the same thing.

I really don't have a solution for you, but it does seem the code may not be right.

Edit: Well it does seem to be the right code. I found this site that has the Vizio codes, and the power code matches yours. So I don't know what's wrong.

Have you tried commenting out all the "Receiver" code in your sketch (in loop() and setup()) to see if you still have the same effect ?

The way you've drawn the button (1:1 from the bread board) looks like the classic rotation problem, but that could simply be your illustration. If you have substituted the IR led with a regular led and that flashes when you press the button , then all is well there.

If you have a second arduino, configured as an IR receiver, you can see what comes through when you attempt to send the code.

@ShermanP:

When I referred to the "IR receiver" I meant the receiver that comes with the arduino kit, not the one on the tv.

My friend's IR blaster was able to turn my tv on and do other things such as raising the volume.

I'm sure its the code that's wrong. I've seen other posts on forums where people have outputted raw data, so I think I'll give that a try. Only thing is, I'm not too sure about how to incorporate my data into the void loop. Would I have to use the .sendRaw method after my .sendNEC method?

@6v6gt:

I tried commenting out the code intended for the IR Receiver. My IR led still didn't work after doing that.

The button works. I've substituted my IR led with a normal one and it turned on as intended.

I do have an IR receiver connected to my Arduino but its not picking anything up whenever I press the button.

All in all, I'm going to try using raw data. Would additional delays be necessary?

david_v10:
. . .

I do have an IR receiver connected to my Arduino but its not picking anything up whenever I press the button.
. . .

Yes, but if you are attempting use the same arduino for both transmitting and receiving, you will be disappointed. The transmitted IR signal has already been and gone before the receiver part even has a chance to see it. For that test, you need two Arduinos.

Well I would try it with the TV. If you get close enough, it may work.

So you are saying you captured the IR blaster with your Arduino in receiver mode, and that code was the result? If the blaster also turns on the TV, it almost has to be the right code.

Could you just try reversing the leads of the IR LED? We know the regular LED is oriented correctly because it blinks, but it wouldn’t hurt to try the IR LED both ways.

I looked at the examples in the IRremote library, and there’s one called IRSendRawDemo.ino. What’s sent is the NEC-32 code to turn on an LG TV. Guess what that code is. I’d suggest you just run that example and see if it turns on your TV. I’m not sure the NEC and LG formats are the same, but it also wouldn’t hurt to try sending the hex code as an LG code - the library supports LG.

That site I found has this info about the Vizio power code:

Power:
One line: 20DF10EF:NEC:32
uint16_t  rawData[67] = {9000,4526, 552,576, 554,578,
552,1686, 552,578, 552,578, 554,578, 552,552, 578,578,
554,1682, 554,1684, 552,578, 552,1684, 552,1684, 552,1684,
552,1684, 552,1684, 554,578, 552,578, 552,578, 554,1682,
554,578, 554,578, 660,470, 554,578, 552,1684, 552,1684,
552,1684, 552,558, 572,1684, 554,1682, 554,1684, 552,1682,
554};  // NEC 20DF10EF
uint32_t  address = 0x4;
uint32_t  command = 0x8;
uint64_t  data = 0x20DF10EF;

The raw data appears to be the same as the example, except the example has four additional oddball values at the end. You could try the example as is, and then try removing the last four values.

Something has to work. :slight_smile:

@6v6gt:

Thanks for letting me know! What I would do was check if the receiver was getting anything, use my phone’s camera to see if the led was turning on, and also point it at my tv to see if it worked.

@Sherman P:

I’m sure I have the right code

I tried reversing the led but it still didn’t function as intended.

I saw another forum of a guy who had a similar problem but with an LG tv. I added delays where he did and sent the data in the order he did, but my IR led isn’t turning on when I press my button (I check if it turns on using my phone’s camera.)

At this point I really don’t know what to do. I have attached the code below if anyone can point out anything wrong.

vizioRemote2.ino (1.05 KB)

So are you saying a regular LED blinks, but the IR LED doesn't show up in your camera?

Have you tried the example sketch I referred to? Does the IR LED show in the camera with that?

Can you tell us anything about the IR LED? A link to it perhaps.

Logically, I think the first step is to make sure the IR LED lights up running at least one example sketch from the library. There's no point worrying about your code until you know the IR LED is good.

I would also say that you aren't running a lot of power through the LED, so the flashing may be very dim in your camera.

Edit: Ok, I tried my phone's camera with the remote for my TV, and it showed up reasonably well. Then I tried a remote I built for my Roku box which runs 200mA through the IR LED, and I had to turn the lights out to see it at all. It was very dim. I suspect the TV remote draws close to an amp of current. Your circuit at 3.3V actually only runs about 11mA through the LED. So I think the problem is your phone camera just can't pick it up. Cameras do have IR filters, but they aren't perfect, so that's why you can see IR at all. But it doesn't see IR anywhere near as well as visible light. I think the better test is to get the top of your IR LED right up next to the TV sensor.

If that doesn't work, then you may have to experiment with using a transistor to drive the LED. But I'm confused about the 3.3V. The Mega 2560 is a 5V board. So isn't the D3 output 5V? If so, then you do have 21mA, but that's still a tenth of my 200mA that my phone camera can barely see.

It just hit me that you are using pin D3, but your drawing says you're using a Mega 2560. D3 is the default transmit pin for the Uno, Nano and Pro Mini, but Arduinos using other processors default to other pins. The README for the library says the possible transmit pins for the Atmega2560 are 5, 6, 9, 11 and 46, and it shows D9 is the default. And yet you say a regular LED on D3 lights up when you push the button. So I'm confused again. Can you explain?

I don't have a Mega or an extra IR LED, but I will compile and run your code on a Nano sometime today to make sure it works there.

When I change the statement inside the "if" block to "digitalWrite(ledTest, HIGH);" the IR led turns on and I can see it on my phone's camera.

I tried the sketch you referred to but the IR Led still didn't appear to light up on my camera. Furthermore, I know where the receiver is located on my Vizio Tv and I pointed my IR Led at it, but the tv didn't turn on.

I removed the IR Led from an old control I don't use. I tried out the control before removing the IR Led, and it did work.

In addition to running the LG code from the "irsendRawDemo". I also tried the Sony power code which is provided in the "irsendDemo", but it failed to turn either of my two Sony TVs.

I should also point out that my IR led isn't hooked up to 3.3v. I haven't connected the 3.3v pin to anything. When I said that earlier, it was by mistake.

I'm starting to think the IR led I have is the problem. As absurd as this may sound, perhaps it can't send codes that aren't of its manufacturer type?

[EDIT]

@SHerman P

You were right!!!!

Pin 9 was the one that worked for me. I was able to turn my TV on with the irsendRawDemo.

I cannot thank you enough as I couldn't figure out what was wrong for several days.

Hopefully someone finds this in the future and it helps them out

Well now we know everything works. For future reference, this line added to your code will display what the IR send pin is:

Serial.print("IR send pin = "); Serial.println(IR_SEND_PIN);

But if you want to implement any other buttons beside the power button, it would be convenient to get the 32-bit hex version working instead of having to use the raw data. So you might go back and give that a try.

Also, I see the library now has a new function called "sendNECStandard", and instead of the 32-bit hex value, you can just send the address and the command. Per that Vizio code listing I found (see above), the power button is address = 4, command = 8. So you could just do:

irsend.sendNECStandard(4,8);

On my Nano test rig with my scope hooked up to D3, it looks like that sends the same sequence as the 32-bit hex value. The commands for all the other buttons are on that listing. The address is always 4, so that would simplify things for setting up other buttons.

If you find that you don't have enough power to get consistent results with the TV from where you normally sit, then you'll need to consider using a transistor to power the LED. We can help with that, but would need to know how your Mega is powered, and whether you have transistors and resistors on hand, and whether by chance you have another old remote that you could scavange a second IR LED from.

By the way, a Mega is kinda overkill for something like a TV remote control. At some point you may want to transfer it to something like a Nano or Pro Mini, and save your Mega for more demanding things.

I'll consider using the NECStandard over the 32 bit hex. Thank you for letting me know about that.

I don't happen to have any transistors on me at the moment but my couch is pretty close to my tv so I haven't been using the remote from far.

In regards to the remote, the MEGA 2560 is the only processor I have at the moment. I look forward to get a Nano soon.