The Flipper Zero is an amazing little tool. Or is it a fun toy? One of the features of the Flipper is Infra Red transmit and receive. One of the built in apps is a “universal TV remote” with a library of many TV and appliance models to let you do basic functions like on/off, volume, channel, and mute. It works well in a room but there is the obvious question of what is the range and I wonder if I could supercharge it to work on TVs in the neighborhood?
First some background. Flipper did an awesomesauce blog post about how IR signals work. Read this first and then come back here. I’ll wait.
So the goal is a higher powered external IR emitter. We can divide this task into hardware and software. First the software.
There are internal LED emitters in the Flipper controlled by an IO pin somehow from the app. I figured they bit banged it and all I had to do was find where they specified the pin and add one of the external GPIO pins to it. That way it would work both internal and external. Once I dove in I saw they actually used a DMA channel to send the data. DMA is Direct Memory Access or special hardware in the microcontroller that can move data around on it’s own so the CPU isn’t spending it’s time with such a mundane task. It can also be used with peripherals and I assume to also provide accurate timing of the signals which is important. So then I started looking to see where they specified the pin so that I could use the external GPIO instead. I got lucky and saw right away they have a DEBUG switch in the code to do just this. All I had to do was enable the #ifdef switch and rebuild the firmware. Also it looks like between the time they used the debug switch and now they refactored the pin names and prepended LL_ to them. No biggy, it compiles now and voila! Data coming out of GPIO-7 now. Now on to the hardware.
So for hardware I will need a transistor to drive it and I remembered I had saved a high power IR emitter from a laser when the Kyber crystal died. (not an actual Jedi Kyber crystal but a KT crystal in this case I think it was KTA or potasium-mumble-arsenic or something. I could google for it and try to impress you or you can google it yourself. This magic crystal generates a green laser when excited with a lower wavelength, in this case an IR LED). I went to my box of flashlight parts and fount a reflector that perfectly fit the emitter. Great!
Next I needed to wire up the FET so I went to my box of FETs and found a couple with gate threshold voltage from 2-4 volts and I figured that was perfect for 3.3v GPIO voltage. Except it wasn’t. It didn’t work. I cobbled up a test circuit on a breadboard and still no joy. It worked at 5V not 3.3. So grrr, I had used HEXFETs before with directly logic so off to Digi Key and $3 each I got a few of these that say specifically “Optimized for Logic Level Drive” .
In the meantime not trusting my junk box emitter and wanting something in a better package for use in the field I went to ebay to look for a cheap IR flashlight. I hit the jackpot with this one. It even came with the 18650 battery and USB charger as well as to 2 tail caps, one with an On/Off button and one with an external thumb switch to attach to your gun when using it with the *included* pictinny mount. All for $23!
With the flashlight I have the power source built in and a convenient coiled wire to connect it to my board once I snipped off the thumb switch. They claim 10 watts but I don’t see it drawing that much power. Four or five watts maybe. Still not bad though. It also lets you focus the beam like this (with IR camera):
Before I wire it up (and while waiting for the HEXFETs to arrive) I had time to worry about the driver. Most LED lights of any significant power have some kind of driver board. I was familiar with some open source drivers like the Guppy2 and if it had any kind of smart driver I probably could not modulate it at the 37 KHz required for IR signals.
Opening it up I found it had 3 constant current driver AMC7135 chips. This is why I suspect the 10 watt rating is exaggerated a wee bit. Three times 350 mA each is a little over 1 Amp times 4 volts is about 5 watts being generous.
The good news is they are apparently designed for PWM up to 100 ish kHz which is well above the 37 kHz I need. This should work. And it did!
The final circuit I skipped the gate resistor and added an orange LED to tell me when it was emitting. Running the app I could see the orange LED blinking and the IR camera in my phone showed it was emitting.
Testing it on my TV I could turn the TV on and off. So the regulators didn’t get in the way. Testing it outside was disappointing though. I couldn’t get it to work from outside my house. I don’t yet know what the problem is. I thought maybe the energy efficient glass might be blocking and I think it still might block some but opening window didn’t help much until I was very close to the house. I compared the beams to an unmodified flashlight and the flippered light was much less.
I don’t think this was my circuit because I tested it with the GPIO app and it was the same brightness when it turned on.
I suspect that with the carrier and data modulation I am reducing the overall On time and total light output significantly. If I assume 50% modulation and roughly 50% (probably less based on the encoding) that’s less than 20%. But that is the integrated intensity, the peak power should still be 100% so why the disappointing results?
Ebay seller was wrong about the power claim, maybe they lied about the color of the light. Maybe it isn’t 940 nm as claimed but something else which would reduce the efficiency of the signal. I don’t have easy access to a photo spectrometer to measure it but I did try with some IR cut off filters. I don’t know what this means but I did not notice by eye (IR camera) any real difference with no filter, 850nm, and 950nm filters.
I scoped and it looks like the GPIO is weak but also the output looks OK. It is about 30% duty cycle.
The unloaded GPIO is nice and square. Also interesting the frequency is 38kHz which is probably within the bandpass of the receiver filter but something to note.
The next thing to check is the current which I will need to insert a small ohm resistor in series and measure the voltage across it.