I’ve been playing around with a new infrared library for Arduino - IRMP, as I wanted a project to make use of the TTGO Display I got - the ESP32 devboard with a built-in TFT and LiPo charger. I never had any luck previously with the IRRemote library.

I’ve made a proxy or repeater that reads a remote code that you teach it by pointing a remote control at it, and then it replays it to the TV or whatever. I even added a web interface that you can enter a remote code and command and it will send it to the device wherever it is over wifi. The display is just big enough to get 3 lines of text on it - remote brand, address and command; plus a repitition flag in various colours. I’ve been busy making a database of all of my remote control’s keys.

I’m currently designing a 3D printed enclosure for it in Fusion 360. Trying to use projected geometries this time, although I’ve found that due to the timeline system F360 is quite limited in how much you can edit things without having to start from scratch, truly parametric it ain’t! I’m also using external STEP files rather than one giant design. I still think I may have things like components and joint vs align/move wrong.

I migrated to a TTGO T7-mini and a seperate 240x240 1.3" display. I’ve found a few things out about these boards on the way - like LED_BUILTIN on the T7-mini is 22 and active-low, but 4 on the T-Display (actually its the backlight); and the T7 has a wrong pinout on their github, the silkscreen is correct luckily.

I also found that the way Arduino munges code together you don’t have to use extern in include files and all #DEFINE variables seem to be a global, pretty poor C++. Also a bit annoyed at the use of Strings for everything in the ESP32 core.

I made a PCB for it that makes use of the button breakout modules that I made - basically three tactile switches and pullup resistors on a board with connector pads for wiring to a project:

img

Due to incorrect pinouts in the custom footprint library I made, the first set of boards are useless. Kicad’s custom library system doesn’t seem very intuitive - making a 3D model and mapping schematic to footprint is very complicated.

So I’m currently waiting on the button modules and fixed boards to arrive before I can finish the enclosure.

The sketch is too large and complex to post here, but here’s a simple receiver sketch that outputs to the TFT:

// ir lib settings for ttgo display
#define LED_BUILTIN 4
#define IRMP_PROTOCOL_NAMES 1
#define IRMP_INPUT_PIN 15
#define IRSND_OUTPUT_PIN 14
#define tone(a,b) void()
#define noTone(a) void()
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#include <irmpSelectMain15Protocols.h>
#include <irmp.c.h>
IRMP_DATA irmp_data;

// tft lib
#include <TFT_eSPI.h>
#include <SPI.h>
TFT_eSPI tft = TFT_eSPI();

void setup()
{
    // setup serial port
    Serial.begin(115200);

    // ir lib
    irmp_init();
    irmp_irsnd_LEDFeedback(false);

    // init screen
    tft.init();
    tft.fillScreen(TFT_BLACK);

    // set screen rotation multiple of 90
    tft.setRotation(1);
}

void loop()
{
    if (irmp_get_data(&irmp_data))
    {
        // blank screen and reset origin
        tft.fillScreen(TFT_BLACK);
        tft.setCursor(0, 0, 2);

        // debug
        irmp_result_print(&irmp_data);
        Serial.println();

        // protocol
        tft.setFreeFont(&FreeSansBold12pt7b);
        tft.setTextColor(TFT_RED);
        tft.println();
        tft.print(irmp_protocol_names[irmp_data.protocol]);

        // repetition
        tft.setTextColor(TFT_MAGENTA);
        if (irmp_data.flags & IRMP_FLAG_REPETITION)
        {
            tft.print(" R");
        }

        // address
        tft.setFreeFont(&FreeMonoBold18pt7b);
        tft.println();
        tft.println();
        tft.setTextColor(TFT_YELLOW);
        tft.print("ADD: 0x");
        tft.println(irmp_data.address, HEX);

        // command
        tft.setTextColor(TFT_GREEN);
        tft.print("CMD: 0x");
        tft.print(irmp_data.command, HEX);
    }
}

And the Makefile:

# ttgo display uses esp32 devkit core
FQBN = esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none
MONITOR_PORT = /dev/ttyUSB0

all:
	arduino-cli compile --fqbn $(FQBN) $(notdir $(CURDIR)).ino

upload:
	arduino-cli upload -b $(FQBN) -p $(MONITOR_PORT) $(CURDIR)

clean:
	rm -rf $(CURDIR)/build

monitor:
	screen $(MONITOR_PORT) 115200

On a related note, I’m pretty much done with Aliexpress now, even if you pay extra for shipping it could take three months to arrive, and as you no longer get any free shipping it’s no cheaper than Amazon that can deliver tomorrow - assuming you have a free prime trial 😉 That said, I’ve been having some hassle with Amazon as it seems if you return any item you part-paid using a voucher, you don’t get the voucher back, only the cash part.