Instead of using iR can I

just use a wire and connect the data transmit wire to the data receive wire on two devices. I don’t need the wireless remote aspect and the connection is not reliable in this setting. The receiver is just a multi-function light bar and would normally use a manual remote but I wish to control it with my Arduino.

I tried a number of things to increase reliability - 2 transmitters, external power source but I only get 1-2 feet of transmission.
Is it just as simple as this or am I missing something?

As is probably obvious I am not an electronics expert.
Thanks in Advance

I hope there’s a common ground connection between the two boards…

I don't know if I understand correctly... Do you want to replace an IR remote control and its receiver with a cable?

a ful description of what you are trying to do - and a schematic?

1 Like

Let's say that it's probably easier to improve your IR range than wire your arduino to some
multi-function light bar...

It is possible to use the IRremote library to send from one Arduino to another Arduino using a wired connection.

You have to send an unmodulated signal from the transmitting Arduino by enabling the USE_NO_SEND_PWM macro.

To demonstrate this I have used two Arduino Uno R3s.
On the transmitting Uno, I ran the IRremote library example 'SendRawDemo'

The line: #define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low
was commented out. I have reinstated it.

If you are adding that line to your own code, it must come before #include <IRremote.hpp>.

Transmit Code
/*
 * SendRawDemo.cpp - demonstrates sending IR codes with sendRaw
 *
 * This example shows how to send a RAW signal using the IRremote library.
 * The example signal is actually a 32 bit NEC signal.
 * Protocol=NEC Address=0x4 Command=0x18 Raw-Data=0xE718FB04 32 bits LSB first
 *
 * If it is a supported protocol, it is more efficient to use the protocol send function
 * (here sendNEC) to send the signal.
 *
 *  This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 ************************************************************************************
 * MIT License
 *
 * Copyright (c) 2020-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>

#if !defined(ARDUINO_ESP32C3_DEV) // This is due to a bug in RISC-V compiler, which requires unused function sections :-(.
#define DISABLE_CODE_FOR_RECEIVER // Disables static receiver code like receive timer ISR handler and static IRReceiver and irparams data. Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not required.
#endif

//#define SEND_PWM_BY_TIMER         // Disable carrier PWM generation in software and use (restricted) hardware PWM.
#define USE_NO_SEND_PWM             // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
//#define NO_LED_FEEDBACK_CODE      // Saves 220 bytes program memory
//#define USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN // Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!

#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
#include <IRremote.hpp>

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    Serial.begin(115200);

#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/ \
    || defined(SERIALUSB_PID)  || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_attiny3217)
    delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
    Serial.println(F("Send IR signals at pin " STR(IR_SEND_PIN)));

    /*
     * No IR library setup required :-)
     * Default is to use IR_SEND_PIN -which is defined in PinDefinitionsAndMore.h- as send pin
     * and use feedback LED at default feedback LED pin if not disabled by #define NO_LED_SEND_FEEDBACK_CODE
     */
}

/*
 * NEC address=0x04 (0xFB04), command=0x18 (0xE718)
 *
 * This is the raw data array in byte format.
 * The uint8_t/byte elements contain the number of ticks in 50 us.
 * The uint16_t format contains the (number of ticks * 50) if generated by IRremote,
 * so the uint16_t format has exact the same resolution but requires double space.
 * With the uint16_t format, you are able to modify the timings to meet the standards,
 * e.g. use 560 (instead of 11 * 50) for NEC or use 432 for Panasonic. But in this cases,
 * you better use the timing generation functions e.g. sendNEC() directly.
 */
const uint8_t rawDataP[] PROGMEM
= { 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 11/*0010 0x4 of 8 bit address LSB first*/, 11, 11, 11, 11, 11, 11, 11,
        11/*0000*/, 11, 34, 11, 34, 11, 11, 11, 34/*1101 0xB*/, 11, 34, 11, 34, 11, 34, 11, 34/*1111*/, 11, 11, 11, 11, 11, 11, 11,
        34/*0001 0x08 of command LSB first*/, 11, 34, 11, 11, 11, 11, 11, 11/*1000 0x01*/, 11, 34, 11, 34, 11, 34, 11,
        11/*1110 Inverted 8 of command*/, 11, 11, 11, 34, 11, 34, 11, 34/*0111 inverted 1 of command*/, 11 /*stop bit*/};

/*
 * The same frame as above. Values are NOT multiple of 50, but are taken from the NEC timing definitions
 */
const uint16_t rawData[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
        560/*0010 0x4 of 8 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690, 560, 560,
        560, 1690/*1101 0xB - inverted 0x04*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111 - inverted 0*/, 560, 560, 560, 560,
        560, 560, 560, 1690/*0001 0x08 of command LSB first*/, 560, 1690, 560, 560, 560, 560, 560, 560/*1000 0x01*/, 560, 1690, 560,
        1690, 560, 1690, 560, 560/*1110 Inverted 8 of command*/, 560, 560, 560, 1690, 560, 1690, 560,
        1690/*1111 inverted 0 of command*/, 560 /*stop bit*/}; // Using exact NEC timing

void loop() {

#if FLASHEND > 0x1FFF // For more than 8k flash => not for ATtiny85 etc.
    /*
     * Send hand crafted data from RAM
     */
    Serial.println(F("Send NEC 8 bit address=0x04 (0xFB04) and command 0x18 (0xE718) with exact timing (16 bit array format)"));
    Serial.flush();
    IrSender.sendRaw(rawData, sizeof(rawData) / sizeof(rawData[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.

    delay(1000); // delay must be greater than 8 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal

#endif

    /*
     * Send byte data direct from FLASH
     * Note the approach used to automatically calculate the size of the array.
     */
    Serial.println(F("Send NEC 8 bit address 0x04 and command 0x18 with (50 us) tick resolution timing (8 bit array format) "));
    Serial.flush();
    IrSender.sendRaw_P(rawDataP, sizeof(rawDataP) / sizeof(rawDataP[0]), NEC_KHZ);

    delay(1000); // delay must be greater than 8 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal

    /*
     * Send the same frame using NEC encoder
     */
    Serial.println(F("Send NEC 16 bit address 0x04, 8 bit command 0x18 with NEC encoder"));
    Serial.flush();
    IrSender.sendNEC(0x04, 0x18, 0);

    delay(30000);
}

I connected pin 3 of the transmitting Uno to pin 2 of the receiving Uno, and connected the two GNDs.
The receiving Uno was running the 'ReceiveDemo' example.

Here are the results:
This is the Serial Monitor output from the transmitting Uno:

10:16:26.984 -> Send NEC 8 bit address=0x04 (0xFB04) and command 0x18 (0xE718) with exact timing (16 bit array format)
10:16:28.048 -> Send NEC 8 bit address 0x04 and command 0x18 with (50 us) tick resolution timing (8 bit array format)
10:16:29.141 -> Send NEC 16 bit address 0x04, 8 bit command 0x18 with NEC encoder

And here are the results from the Serial Monitor output from the receiving Uno:

10:16:27.064 ->
10:16:27.064 -> Protocol=NEC Address=0x4, Command=0x18, Raw-Data=0xE718FB04, 32 bits, LSB first, Gap=3276750us, Duration=67800us
10:16:27.105 -> Send with: IrSender.sendNEC(0x4, 0x18, );
10:16:28.131 ->
10:16:28.171 -> Protocol=NEC Address=0x4, Command=0x18, Raw-Data=0xE718FB04, 32 bits, LSB first, Gap=1001250us, Duration=67550us
10:16:28.171 -> Send with: IrSender.sendNEC(0x4, 0x18, );
10:16:29.222 ->
10:16:29.222 -> Protocol=NEC Address=0x4, Command=0x18, Raw-Data=0xE718FB04, 32 bits, LSB first, Gap=998100us, Duration=67600us
10:16:29.262 -> Send with: IrSender.sendNEC(0x4, 0x18, );

Yes and with that approach you likely could connect arduino to "some device" substituting the original IR receiver with optocoupler.

I am beginning to agree with you, especially after reading JohnLincoln’s suggestions. The ‘just use one wire’ comment seems to be far more complicated as I kind of expected. I am thinking you are right as this is only being done for a ‘one night’ special effect and I am just a beginner in this sort of thing.
I am only using a cheap (6 for $10) on-line iR transmitter so perhaps there are better transmitters.
Thanks for your reply

If you are interested in some information how IR remote controls send the data see here:

https://learn.sparkfun.com/tutorials/ir-communication/all

Reasons for short range of IR transmitters are often that the electronic that drives the diodes does not supply enough power and/or that the beam is not focussed enough so the energy spreads over a large angle.

This page shows an example how to use a transistor to drive an IR diode:

https://www.mikrocontroller.net/articles/IRSND_-_english

Good luck!
ec2021

This would be easy $4 ready made one. It's not difficult to build one with NPN transistor though.

But problem can be wrong frequency as well...