Bluetooth Debugging

Serial Communication

Baud Rate

The baud rate specifies how fast data is sent over a serial line. It’s usually expressed in units of bits-per-second (bps). If you invert the baud rate, you can find out just how long it takes to transmit a single bit. This value determines how long the transmitter holds a serial line high/low or at what period the receiving device samples its line.

Baud rates can be just about any value within reason. The only requirement is that both devices operate at the same rate. One of the more common baud rates, especially for simple stuff where speed isn’t critical, is 9600 bps. Other “standard” baud are 1200, 2400, 4800, 19200, 38400, 57600, and 115200.

The higher a baud rate goes, the faster data is sent/received, but there are limits to how fast data can be transferred. You usually won’t see speeds exceeding 115200 – that’s fast for most micro controllers. Get too high, and you’ll begin to see errors on the receiving end, as clocks and sampling periods just can’t keep up.

Problems we found with the Bluetooth servo test

When testing out our servo with the HC-06 sensor we came across a few problems. The videos below show our problems.

What were the problems?

  • The servo did not recognize the angle inputted from the user in the Bluetooth Serial
  • The code could not exit the ‘while loop’ to differentiate as to when the angle was being inputted.
  • The code would not clear the value ready for the next value to be inputted.
  • The Code was not converting from a string to an integer correctly
  • It was spitting out ‘gibberish’ after the inputted value.

Solution

The code below shows how we have overcome these problems

https://create.arduino.cc/editor/ma2-weston/9025b278-052c-43a6-869f-5473f66a4692/preview?embed

ASCII table

To understand how to properly convert a string to an integer i consulted the table in the link below

https://www.arduino.cc/en/Reference/ASCIIchart

 

Additional notes

The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality (hence the name “SoftwareSerial”)

Digital pins 10 and 11 on your Arduino or Genuino boards are used as virtual RX and TX serial lines. The virtual RX pin is set up to listen for anything coming in on via the main serial line, and to then echo that data out the virtual TX line. Conversely, anything received on the virtual RX is sent out over the hardware TX.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s