Go Down

Topic: ArduinoCommander (Android-Bluetooth) with Leonardo (Read 4189 times) previous topic - next topic

I'm trying to get a bluetooth connection to work with following circumstances:
- Board is Leonardo
- Bluetooth shield is this: http://www.exp-tech.de/Shields/Stackable-Bluetooth-Shield---BT-Shield-v2-2--Master---Slave-.html
- Board with StandardFirmata except:
     o all Serial exchanged to Serial1
     o changed baud rate line to "Firmata.begin(9600);"
     o added in setup section the condition "while(!Serial1) ... "

I can see the bluetooth device with other devices, but the computer says that device does not provide any services (like SSP what I need). The Android Tablet PC with Arduino Commander tries to connect but has no success.
Does anybody has a hint for me how to troubleshoot? Thanks!


- Board with StandardFirmata except

Why? Why start with code you have no control over? Write some simple sketch that does nothing but echo what it gets over one port to the other, until you get the BT thing working. Then, get more complicated as you need to. Leave making Firmata work with bluetooth until you know BT works at all.

The Android software for controlling the Arduino (UNO) via bluetooth expects this firmata. My hope was that I could skip the Arduino programming and just use the firmware that exists.
When it didn't work in first place, I checked for differences between UNO<->Leonardo and came up with the changes I mentioned. Still no luck   :|

So again:
What points do I need to look after when trying to use the standard firmata with Leonardo to get the same funcionality as with the UNO? Thanks again

Code: [Select]

  // pins with analog capability default to analog input
  // otherwise, pins default to digital output
  for (byte i=0; i < TOTAL_PINS; i++) {
    if (IS_PIN_ANALOG(i)) {
      // turns off pullup, configures everything
      setPinModeCallback(i, ANALOG);
    } else {
      // sets the output to 0, configures portConfigInputs
      setPinModeCallback(i, OUTPUT);

I found that the program has problems with the "systemResetCallback" function in the fortodo loop shown above.
If I disable it, LED from Bluetooth shield says "open serial port". If I enable it, LED stays dark.
Does anyone know what the problem may be?

It reads more like a monologue here but anyway:
I used the example "SerialCallResponse" to read values over Serial1 (bluetooth in my case) and write it to Serial (connected computer). This works nice (actually I also checked for "j" and "n" and used these letters to switch on/off an LED. To give input via Android Bluetooth I used SENA BTerm and on Leonardo I used this modified example (I only put it here because it would have saved me some time - perhaps it helps someone:
Code: [Select]

int inByte = 0;         // incoming serial byte
int led = 13;

void setup()
  // start serial port at 9600 bps:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  while (!Serial1) {
    ; // wait for serial port to connect. Needed for Leonardo only

//  pinMode(2, INPUT);   // digital sensor is on digital pin 2
  establishContact();  // send a byte to establish contact until receiver responds

void loop()
  // if we get a valid byte, read analog ins:
  if (Serial1.available() > 0) {
    // get incoming byte:
    inByte = Serial1.read();
    if (inByte == 106) {            // 'j'
        pinMode(led, OUTPUT);     
        digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
    if (inByte == 110) {            // 'n'
        pinMode(led, OUTPUT);     
        digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW


void establishContact() {
  while (Serial1.available() <= 0) {
    Serial.print('A');   // send a capital A

This is only a slightly different source than "SerialCallResponse", so I would not call this my style :-)


It reads more like a monologue here but anyway:

But that sketch is not Firmata... Which you insisted was crucial.

Unfortunately you are right. But your suggestion to start with simple sketch and check functionality at all was more satisfying than poking around in the dark.
Next step will be to import piece by piece from standardfirmata into this sketch until it stops working again...

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131