element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Seeed Bluetooth Shield Issue
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 9 replies
  • Answers 1 answer
  • Subscribers 392 subscribers
  • Views 632 views
  • Users 0 members are here
  • bluetooth
  • arduino
Related

Seeed Bluetooth Shield Issue

wallarug
wallarug over 9 years ago

Hey all,

 

I'm having an issue with my Bluetooth shield set up, where if I connect everything up to my BoeBot Shield + the Bluetooth Shield, the Arduino crashes/restarts.  See below for more details.

 

Setup (on robot)

  • Arduino Uno
  • Boe-Bot Sheild (similar to: https://www.parallax.com/product/28832)
    • With two 360* full rotation servo motors
  • Seeedruino Bluetooth Shield (http://www.seeedstudio.com/wiki/Bluetooth_Shield)  --> Set up to run as a master.
  • HD44780 Character display (using a 74HC595 shift register to reduce the number of pins used)
  • HC-SR04 Distance Sensor

(separate)

  • Arduino Uno
  • Seeedruino Bluetooth Shield  --> Set up to run as a master

 

Issue / Behaviour:

  • Arduino is powered on > the sketch goes into the setup function > the setup() calls a bluetoothsetup() function.
  • The bluetooth fails to connect with it's paired shield.
  • COMMENT: Everything appears to work up to the delay(), where halfway through the delay(), the device crashes (BEFORE it gets to the loop() function.

 

When I run the below sample program, everything works as expected.  It is just when I try to use the Seeedruino Bluetooth in my custom code that it doesn't work.  I bought a HC-06 Bluetooth device, and that works fine with everything connected (HC-06 connects to laptop's bluetooth).

 

Everything is connected correctly.

 

Can anyone help point me in the right direction here?

Custom Code - uploaded to robot

/*

*  Written By: Cian Byrne 2015

*

*  Sensors Used:

*    - HC-SR04 Distance Sensor

HD47780 Character LCD Display(via  74HC595N74HC595N

*    - Servo Motor

*    - BoeBot Sheild

*/

 

 

#include <LiquidCrystal595.h>    // include the library

#include <SoftwareSerial.h>   //Software Serial Port

#include <Servo.h>

 

 

/*

* define global pins:

*/

#define trigPin 9

#define echoPin 6

#define servoPin 11

#define RxD 7

#define TxD 6

 

 

#define DEBUG_ENABLED 1

 

 

/*

* Variables

*/

int pos = 0;                                  //variable to store the servo position

long duration, distance;                      //variables to store the SR04 values

String slaveAddr = "0,6A,8E,16,C4,FD";        //MAC address of other BT sheild.

int distances[180];                           //Array to dump values from distance sensor

byte dataPacketA[180];                        //Array to dump values from distance sensor

 

 

SoftwareSerial blueToothSerial(RxD,TxD);

Servo ultraServo;                             // create servo object to control a servo

LiquidCrystal595 lcd(3,4,5);                  // datapin, latchpin, clockpin

 

 

 

 

/*

* Set up function

*/

void setup() {

  /*

   *  Serial set up (hardware and bluetooth

   */

  Serial.begin(9600);

  pinMode(RxD, INPUT);

  pinMode(TxD, OUTPUT);

  setupBlueToothConnection();

  //wait 1s and flush the serial and btooth buffers

  delay(1000);

  Serial.flush();

  blueToothSerial.flush();

 

  /*

   *  Servo and LCD Display

   */

 

  ultraServo.attach(servoPin);  // attaches the servo on pin 9 to the servo object

  ultraServo.write(90);   //set servo to middle position

 

  lcd.begin(16,2);         // 16 characters, 2 rows

  lcd.clear();

  lcd.setCursor(0,0);

 

 

  /*

   * SR HC-06 - Distance Sensor

   */

  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

 

 

}

 

 

void loop() {

 

  // REMOVED CODE LOGIC

 

 

 

    //  send data over serial to PC:

    blueToothSerial.write(dataPacketA,180);

    Serial.write(dataPacketA,180);

}

 

 

 

// CODE REMOVED

 

 

 

 

 

/*

*  This is for the Seeedruino Bluetooth device

*/

void setupBlueToothConnection()

{

  // Set BluetoothBee BaudRate to default baud rate 38400

  blueToothSerial.begin(38400);

  // set the bluetooth work in master mode

  blueToothSerial.print("\r\n+STWMOD=1\r\n");

  // set the bluetooth name (irrelevant)

  blueToothSerial.print("\r\n+STNA=Master20\r\n");

  // Auto-connection is forbidden here

  blueToothSerial.print("\r\n+STAUTO=0\r\n");

  // This delay is required.

  delay(2000);

  blueToothSerial.flush();

  // This delay is required.

  delay(2000);

 

 

  //form the full connection command

  Serial.print("Connecting to slave: ");

  Serial.println(slaveAddr);

  //send connection command

  blueToothSerial.print("\r\n+CONN=" + slaveAddr + "\r\n");

  delay(5000);

}

 

 

/*

* This is for the HC-06 Bluetooth

*/

void setupBluetoothConn(){

  //Set BluetoothBee BaudRate to default baud rate 9600

  blueToothSerial.begin(9600);

  //delay

  delay(2000);

}

Sample Code (that works!) - uploaded to receiving Arduino connected to USB serial port

#include <SoftwareSerial.h>                     // Software Serial Port

 

 

#define RxD 7

#define TxD 6

 

 

#define DEBUG_ENABLED  1

 

 

// Make sure you modify this address to the one in your Slave Device!!

String slaveAddr = "0,6A,8E,16,C4,FD";

 

 

SoftwareSerial blueToothSerial(RxD,TxD);

 

 

void setup()

{

  Serial.begin(9600);

  pinMode(RxD, INPUT);

  pinMode(TxD, OUTPUT);

  setupBlueToothConnection();

  //wait 1s and flush the serial and btooth buffers

  delay(1000);

  Serial.flush();

  blueToothSerial.flush();

}

 

 

void loop()

{

  char recvChar;

 

 

  // Infinite loop

  while(1)

  {

    // If there is data pending to be read from the shield

    if(blueToothSerial.available())

    {

      recvChar = blueToothSerial.read();

      // Print the data through the Serial channel

      Serial.print("Master Received: ");

      Serial.print(recvChar);

      Serial.print("\n");

    }

    // If there is data pending to be read from the serial port

    if(Serial.available())

    {

      recvChar  = Serial.read();

      // Send the data through btooth

      blueToothSerial.print(recvChar);

      Serial.print("Master Transmitted: ");

      Serial.print(recvChar);

      Serial.print("\n");

    }

  }

}

 

 

// Function to start the connection. Make sure slaveAddr is set to the right

// value.

void setupBlueToothConnection()

{

  // Set BluetoothBee BaudRate to default baud rate 38400

  blueToothSerial.begin(38400);

  // set the bluetooth work in master mode

  blueToothSerial.print("\r\n+STWMOD=1\r\n");

  // set the bluetooth name (irrelevant)

  blueToothSerial.print("\r\n+STNA=Master20\r\n");

  // Auto-connection is forbidden here

  blueToothSerial.print("\r\n+STAUTO=0\r\n");

  // This delay is required.

  delay(2000);

  blueToothSerial.flush();

  // This delay is required.

  delay(2000);

 

 

  //form the full connection command

  Serial.print("Connecting to slave: ");

  Serial.println(slaveAddr);

  //send connection command

  blueToothSerial.print("\r\n+CONN=" + slaveAddr + "\r\n");

  delay(5000);

}

  • Sign in to reply
  • Cancel

Top Replies

  • gadget.iom
    gadget.iom over 9 years ago +1 suggested
    wallarug wrote: Custom Code - uploaded to robot /* * define global pins: */ #define trigPin 9 #define echoPin 6 #define servoPin 11 #define RxD 7 #define TxD 6 You appear…
  • gadget.iom
    gadget.iom over 9 years ago in reply to wallarug +1
    Glad you're all sorted. Paul
Parents
  • Former Member
    0 Former Member over 9 years ago

    Reading you original post you've got both your robot and remote BT setup as Master.  Is that correct, just a typo, or is there another device functioning as a Slave?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 9 years ago

    Reading you original post you've got both your robot and remote BT setup as Master.  Is that correct, just a typo, or is there another device functioning as a Slave?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • wallarug
    0 wallarug over 9 years ago in reply to Former Member

    That is correct.  I am using both as a master, so that they can both send data to each other.

     

    As I said above... that set up worked with the example code but just not with my code.  I am pretty sure now that the pin assignments were wrong.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube