Cheap Wireless Transmission Between Two Arduinos With Infrared




Introduction: Cheap Wireless Transmission Between Two Arduinos With Infrared

About: French engineer in robotics. I love Arduino projects / coding / guitar / various electronics. Oh, I like cooking also ! PS : English is not my main language, please inform me in case of grammar mistakes ! ...

Hi all,

For a project, I was looking for a cheap solution to send data from an Arduino to an other one. The serial port was already taken, and my transmission (unidirectional) needed to be wireless.

My researches has brought me to discover these kinds of radio modules (433MHz). They were available on the net, but I was still looking for something else.

So, I remember that I have in my stock an IR receiver with a small remote control. I also had an IR led. After some researches on the web for libraries, I used an existing one to create a small and easy IR protocol to send data between my two cards.

Of course, the range and the baud rate are limited, and you must keep the cards in "eye contact".

Here is a step by step presentation of this system. In my example, a temperature and humidity sensor will be used for data transmission (DTH11). The data will be sent to the other Arduino and sent to a computer. Feel free to use and modify this example for your own projects !

Thanks for the 20k views !

Step 1: Materials List

Ok, you will need:

• two Arduino cards (uno, mega...). I'll use an Uno and a Mega in this project.
• a computer with the Arduino software
• an IR led, with a 100 ohms resistor
• a 38 kHz receiver module
• wires
• breadboard, or similar
• In my case, a DTH11 temperature and humidity sensor. If you don't have it, you can simply sent a demo string. (see the code in the next step)

This site was a good source of information. I encourage you to read it ! The main IR libraries are here. Please download and install them in the Arduino "Libraries" folder. (Should be in "My documents / Arduino")

The libraries for the temperature and humidity sensor are here.

Step 2: Wiring the Emitter

The emitter is easy to build. You just need to wire a led with a 100 ohms resistor, and use an other pin to connect the sensor.

The Arduino pin used for the led is the 3. (See the attached pics). Watch out, the Fritzing illustration doesn't fit my real module. If you have the naked chip, you will need more parts ! See the DTH11 datasheet.

If (like me) you are not sure about the LED orientation, or if you don't know if it works correctly, temporally connect the DATA wire to the +5v pin on the Arduino (to turn the LED on). Then, check with a mobile phone camera if the led is emitting (you should see a low purple colour, see pics)

The temperature sensor is wired this way:
• Vcc : to the +5v pin of the Arduino
• Dnd : to a GND pin
• Data : arduino pin 2

If you don't have this sensor, you can try the transmission by sending a string. Just check the code.

The code is attached. Compile it and upload in on the card.

Step 3: Wiring the Receiver

Ok, for the receiver, I have a ready-made reception module (38 kHz). It was used with a small remote control. Just connect it to the second Arduino following:

• Gnd to GND
• Vcc to Arduino Vcc (+5v)
• Data : Arduino pin 11

Watch out, again the module shown in the illustration is not the same as my module. if you have a naked receiver, you must add parts !

The receiver has a built-in LED, so we will be able to check if incoming data is received.

The receiver sketch is attached. The incoming data is collected then sent to the serial port.

Compile it and upload in on the card.

Step 4: Use It !

In this last step, we will turn everything on and check if it works.

I use the PuTTY software to receive the data from the Arduino.(Of course you can also use the Arduino Serial Monitor, the result will be the same !) Of course, it uses the USB connection, through the virtual serial port.

• Ok, turn on the emitter card. Remember, you can check the LED by using a mobile phone camera.
• Make sure the IR led on the emitter card and the receiver are aligned.
• Put the receiver card not far away. My receiver module has a build-in LED that blinks in case of incoming data.
• Launch PuTTY, select "Serial" and type "COM4" in the serial line text box. If you don't know the correct serial port, just check the bottom right line in the Arduino IDE : mine says "Arduino Mega on COM4". Make sure the baud-rate is correct (9600 in my example), then click Open. It should work !

Ok, it's quite stupid to sent a whole sentence. It's slow, and it may be better to sent only the two variables (temperature and humidity). Remember that this Instructable is only an example !

Here we are, a simple solution to send mono-directional data between two Arduino cards. Of course, real wireless solutions (433 MHz modules, Bluetooth or Wifi) are also perfectly suitable. In my case, the IR module was in stock, and it was possible to use it (no obstacles between them). If you need to simply send data (at low speed), just remember the good old IR transmitters... Its is possible to improve this code, for example by adding a control error, or by adding bi-directional links.

Thanks for reading !



    • Water Contest

      Water Contest
    • Metalworking Contest

      Metalworking Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    23 Discussions

    Did you know that it is possible to flash tiny devices like the 85 directly with an Arduino ? (You can find great Instructables on the subject.). I don't see why it may not work directly ? Maybe the internal oscillator may not accurate enough for the IR transmission... I'll try to test ! I don't know if the 85 can handle the protocol used by the temperature sensor... It is possible to use an ADC channel to use an analog sensor instead.

    Yeah, I know that.The problem is that tinny micros are not compatable with IR library used for Arduino.And I didn't find any ported library or something that I can use to accomplish same thing in your instructable.So I decided to find way to do it.I am now using 555 timer to generate 38khz ,aTtiny85 for data and morse library :-)
    I can make instructable too...I don't know

    How will your design work in fact ? Ok, I see how I can create a 38 kHz with a 555. So, to sent a "1", I just have to sent 38 kHz pulses on the LED, and for a "0" I sent... nothing ? It's as simple as that ? I can't remember if the 85 can create a PWM output with its internal timer...?

    I'm using 555 to create 38khz main wave and you have a few options to create pulses by controling reset pin on 555,power of 555 or to leave 555 to work all the time and just switch output off/on.Yes,is that simple.When trasmitter sends 1(ir led lights up) for example ,on receiver side is low, then I mesure duration of each low signals(hight from transmitter) and finally translate these pulses.I'm still working on receiver software couse it's more complex than I imagine.

    Ok I see. I'm also trying something, but without a 555... I will let you know. (Or I'll write a new instructable...?)

    Ah, ok. I don't know... Maybe other libraries may work... Or working directly in C with atmel studio (without an arduino, so with an ICSP programmer. I'm working on an instructable on this subject).

    Your concept is great too !


    4 years ago

    Did you consider using a laser for longer distances and/or higher reliability? I have always wanted to try that.

    9 replies

    It would be possible, I have audio modulated a laser pointer before and sent audio about 200 feet. Aligning an infrared laser would be somewhat difficult though. If the laser becomes even slightly misaligned, you won't get any data.

    You could use a lens to increase the dot size of the laser to make it easier to align, but that will decrease the range. Most laser modules have a focus adjustment for that though.

    Could you put a lens on the receiving end so that as long as the laser hits the lens it will be focused onto the ldr? That way the range will not be decreased.

    It might work, but once you start needing big lenses or high powered lasers it becomes more expensive than using a radio module like an rmf69.

    Ok, I see. The solution is to use a powerful laser, but it's harder (and difficult, as powerful lasers are forbidden in my country)

    I don't have (right now) enough skills in lasers for doing that (But yes, I'm thinking about it). I'm planning to try to use mirrors to increase the range... But my real objective is to try... a telescope ! I have a uncle that have a lot of astronomy hardware. I don't know if some powerful IR leds can be seen with a telescope, and if the receiver can be used instead...

    Hmmm, that's an interesting idea, I never thought of that. It would probably be safer than lasers too (even IR lasers could damage your eyes if you happened to be walking by and looked right into it).

    I'm sure that you can have incredible range with lasers (we use them to measure the earth-moon distance) but for a beginner like me, I'll start with a telescope. It may not work, but it will be fun :)


    4 years ago

    Any idea on the range and will it work in all weather?