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. vulussu» Blog Archive » EasyTransfer Arduino Library « The Mind of Bill Porter

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.

    • JoshNo Gravatar says:

      Is there any way to use EasyTransfer to communicate to a PC or similar using processing or something like that?

      • BillNo Gravatar says:

        Where there’s a will there’s a way. My library could be ported to processing to enable comms with a PC, but no one has done it yet. I have a wedding in the works and don’t know processing so it wouldn’t be me for a long time. Hopefully someone else can step up.

    • Jerry IsdaleNo Gravatar says:

      Reading this, I initially thought – gee a PC port would be cool, then I thought about it a bit more and wondered:
      a) what i/o port on a PC would you use?
      most pc’s have USB or bluetooth and little else these days
      b) as long as its an intel pc you dont have to worry about Endian issues – i think.
      c) you will have to worry about structure packing and data alignment issues.

      So the question would turn more on – could you port this to run over USB? probably. Under the hood it is basically passing a binary structure, without packing or data alignment padding. You could do that over USB, or bluetooth.

      • BillNo Gravatar says:


        I looked into it a while back. I assumed a serial port (over USB or otherwise) would be the low layer connection. Endian/data type issues do exist with a native windows program, but Processing uses their own scheme that happens to match with a Arduino perfectly. (You’d think Arduino was based off Processing or something. (Bad joke, it is)).

        It shouldn’t need any more effort then just changing API calls to match Processing. I just have no time to try it.

        • JoshNo Gravatar says:

          Thanks guys, anyone know processing to give it a go? I haven’t used it yet just knew that android was based on processing platform so figured they’d be close in that regard.

          Another question, could you send more than one struct in your message? Or could you use two ET instances to send two structs?

          Cheers Bill! And cudo’s once again on an excellent library. PS did you get any traction on the ET over Ethernet/web work? There is a chunk of beer money in it for you if you do 😛

    • pfornellasNo Gravatar says:

      I can use the easytransfer over rs485 without data loss? Sorry my english google translate.

    • BrettNo Gravatar says:

      Great library, but I’m running into a problem. I have a structure with 7 integers which are reflecting the state of 7 buttons on a remote Leonardo. I have a serial print running listing the values of the data structure on the local Leonardo and I am getting random values every once in a while.

      I have tried varying the baud rates, the number of times I query the receive data structure, the time delay between reads, etc.

      Basically, the goal of this is to add I/Os to the local Leonardo so I can’t slow it down too much or I lose responsiveness.

      Any ideas?


      • BillNo Gravatar says:

        None. Did the sample code work without corruption? Do you have a way of eavesdropping in on the communications between the two? Checksums should catch bad packets. There may be a memory leak in your code that’s writing something to the area in memory occupied by your data struct.

    • MikeNo Gravatar says:

      Bill, thanks for a great library, it solved my Arduino/ Nanode serial problem perfectly 😉

    • owarNo Gravatar says:


      I need to transfer some variables(3bytes of data) over the XBee connected to Fio on one side and XBee connected to Uno on the other side.

      I have tried the EasyTransfer .But this has quite long response for my 4WD robot.

      So I have written my code to send the variables.It is sending the Start byte(255) the ID byte(to identify which data I am sending) 3 bytes of data(3 variables 0-255) and two bytes of some check if the data was recieved correctly. It is working but only when I send this packet one per +-100ms which is even worse than the EasyTransfer.

      What could be the problem?

      Arduino Uno
      Arduino Fio
      XBee S2 with XB24-ZB firmware(Coordinator and end device)


      I hope someone will find where is the problem.Thank you very much for every input

      • BillNo Gravatar says:

        EasyTransfer does not have much overhead and should not delay messages to your robot. If you perceived a delay, then you did not follow the instructions in the example. You probably didn’t have the receiver process messages 2x faster then the transmitter sent them. This cause the messages to stack up and make it look like the system has a delay.

        I’ll help you get EasyTransfer working but I don’t have the time to help you write your own version from the ground up.

    • Jack EdwardsNo Gravatar says:

      I have had serial transfer problems that seem to be timing issues that get better when I cut down on the terminal print statements. See what happens if you do internal data check and print only 1 – ok, 0 – bad, or switch an LED to get rid of all print statements.

      • owarNo Gravatar says:

        I have tried that and same problem.I have changed the datatypes from integers to bytes and Serial.begin at 115200 but still I can get just to 45ms at delays.It is still to much i think that just 5 max 10ms must be enough at 9600 when I am sending just 7 bytes..

        • BillNo Gravatar says:

          Commercial RC control has and update rate of 50Hz or every 20ms. Realistically though there is some delay added on top of that and it could be around 30ms for most brands. Why on earth do you need 10ms or less delay? Remember both processors on either end must stop, assemble the data, transmit it; receive it, finish other code before processing what was received, then process what was received. Baud rate plays a minor role in what makes up the start to finish delay.

          Also, remove the Xbee’s from the system while testing. Xbees themselves add a delay to the messages.

          • owarNo Gravatar says:

            Yes I know that 30ms is good enough but when I try in that code to set: delay(z); and on the RX side I print just the recieved z variable it looks like this:…254-255-0-1-2-3…. so It must be possible to send data much faster.It is just driving me crazy that when I set the delay manually to 15ms it is not working but when it counts from zero to 255 it is working..

    • JoshNo Gravatar says:

      Hey how would we go about using Easy Transfer with the Wireless RF24L01SE+ Chips?

    • NikosNo Gravatar says:

      Any pointers as to how would you create two way communication by using the EasyTranferI2C library?
      I do not seem to be able to come up with anything…

    • CamNo Gravatar says:

      Hi Bill et al, This is just what I have been looking for – thank you 🙂 I have some tests up and running nicely but one thing I would like to do is decode the packet that I can see coming over serial into a human readable format – any ideas how I do this? Thanks.

      • BillNo Gravatar says:

        That depends on what is listening to the data stream. Another Arduino is easy, use easytransfer to receive the data and print it out on another serial port. A pc is a different story because easytransfer sends the data I am the same way the Arduino saves the data in memory. So to be able to decode it, you have to know how the Arduino and avr saves data.

        • CamNo Gravatar says:

          Thanks Bill, Indeed hoping to read the packet over a PC serial port (Arduino to Arduino works a treat) as the third part of the system…. any clues on how to decode this appreciated 🙂

    • CamNo Gravatar says:

      Hello again Bill, I think some of the packet structure is worked out, hoping you might be able to demystify the header and terminator? So for example my packet 06 85 0c 00 00 A4 41 BA 5B 68 42 56 91 3f 41 9b has the following structure?
      Header: 06 85 0C
      Float 1: 00 00 A4 41
      Float 2: BA 5B 68 42
      Float 3: 56 91 3F 41
      Terminate: 9B

      The header value doesn’t change but the terminator does so suspect some sort of checksum?

      Any pointers and explanation welcome 🙂

    • MAXIENo Gravatar says:

      Hello Bill, thanks for your library, it’s really useful. I’m wondering that whether this library can do three way communication or not? Is it possible for me to create a packet in order to prevent distortion ?Thanks again.

    • EmanueleNo Gravatar says:

      I want to create a network with more than 2 arduinos, so I will have one master and two or more slaves, can I use the easyTransfer library? Is there any way to create a filter in the slaves so that they can read only when they are addressed from the master?

    • themotormanNo Gravatar says:

      Looking to use easytransfer to connect Ardunio to Android. Outline of ideas to try please. I have data on the ARduino that I want to display on the Android via an app.

Leave a Reply

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