Struggling to get IR remote codes from nano + receiver

Hello, I'm trying to get the IR codes from a remote.

I bought a generic nano, ir receiver + breadboard from aliexpress and wired them up like this:
nano 5v - IR UCC
nano gnd - IR GND
nano D2 - IR OUT

I then ran the SimpleReceiverForHashCodes sketch from the IRremote library examples:


/*
 * SimpleReceiverForHashCodes.cpp
 *
 * Demonstrates receiving hash codes of unknown protocols with IRremote
 *
 *  This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 ************************************************************************************
 * MIT License
 *
 * Copyright (c) 2024 Armin Joachimsmeyer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 ************************************************************************************
 */

#include <Arduino.h>

/*
 * Specify which protocol(s) should be used for decoding.
 * This must be done before the #include <IRremote.hpp>
 */
#define DECODE_HASH             // special decoder for all protocols
#define RAW_BUFFER_LENGTH  1000 // Especially useful for unknown and probably long protocols
//#define DEBUG                 // Activate this for lots of lovely debug output from the decoders.

/*
 * This include defines the actual pin number for pins like IR_RECEIVE_PIN, IR_SEND_PIN for many different boards and architectures
 */
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp> // include the library

void setup() {
    Serial.begin(115200);
    while (!Serial)
        ; // Wait for Serial to become available. Is optimized away for some cores.

    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));

    // Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
    IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);

    Serial.println(F("Ready to receive unknown IR signals at pin " STR(IR_RECEIVE_PIN) " and decode it with hash decoder."));
}

void loop() {
    /*
     * Check if received data is available and if yes, try to decode it.
     * Decoded hash result is in IrReceiver.decodedIRData.decodedRawData
     */
    if (IrReceiver.available()) {
        IrReceiver.initDecodedIRData(); // is required, if we do not call decode();
        IrReceiver.decodeHash();
        IrReceiver.resume(); // Early enable receiving of the next IR frame
        /*
         * Print a summary and then timing of received data
         */
        IrReceiver.printIRResultShort(&Serial);
        IrReceiver.printIRResultRawFormatted(&Serial, true);

        Serial.println();

        /*
         * Finally, check the received data and perform actions according to the received command
         */
        auto tDecodedRawData = IrReceiver.decodedIRData.decodedRawData; // uint32_t on 8 and 16 bit CPUs and uint64_t on 32 and 64 bit CPUs
        if (tDecodedRawData == 0x4F7BE2FB) {
            // do something
        } else if (tDecodedRawData == 0x97483BFB) {
            // do something else
        }
    }
}

The code compiles and tells me it is ready and listening on pin 2 but the serial monitor does not display any codes when I use a remote.

  • I have tried 4 different remotes + ir blaster on my phone
  • the receiver detects the remotes and lights up an led
  • if I connect an led + resistor between OUT & UCC, this led also lights up when I use remote
  • if I jiggle the board, or move the wires connecting the receiver around, the serial monitor goes crazy with unknown protocol readings, but once the connections are secure, there are no messages whether I use remote or not

I tried to troubleshoot with ChatGPT, but after a couple of hours of more and more complicated code and going round in circles, I've given up on AI and am hoping a human can help!

I'm completely new to this and so have probably done something very silly.

Thanks for any help.

Everything indicates bad contact. Did you solder the pins by yourself?
If you have female jumper wires, just connect module to arduino without breadboard.

I have never user IRreceive with a Nano (I did it with UNO and some ESP8266 like WeMos), but just to exclude a few options, why don't you first try another example code like the basic "ReceiveDump" and see if reports the codes?
Then, if it fails, try the same receiver with a regular Arduino UNO if you have one. If it doesn't work it's either the receiver or the remote you're using (are you sure the IR carrier is 38 kHz, the one of this sensor?). Or the breadboard (try changing the positions...).
If it works with you can say the receiver is OK (I don't trust chinese sites like AliExpress...), and it could be something/somehow related to Nano but I don't know much more..

Unfortunately I don't have a soldering iron, I know nothing about electronics and thought I had bought a solderless kit with the breadboard etc. Sometimes the nano is not powering the ir receiver either, but i have tried it with an external power source that works but the end result is the same, no codes.

I didn't mean you should solder anything.
But if you have female wires try to connect module to A without breadboard.

The question was about the IR receiver: were the headers (the pins) already soldered when you got the module or did the module come with the 90° header separate and you just slotted that into the breadboard on one side and the module on the other side?

I think you might have been right about the connections, I have been jiggling the nano and the connections about some more and it looks like it started to receive messages briefly!

I think I may have bought the wrong kind of nano, the pins aren't soldered in, I'm just slotting them in with the connectors included. Apologies if that doesn't make sense, I have no idea what I'm doing here. Something seems to be working for now at least.

So the IR receiver came soldered as one piece, but not the nano, it came as a board and a set of pins. I just stuck the pins in the breadboard and the nano on top of that. I'm thinking that was a mistake and I should have a nano with soldered pins instead!

Ah then indeed it’s likely the issue.

Find a soldering iron or buy one with the headers

I guess I'll have to come up with some new projects to make the soldering iron worthwhile then!

You can start out with a cheap 30W soldering iron, plus some 63/37 solder, for about US$10. Look for a beginner's soldering kit.