SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By jainam
#186506
Hi Devs,

I just got my hands on Bluetooth Mate Gold and tried to transmit and receive some data using Arduino Yun and Android app, Bluetooth Terminal, https://play.google.com/store/apps/deta ... inal&hl=en.

Here is my Yun code (copied from https://learn.sparkfun.com/tutorials/us ... mmand-mode),
Code: Select all
/*
  Example Bluetooth Serial Passthrough Sketch
 by: Jim Lindblom
 SparkFun Electronics
 date: February 26, 2013
 license: Public domain

 This example sketch converts an RN-42 bluetooth module to
 communicate at 9600 bps (from 115200), and passes any serial
 data between Serial Monitor and bluetooth module.
 */
#include <SoftwareSerial.h>  

int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  Serial.begin(9600);  // Begin the serial monitor at 9600bps

  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  bluetooth.print("$");  // Print three times individually
  bluetooth.print("$");
  bluetooth.print("$");  // Enter command mode
  delay(100);  // Short delay, wait for the Mate to send back CMD
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  bluetooth.begin(9600);  // Start bluetooth serial at 9600
}

void loop()
{
  if(bluetooth.available())  // If the bluetooth sent any characters
  {
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());  
  }
  if(Serial.available())  // If stuff was typed in the serial monitor
  {
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
  }
  // and loop forever and ever!
}
I debugged the code, below loop from "void loop()" is never entered,
Code: Select all
if(bluetooth.available())  // If the bluetooth sent any characters
  {
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());  
  }
Connection between Yun and BT Mate was as shown below,
Image

I am able to send messages from Arduino IDE Serial Monitor which are received in Bluetooth Terminal app but when I send any messages from the app, serial monitor doesn't show any message. Connect LED on BT Mate is ON entire time. Also, as explained here, https://learn.sparkfun.com/tutorials/us ... mmand-mode, sending "$$$" makes the red LED on BT Mate flash fast but on sending message "E", monitor doesn't return any information.

Any help is much appreciated. Thanks in advance.

Jainam
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]