IR transmission code not working IrSender.begin();

I'm new to ESP32 and Arduino. I want to Transmit IR signals using an ESP32 Wroom32 microcontroller. My IR transmitter has 3 pins S + -. I have placed S to pin 26 + to 3.3v and - to Ground of the ESP32. My IRremote library version is 4.4.1

I'm using the following code but its not working. I can find what's wrong. Can somebody please help?

    #include <IRremote.hpp>
    #define IRPin 26         // Transmitter pin


    uint8_t sCommand = 0x34;
    uint8_t sRepeats = 0;
    void setup() {
    Serial.println(9600);
    IrSender.begin(IRPin);
    }

    void loop() {
    IrSender.sendSony(0x01, sCommand, sRepeats);
    Serial.println("IR send....");
    delay (5000);
    }

I get no output. not even Serial.print output.

You need to do

Serial.begin(9600);

Not

Serial.println(9600);

Do you have a part number or data sheet for it? Every IR transmitter I have used look like LEDs and have only 2 pins. All the IR receivers that I have used have 3 pins and look like this:
image

1 Like

"You're missing some important code. You need to use Serial.begin(9600); before you can print any messages to the console. I’m not familiar with the specific library you’re using, but generally, you also need to declare the pin as an output using pinMode(pinNumber, OUTPUT);. Add that, and you should start seeing some results.

Get a copy of the Arduino Cookbook it will become your best aid.

Ooo MY GOD!!!! such a silly mistake!!!

I've made plenty of silly mistakes in my time coding. The hardest ones to spot are my own silly mistakes.
The library you are using should have examples like this:


The usual path is to run the IReceiveDemo or IReceiveDump, to get the code from the remote you want to emulate. Then copy IRsendDemo and edit it to send the code you want to send (that you found from IReceiveDump).

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.