EasyTransfer Arduino Library

Posted in Arduino Libraries by Bill
30 May 2011
EasyTransfer Arduino Library

The purpose of this library is to make it easy for the everyday Arduino user working on projects with multiple Arduinos communicating with each other and sharing data. I had many people ask me for the code I used in my PS2X library example that sent PS2 Controller values wirelessly to my SAGAR robot. It got to be tiresome answering the questions and I had an idea to write a library to help the inexperienced with micro controller communications. This is a easy to use and no frills way to send data between two Arduinos.

In most of my own projects I define and write my own NMEA standard communication protocols. This makes communications human readable and easy to debug, but proves wasteful with bandwidth and processing power so it’s not right for every application. Binary communications is much more efficient and versatile, but requires careful handling. This library abstracts the finer points of packetized serial communication away from the user so it easy to use and understand.

To use the library, simple define all the data types you want to share inside a data structure. This keeps all the data stored together in memory.

  //put your variable definitions here for the data you want to send
  int blinks;
  int pause;

When requested, the library will send all the binary data in the structure to another Arduino via serial with a checksum to avoid transfer errors.

void loop(){
  //this is how you access the variables. [name of the group].[variable name]
  mydata.blinks = random(5);
  mydata.pause = random(5);
  //send the data

The receiving Arduino will verify the checksum, and copy the new data onto a identical structure in it’s memory.

void loop(){
  //check and see if a data packet has come in. 
    //this is how you access the variables. [name of the group].[variable name]
    //since we have data, we will blink it out. 
    for(int i = mydata.blinks; i>0; i--){
      digitalWrite(13, HIGH);
      delay(mydata.pause * 100);
      digitalWrite(13, LOW);
      delay(mydata.pause * 100);


It’s important to make sure the structure is the same on both Arduinos for this to work. Now sharing data between Arduinos is easy without having to define and program your own communications protocol and have to worry about syncing or transmit errors. EasyTransfer will do that for you.

Using Structures to hold the data allows for versatile communications by allowing any type and number of data points to be shared, as long as the whole structure is under 255 bytes. You could define int’s, arrays, longs, etc inside the structure and share the data. It’s also possible to create two way communications by defining two sets of structs on each end and creating two objects using the library. I will have an example of that up shortly.

You can download the library and example below. The example requires two Arduino boards to be connected to each other via their Uarts. One will create two random numbers and send the data to the other that will flash out a sequence of flashes based on those numbers. The first one will also flash out the same sequence.

Now it’s easier to pick which Serial port to use; Serial, Serial1, etc. AND support for the NewSoftSerial library for creating software serial ports on any pin. EasyTransfer is for hardware serial, SoftEasyTransfer is for software; each has there own set of examples. There’s also an example for two way communications using the library.

Source Code available on GitHub project pages.


Or Direct Download



Thanks to Kumy, there’s now an I2C version of EasyTransfer. There’s also an experimental VirtualWire version for use with those cheap low frequency radios. All are in the single download zip file above.


To install the Library, open the zip file and transfer the EasyTransfer folder into your Arduino ‘libraries’ folder. Then follow the examples to add the code to your project. If you have any problems or questions, let me know in the Support Forum.

Need Help?

Please use the Support Forum to ask for help. Don’t use the comments below.


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.


Trackbacks / Pingbacks

  1. The Living Map of Manchester powered by Arduino | greater than 140.
  2. Arduino Controlled RGB LED Dot Matrix Board -Use Arduino for Projects
  3. Xbee notes | Grimtech

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/46/d285670699/htdocs/bill/wp-includes/comment.php on line 879
  1. 443 Comments.

    • Hi Bill

      Several months later and still this is one the most valuable libraries I use it all the time

      But lately I have had a need for it to do just one more thing (: to make it REALLY awesome!

      A RPI class! If I could run a piarduino and exchange variables just as easy (for instance to pass analog readings to variables in bash and also to pass strings to a arduino to show on LCD – it would be awesome?


      • BillNo Gravatar says:

        The library as it stands is simplistic however that means it requires that the two talking systems store data in the same way. The RPi and the Arduino do not, so a RPi version would have to reconfigure data. This is significantly more involved than how the library works now. It could be done, just not easily. I won’t have the time to do anything like that. But, it is open source, and someone else might be able too.

      • ArthurNo Gravatar says:

        You could install Processing on the RPi and connect the Arduino to a Processing Sketch on the Pi (via USB), but you would have to get the information you want to send to the Pi into Processing, depending on the kind of data you want the LCD to Display this might be a problem. The system time of the Pi (RTC) e.g. shouldn’t be to hard.

        P.S. This Library is AWESOME!

        There are some tutorials on that topic I couldn’t find the one I liked but this one is good as well:


    • MartinNo Gravatar says:

      Dear Bill,
      this is exactly what i was looking for and you deserve more than a thumb up. Its superfast and easy to use, GREAT JOB.

    • […] solve this I enlisted the help of a second Arduino.  Using the EasyTransfer library I got the 2 Arduino’s communicating over their serial ports.  The master Arduino […]

    • […] is used to make this process painless. Here is the link to the instruction website we used: http://www.billporter.info/2011/05/30/easytransfer-arduino-library/. Just make sure you download the libabrary files and SAVE them to the “C:Program Files […]

    • Hello
      The title “EasyTransfer Arduino library” is not very informative. Maybe you can change it to “EasyTransfer Serial or I2C Arduino library”. When you google to “I2C Arduino library” you do not find your library.

    • AndreNo Gravatar says:

      Hi! will this work to make a Leonardo communicate with a Mega1280, through Serial1(LEO)Mega(Serial2)?


    • ZaffoNo Gravatar says:

      Hi.. I have some problem with the upload the configuration on the Arduino UNO after put the easytransfer’s example.
      Now the program use the serial0 of the arduino and don’t receive via usb new code..
      Why ? And now… What’s can I do ?

    • ToryNo Gravatar says:

      thank you for the tutorial.
      It is possible to send more than 26 bytes?
      I would be send 2 or 3 lines of data. Can I define e.g. sending line 1 and sending line 2?
      And the receiver should be read receiving line 1 and receiving line 2? So that I can transfer more sensordata?
      Thanks a lot grom Germany

    • madsNo Gravatar says:

      I am worried that there might be a pretty severe bug in your library. I have been converting the library to processing for communication with arduino and it threw an array out bounce error which. I think you forgot to allocate enough space in your buffer array. I think this is sufficient:

      rx_buffer = (uint8_t*) malloc(size)+1;

      Btw – I love your library.

    • […] EasyTransfer Arduino Library […]

    • Aaditya DengleNo Gravatar says:

      Hi Bill,
      How fast I can have a cycle of write and read through this library if I have only 2 Floats to share? those are not more than 8 digits individually, but updating very fast (basically encoder counters)?

    • RoccoDNo Gravatar says:

      This is great. It really makes sending multiple variables between arduinos over Xbee very simple. Thanks for making it.

    • So I am working on a wirelessly controlled pan tilt servo for a home security camera.

      Curious why I would need to use the virtual wire version of this. Why not just use the serial version, initiate the appropriate baud rate for the serial device, and hook the transmit/receiver data pins to the serial pins on their respective board?

      The major benefit of this would be that I would than be free to use the 16 bit timer1 on my atmel328p on the receiver side to generate the appropriate signals to drive my pan tilt servo with the standard Servo library.

      Am I missing something?

    • JoshNo Gravatar says:

      Hi Bill,

      Would it be possible to send via EasyTransfer over UDP broadcast ?


    • AndrewNo Gravatar says:

      I am having trouble with a robot, I am a novice when it comes to programming, I have two arduino unos, 2 xbee series 2, and the shield, 1 motor controller, and 1 2 axis joystick, I am trying to control 4 dc motors with the joystick wirelessly, I have figured out out to do this serially but want to do it wirelessly, can anyone help. attached is my code that I have on the bot so far for serial comm.


      AF_DCMotor motorLeft(2);

      AF_DCMotor motorRight(1);

      int myData = 0;

      void setup(){
      Serial.println(“MOTOR TEST”);

      //turn motor on


      void loop(){
      uint8_t i;
      if(Serial.available() > 0){

      myData = Serial.read();

      if(myData == ‘w’){
      for(i=0; i<255; i++){
      for(i=0; i<255; i++){
      if(myData == 's'){
      if(myData == 'd'){
      // left
      if(myData == 'a'){

      if(myData == 'x'){


      can anyone help me with the code that is supposed to be on the transmitter and the router or receiver, please email me at nealat06@gmial.com. thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.