TinyCircuit - Interfacing to Bluetooth Mate Gold - Issues

rocketman889

  • Newbie
  • *
    • Posts: 2
    • View Profile
Good Day All,

I need you help. My goal is to use bluetooth as wireless serial between two devices. My setup consists of two Arduino Unos, each connected their own Bluetooth Mate Gold. I followed the tutorial on Sparkfun (https://learn.sparkfun.com/tutorials/using-the-bluesmirf) to configure both bluetooth modules (9600 baud, auto-connect, no pin code required). In the sample code that they had, I added a few more conditional lines to turn on pin 13 when an 'h' was received and turn off when 'l' was received. I connected both Unos up to my computer and was able to send 'h' and 'l' from both modules, and it would show up in the serial terminal, as well as the LEDs on both modules would light up. (I uploaded the same code to both Unos). - No problems here. Everything working as expected.

Now, I wire one of the Bluetooth Mate Golds from one of the Arduinos to the Proto Terminal Block shield, as per the set up I had on the Uno. In the Arduino IDE, I change the board to 'Arduino Pro or Pro Mini' and set the Processor to 'ATmega328 (3.3V 8MHz) and upload the SAME code that was working on the Uno.

When I send commands from the Uno to the TinyCircuit (over the connected bluetooth modules - green solid light) The Uno board LED changes, but nothing happens on the TinyCircuit board (no LED change or Serial received by bluetooth <-- echoing this out over the serial port).

When I send commands from the TinyCircuit to the Uno, nothing happens on the Uno, but I get the confirmation that the TinyCircuit Board is working from the LED turning on and off with the 'h' and 'l' characters.

I've looked online but couldn't find anything that could be the problem. My thinking leads me to that the issue is with the Software Serial library on the TinyCircuit? Or maybe pins 2 and 3 don't support Software serial??

Any thoughts/comments would be super awesome. I've been hitting this wall for a few days now. :(

Thanks!!
Mike

My code below:
Code: [Select]
/*
  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
int LEDpin = 13;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  Serial.begin(9600);  // Begin the serial monitor at 9600bps
  pinMode(LEDpin,OUTPUT);
  digitalWrite(LEDpin, LOW);
  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
  //Serial.print("ready");
}

void loop()
{
  if(bluetooth.available())  // If the bluetooth sent any characters
  {
    // Send any characters the bluetooth prints to the serial monitor
   char data = (char)bluetooth.read();
    Serial.print(data); 
    if(data == 'h'){
      digitalWrite(LEDpin, HIGH);
    }
    if(data == 'l'){
       digitalWrite(LEDpin, LOW);
    }
  }
  if(Serial.available())  // If stuff was typed in the serial monitor
  {
    // Send any characters the Serial monitor prints to the bluetooth
   
    char data1 = (char)Serial.read();
    bluetooth.print(data1);
    if(data1 == 'h'){
      digitalWrite(LEDpin, HIGH);
    }
    if(data1 == 'l'){
       digitalWrite(LEDpin, LOW);
    }
  }
  // and loop forever and ever!
}


rocketman889

  • Newbie
  • *
    • Posts: 2
    • View Profile
I managed to get the Bluetooth Mate Gold working with the TinyCircuits. It didn't work with the 9600 baud rate to the bluetooth softserial port, but it did end up working flawlessly by using 19200 baud rate.

Hope this helps others.

Mike


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 392
    • View Profile
Glad you got it working, thanks for posting- the lower 8MHz clock speed can cause interesting issues with the softwareSerial library. However it's unusual that 19200 works better than 9600- we'll keep this in mind over here.


 

SMF spam blocked by CleanTalk