Skip navigation

looked around on the shiny shiny internet, and thanks to this thread in the arduino fourm (and my advisor david mellis) i made this neat little wireless connection:

its super simple (and CHEAP!). super nice thing is that you can block the signal with your hand (mirrors? lenses?) this is real cool for my project, as this means that you can jam musical data coming from one unit to another. jam as in trash / mash up. also one unit will interfere with another. yeah: data chaos!

below is pictures of the setup / schematic and code:

transmitter:

TX code:

//dirt cheap wireless TX
//generates 38kHz carrier wave on pin 9 and 10
//sends data via TX every 500ms
void setup()
{
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // Clear Timer on Compare Match (CTC) Mode
  bitWrite(TCCR1A, WGM10, 0);
  bitWrite(TCCR1A, WGM11, 0);
  bitWrite(TCCR1B, WGM12, 1);
  bitWrite(TCCR1B, WGM13, 0);

  // Toggle OC1A and OC1B on Compare Match.
  bitWrite(TCCR1A, COM1A0, 1);
  bitWrite(TCCR1A, COM1A1, 0);
  bitWrite(TCCR1A, COM1B0, 1);
  bitWrite(TCCR1A, COM1B1, 0);

  // No prescaling
  bitWrite(TCCR1B, CS10, 1);
  bitWrite(TCCR1B, CS11, 0);
  bitWrite(TCCR1B, CS12, 0);

  OCR1A = 210;
  OCR1B = 210;

  Serial.begin(2400);
}

void loop()
{
  Serial.println("testing testing testing");
  delay(500);
}

receiver:

RX code:

//dirt cheap wireless RX
void setup()
{
  Serial.begin(2400);
  pinMode(13, OUTPUT);
}

void loop()
{
  // if incoming serial
  if (Serial.available()) {
    readSerial();
    digitalWrite(13, HIGH);
  } else {
    digitalWrite(13, LOW);
  }
  delay(10);
}

void readSerial() {
  char val = Serial.read();
  Serial.print(val);
}

66 Comments

  1. Nice post! Simple, cheap!

    I wonder if you can program an Arduino that way.. Hmm..

  2. That is a nice trick. How far apart can you get it before the communication gets garbled?

    • that depends on the IR LEDs really. i haven’t tried it over greater distances, but my guess would be that with clear line of sight and not too much sun light / interference, you could reach pretty long distances.

    • You can get great(100+ meters) range if you use the right protocol and lenses, just look at some of the DIY Lasertag stuff.

  3. This is awesome. AWESOME.

    Any chances of higher resolution pictures?

    • hm… i took these pictures with my phone while doing the prototyping…. so i’m not sure if higher resolution will give you a lot more info… are you looking for something special on the photos? connections?

  4. Nice work.
    Definitely I will try this.

  5. I can see applications for this in swarm robotics. A secondary fail-safe communication, passing data from one to another if other methods fail.

  6. good job

  7. wireless data trasmission using robot which measure temperature and send data to recevier & it display on LCD.

  8. This is great trick instead of using
    x-bee. Can you explain how you generate
    the carrier at 38KHz in arduino?

    • the carrier wave is generated by some pretty low level interrupt driven C code, you can look in the posted code example. i am not a great C coder, so i cant really explain exactly how it works (i got a bit of help with this part)

  9. How about using lasers instead for long distance line of sight communications?

    • yes, lasers would work — ony problem with laser are that they are so linear / precise i.e. you have to point EXACTLY at the receiver / transmitter to get a signal. just being a couple of mm of would render you signal non-existing…

  10. You could use lasers, but as jremin said you might have issues with accuracy. However, I wonder if you used a laser to illumate something like a ping pong ball or diffued target, that way you have some leeway.

  11. Hi,

    thanks for this trick.
    I tried to use it but I have some strange behavior.
    Do you know if the values you put in registers to generate 38 KHz are linked to the frequency of the micro-controller.
    I currently use use an Arduino with the 20MHz 328. Are the values used here for a 20MHz or a 16MHz clock?

    Thanks a lot anyway.

    • this code is for a 16mhz clock
      cheers,
      jacob

  12. This is cool! I’d like to use this in a lasertag project, is that alright with you? What license is your code under?

    • completely cool with me! 😀
      the license is creative commons, non-commercial, share-a-like
      please send a link when you have done your laser tag project. and have fun!

        • hunternet93
        • Posted March 21, 2010 at 1:52 am
        • Permalink

        I’ve created a forum for my laser tag system, which I’ve dubbed LasyTag. Your code is great, I have almost finished the base software for the unit. Here’s the link: lasytag.vanillaforums.com

        • jremin
        • Posted April 23, 2010 at 10:54 am
        • Permalink

        cool!

  13. how about to change uart baudrate to 9600? is it work?

    • it doesnt work that fast im afraid — it all depends on the speed of the carrier wave and the combination of the carrier wave and the serial data — if you write the serial data too fast for the carrier wave, you will loose data

        • digitak
        • Posted April 27, 2010 at 2:14 am
        • Permalink

        Thank you jremin,
        I used baudrate 2400 with delay time 500ms but the data still loose, any suggestion?

  14. hey dude i dont understand this part of your code, could you please help me out with this please… :
    “bitWrite(TCCR1A, WGM10, 0);
    bitWrite(TCCR1A, WGM11, 0);
    bitWrite(TCCR1B, WGM12, 1);
    bitWrite(TCCR1B, WGM13, 0);

    // Toggle OC1A and OC1B on Compare Match.
    bitWrite(TCCR1A, COM1A0, 1);
    bitWrite(TCCR1A, COM1A1, 0);
    bitWrite(TCCR1A, COM1B0, 1);
    bitWrite(TCCR1A, COM1B1, 0);

    // No prescaling
    bitWrite(TCCR1B, CS10, 1);
    bitWrite(TCCR1B, CS11, 0);
    bitWrite(TCCR1B, CS12, 0);”

    any help would be appreciated

    • hej fan 😉
      i am unsure of this myself….
      but to quote david mellis (the guy who actually wrote this piece of code):
      “I’m afraid there’s no easy answer to this one. There’s a lot of stuff to explain for people to understand how the code works – it’s a larger issue that I’d like to work on at some point (e.g. by wrapping the timer code with a nicer API along the lines of: http://dam.mellis.org/2010/06/sensor_library_for_arduino/) but I don’t really have an answer I can post on your blog.”

  15. Hi This is really great. But i have tried this. It does not work. So i have some questions?
    For TX, how does the IR LED connect to arduino? the +leg of IR LED to arduino pin 9 and the other leg to arduino pin TX?

    And for RX, in the code, what does the pin 13 do? the three legs of the sensor are connected to the arduino +5v, gnd,and pin RX?

    Thank you very much.

  16. How can I change pin9,10 to pin5,6?

  17. How do you make an Ir-Led array. I mean amplify this circui, can anyone hansome posting the schematic?

  18. Great tutorial!
    I’ve liked it very much. But I haven’t understood how is the positive pin of the LED connected to the board.
    Is the red wire only plugged to the pin 9, only to the pin 10, to both or in another way?

    • hej,
      it is either one. the carrier wave is on both pins. pick the one you like 😀

  19. I noticed the questions on the complicated bit of timer code in this post. thought this might help the curious:
    http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106

    • ah! great! thank you hexagon!

  20. How much current draws your ir led?
    All types i saw had at 50mA – 100mA.
    Isn’t it to much?
    Wouldn’t it be better to use a transistor.
    Even to get a better range.

    • no 100mA should be OK. as far as i know the atmega can handle up to 200mA on each pin.
      sorry for the late reply! things have been hectic here
      /j

  21. Thanks, for your answer, but 200mA is much to much.
    See the Atmel Datasheet, Electrical Characteristics:
    “DC Current per I/O Pin …. 40.0 mA”
    But I think that I found the solution. The resistor tweaks the power consumption of the LED. Without the resistor you might toast the LED -and the Arduino.
    If the LED needs 1.3V (see LED Datasheet) and you want only 20mA on your Arduino pin, the equation should be (5V-1,3V) / 0,02A = 185 Ohms.
    The resistor reduces the IR output.
    A transistor is only needed when the LED gets to weak for the task.
    I’ll try out how it works and post the result.

    • ouch! good you had a look at the datasheet yourself! 200mA must be total consumption…. or maybe i am just completely off (would not be the first time)
      good luck
      /j

  22. Ok, hacking means also to go beyond datasheets. – But I it is also annoying when your exhibition ends in a soldering performance….

  23. Hi there, nice demonstration. I’m trying to figure out the receiving side…exactly what kind of IR receiver did you use? And is it a phototransitor or a photodarlington?

    Thanks for the details!

  24. I am sorry for my rough english, it was not my intention to complain or something. It thing it is very cool when people share their knowledge instead of making secrets out of it.
    Here is an articles about LED and resistors:
    “http://www.sparkfun.com/tutorials/219”
    and one example with transistors(150ft range):
    “http://www.ladyada.net/make/tvbgone/design.html”
    And I finally checked the Atmel datasheet : 40mA is the max current for a single I/O pin. 200 mA is the current for the vcc and the gnd pins. The consumption of the 328 chip is 12mA. If all 14 I/O pins are used for output: (200-12) / 14 = 13,4 mA on each pin. -but I think, that these are absolute save conditions. So I use now a 220ohm resistor and it the LED works with 18 mA.

    • thanks for sharing Idp

  25. Where do I connect pin to generate 38kHz??
    Pin 9 or Pin 10?

    • hej,
      it’s been a while since i used this setup, but i think both pins will send 38kHz. try it out 😉 check with a scope, or just connect the IR LED and see which work.
      /j

  26. Thank you for so kind anwers.
    I have other questions

    Is the status LED blinking? and
    Is your test board atmega 168(Decimilla)?

    • yes the status LED will blink whenever the IR LED will transmit IR
      i think the boards i am using are 328s… but this should not really matter for the result

  27. i want to send a string from a arduino to the other. Iam not getting in the same order as transmitted.

  28. i want to send a string from a arduino to the other. Iam not getting in the same order as transmitted.

  29. My receiver receives some garbage values. How to avoid this?

    • i am sorry genn / jer12, you have to be more specific if i am to help you. debugging is tricky and needs precise information.

  30. I am still confuse in transmitter schematic, where is the ground position…?

    • you are not connecting the LEDs to ground. you are connecting them to TX and pin 9/10 (carrier wave)
      /j

        • khadafi
        • Posted May 30, 2011 at 11:49 pm
        • Permalink

        Thanks jremin, it works perfectly.

  31. Hi jremin
    I se you use the pin 9 and 10 for the 38KHz, but is the pin 9 and 10 not for the 16MHz XTAL?

    • it is arduino digital pin 9+10 for carrier wave, not the actual pin 9+10 on the atmega chip

  32. okay, how dos that work, you type pinMode(9, OUTPUT); pinMode(10, OUTPUT);
    but get the pin 15 and pin 16

    is that because its a Arduino where there are some preprogram in it?
    sorry for the question, but get confused because im new with Arduino.

  33. okay thanks.

  34. Hi, i just see “ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ” someone can help me?

    • sound like you are using the wrong baud rate in your serial monitor?

  35. Can you make the RX code to flash an led when its receiving “testing testing testing” ?

    • sure. just add an LED to the receiving circuit. look at basic arduino to tutorials on how to flash LEDs.

  36. Pleased to have found this. The first thing anyone asks when they see one of my RC Projects is ‘How small can you make it ?’ and the truth is at least half the size is due to the user interface – buttons, pots, leds etc.

    Yaw control for an RC Car – its has three pots but I want at least six or seven and then some toggle options as well –

    http://rcarduino.blogspot.com/2012/07/rcarduino-yaw-control-part-2.html

    I was planning to move the user interface to a separate device and was already thinking IR would be the quickest and easiest way to exchange data as there is no need to plug anything in. This approach looks perfect, if I take this approach I will post a link to this page to acknowledge your original idea. If for any reason you do not wish me to link to your content I will of course remove the link at your request. Duane B rcarduino.blogspot.com

    • sure! go for it!

  37. Hey!
    The text here is hard coded. I am trying to accept text from the serial monitor and send that across. But im not receiving even a bit.
    Is such a thing possible?

    • i am sorry i don’t understand what you mean?


18 Trackbacks/Pingbacks

  1. […] is a really simple and dirt cheap wireless system that you can use for your next micro-controller project. its super simple (and CHEAP!). […]

  2. […] is a really simple and dirt cheap wireless system that you can use for your next micro-controller project. its super simple (and CHEAP!). […]

  3. By Dirt cheap wireless | SquareCows on 25 Aug 2009 at 11:43 am

    […] is a really simple and dirt cheap wireless system that you can use for your next micro-controller project. its super simple (and CHEAP!). […]

  4. […] you need to send some wireless data from one microcontroller to another have a look at this Cheap Microcontroller IR Data Transmission project for inspiration. It uses an IR LED, a resistor and an optional visible LED for the […]

  5. […] you need to send some wireless data from one microcontroller to another have a look at this Cheap Microcontroller IR Data Transmission project for inspiration. It uses an IR LED, a resistor and an optional visible LED for the […]

  6. […] you need to send some wireless documents from one microcontroller to another have a look at that Cheap Microcontroller IR details Transmission project for inspiration. It uses an IR LED, a resistor and an optional visible LED for the […]

  7. […] you need to send some wireless data from one microcontroller to another have a look at this Cheap Microcontroller IR Data Transmission project for inspiration. It uses an IR LED, a resistor and an optional visible LED for the […]

  8. By Dirt cheap wireless | Arduino Live on 26 Aug 2009 at 2:28 am

    […] Link Share and Enjoy: […]

  9. […] an easy way to transfer data with an infrared LED and an infrared remote control demodulator. The example uses an Arduino, but the technique will work with any […]

  10. […] del Video | Mas detalles del Proyecto | Comunicacion con […]

  11. By links for 2009-09-27 « Talkabout on 28 Sep 2009 at 3:05 am

    […] Arduino minimal infrared serial wireless | https://tthheessiiss.wordpress.com/2009/08/05/dirt-cheap-w… <blockquote> <pre> //dirt cheap wireless TX //generates 38kHz carrier wave on pin 9 and 10 //sends data via TX every 500ms void setup() { pinMode(9, OUTPUT); pinMode(10, OUTPUT); […]

  12. […] PC remote control decoders have been popular for years, Ian published a USB version at Hack a Day. Jremin recently demonstrated an inexpensive wireless connection using an IR LED and receiver pair.  The […]

  13. By eureka!? | solid on 28 Aug 2010 at 9:02 am

    […] think the above project’s code which I found here is very relevant to what I need to use myself with analogue input going from the aruino into […]

  14. By Firefox Bookmarks « Rabiul's on 09 Oct 2010 at 7:52 pm

    […] dirt cheap wireless « CHEAP, FAT and OPEN […]

  15. By IR Sensor network. | hexdream on 21 Feb 2011 at 1:03 am

    […] a starting point, just a TX and RX unit. Not sure if it’d work out, but it’s something to play with […]

  16. […] (only for tan furthermore tight fluroscent sparks) also abandon from FCC law. The tangle place https://tthheessiiss.wordpress.com/2009/08/05/grime-inexpensive-wireless/ (Jacob Sikker Remin, 2009) evinces how to application a IR inaccessible monopolize recipient […]

  17. […] (except for sun and compact fluorescent lights) and freedom from FCC regulation. The web site https://tthheessiiss.wordpress.com/2009/08/05/dirt-cheap-wireless/ (Jacob Sikker Remin, 2009) shows how to use a IR remote control receiver and IR LED to send ASCII […]

Leave a reply to Sam Martin Cancel reply