I'm having trouble figuring out how to start my project. The objective is to control a robot with four servo motors and six DC motors through bluetooth. I have a bluetooth shield from Adafruit and I'm using the Arduino UNO. Ideally, I want to control this robot by sending it packets through Processing. The problem is I don't know how to create a packet with a header, payload, and checksum. I can't find any examples; can anyone help me find something to help me get started?

  • One layer of this should already be being invisibly added, verified, and removed in the bluetooth subsystem, but you can do your own as well on top. One thing which would make your life a LOT easier is to use a printable format so you can use a serial monitor for debugging. For example you could simply have a line of readable text, and a two-digit hex checksum at the end followed by a carriage return (a bit like a line from a .hex file). You could put a byte count at the start of the line, but don't need to. Jul 31, 2014 at 16:11
  • I don't understand. What I'm saying is: I don't know what a packet is, or a header, or a payload, or how to create a checksum. Is there an example out there that helps me grasp what these are?
    – user3403
    Jul 31, 2014 at 16:50

2 Answers 2


First, depending on the degree of reliability you need, you may not actually have to do this yourself, as the bluetooth implementation will already invisibly-to-you add, verify, and remove a packet and checksum framing around your data. But let's assume you want to add your own as well.

A packet is a batch of data to be transmitted as a contained unit. It may or may not contain exactly one useful message, but it is quite convenient if it does, and since you will be doing your own packetization (at this level) you can make sure that it does. So basically you will transmit something that has a structure, for example:

  1. Hi, I'm a packet
  2. attention HAL
  3. "Open the pod bay doors"
  4. The bytes in this message should add up to xx if you ignore the overflow
  5. That was a packet

There are countless ways you could implement this, but your life will be a lot easier if you make both the messages and the packet structure human readable, so that you can watch on the serial monitor, and perhaps even type manually. So let's say you did something like


For simplicity sake, instead of having a "Hi I'm a packet" header, we just use the newline character '\n' to mark the end of a packet, and assume that whatever comes next is the start of a new packet. Further, since bluetooth is already creating a one-to-one link, you don't need to address who you are talking to.

Now we have a message, for example "M1=200" meaning "drive motor 1 at PWM level 200" (out of 255).

I'm somewhat randomly choosing the '/' character to mark the division between the message body and it's checksum.

"BF" might be the low two hex digits of adding up all the previous bytes in this message (it's not, I just picked something random).

And finally you have your newline to mark the end of a message and the end of a packet, since in this scheme we've decided that 1 packet = 1 message.

For extra fun, if the robot itself is not dangerous, you can make a test mode where the receiver will accept messages with no '/' and checksum, and only check the checksum on those where it is present. This would allow you to manually type messages into a terminal when you are experimenting. Or you can make your own specialized terminal program which calculates and appends a checksum each time you press return


Start simple.

  1. send serial data from PC. either use Arduino USB port or on real hardware serial port, needs USB to serial adaptor and a terminal software. (see diagram in below web)

  2. for starting, no need for header. Just use simple text as defined yourself

  3. on Arduino side, read serial input. For example, type letter 'a' on PC will blink LED, 'b' to move servo 30 degree

  4. Replace serial communication (like RS-232 or a UART) with Bluetooth. Bluetooth supports many 'profiles', like headset, keyboard, etc. that are not suitable in your case.

See below video. You need to use the SPP profile. see https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles

Make sure your purchased bluetooth device supports SPP. Some bluetooth device are permanently setup to do one fix action. However, many bluetooth need to be 'programmed' (told what to do) before doing the task via AT command. Set speed, pairing, etc.



  • Quoted from your link, "Bluefruit EZ-Link shield is a regular 'SPP' device" so you have brought the right unit. At FAQ, "There is no command mode for EZ-Link, it is designed to be used out of the box.", so, one less thing to worry. The tutorial look excellent and should have all info you need. There are may steps and 'fine points'. Make sure you follow them precisely and carefully. Are you using one pair of "module plus Arduino"? That is, two same_brand and same_model BT modules communicating. Thinngs are more complex if different equipment is involved, like BT module communicate with phone.
    – EEd
    Aug 4, 2014 at 23:52
  • If I am at your situation, I would forget my code for the time being. Just follow the Adafruit tutorial from start to end. This ensure wiring done ok and the unit is paired (need one time pairing and two modules can communicate in all future sessions)
    – EEd
    Aug 4, 2014 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.