Bluetooth transmition LEDS rx/tx

Hello, I have a simple question that I haven't found yet, so I decided to post my question here to see if anyone can help me.

I have noticed that when working with the serial monitor on the Arduino IDE, if yo use a command like Serial.print() the arduino's tx led turn on, I think because is sending data, and the RX led turns on when is receiving data.

So, my problem is that I'm using a Hc-06 Bluetooth module, with a mit app inventor app, and when I send de data the RX led doesn't turns on, the same happens when the arduino is supposed to send data, the tx led doesn't turn on.
So is this supposed to be this way, those leds doesn't work with the bluetooth module?

And I know that the problem is not the app because I have used a serial monitor for bluetooth from the play store, and still anything.

Also I have my suspects about the module is not working, because I know that you can't upload a sketch to the Arduino while the module is connected, but I can, so I'm guessing that the bluetooth module doesn't works anymore.

Sorry if made gramatical mistakes.

The only thing clear about your code is that it is a deep, dark secret, but at least your grammar isn't too bad, even though your absolving of the app is incoherent.

The HC-06 is pretty robust and I submit the last thing you should do is guess that it is dead. You are correct in that, if you have Bluetooth on hardware serial, you must disconnect it to upload code but, if your new code is for software serial, all is explained - including the lights. I can't otherwise explain the LEDs, but your problems my be more down to procedure rather than code, i.e. wiring etc.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Leave the app inventor stuff out of the game until Bluetooth is kosher, it is just as likely to be the villain as anything else.

Thank you for your answer. I didn’t talk about my code because I don’t have any problems with it, it’s function is to control a robotic arm, I send two positions, an initial and a final, then the Arduino makes the math to determine how much the motors have to move and the print those angles.

As I said, I don’t have any problems working with the code through the serial monitor from the Arduino IDE, the problem is with the bluetooth module, it is wired fine, I know the RX goes with the TX and the TX with the RX.

Another thing is that I only can connect my phone to the Hc-06 trough the mit app, or from an app from the playstore, ( and I know is connected because the led from the Hc-06 stops blinking and stays on) but when I try to pair my phone trough the phone settings I won’t let me, the same happens when I try to connect my PC, so I think I am going to buy another one, anyway thank you for the time you take to answer.

Carlos4032:
Another thing is that I only can connect my phone to the Hc-06 trough the mit app, or from an app from the playstore, ( and I know is connected because the led from the Hc-06 stops blinking and stays on) but when I try to pair my phone trough the phone settings I won't let me, the same happens when I try to connect my PC, so I think I am going to buy another one, anyway thank you for the time you take to answer.

OK, see how you go, but I would point out that the above makes no sense. If you are able to connect, and you maintain that is the case, you must have succeeded in pairing, which you deny. You do not have to look at the paring in order to connect, but I don't see how the pairing can be anything other than kosher when you do, even if you are not actually aware of how you did it. (!)

This may merely be a matter of nomenclature, but I suggest you get it sorted before the other one turns up in the mail.

Dear Carlos4032

Don't forget to use other pins rather than RX and Tx, because they're used when you connect the arduino to the pc

As Nick says the Hc-06 is very robust and it seems that your procedure of wiring may be failing rather than your code (without knowing or seeing a piece of it), please show it anyway

Good Luck

Nick_Pyner:
OK, see how you go, but I would point out that the above makes no sense. If you are able to connect, and you maintain that is the case, you must have succeeded in pairing, which you deny. You do not have to look at the paring in order to connect, but I don’t see how the pairing can be anything other than kosher when you do, even if you are not actually aware of how you did it. (!)

I meant that I can only connect my phone with the bluetooth module trhough the mit app that I did (and I am not %100 sure thats it is connected, because if I go to the settings it doesn´t appear conected). If I don´t want to use the MIT app to connect myself, but instead I want to connect myself throug the phone settings it won´t let me.

carlitos101:
Dear Carlos4032

Don’t forget to use other pins rather than RX and Tx, because they’re used when you connect the arduino to the pc

I first upload the sketch to the arduino, and then I disconnect it from the PC, and connect it to and external power supply, so I don´t think the pins Rx and the Tx are being used by the PC.

Here is the code, as I said I don´t have problems working with it through the Serial monitor.

#include<Servo.h> 
Servo Servo1, Servo2, Servo3;
String lectura;
float xi, yi, zi,xf, yf, zf;
const float l1 = 30.0;
const float l2 = 20.0;
const float l3 = 15.0;
float ai, bi, ci, ri, af, bf, cf, rf, qi1, qi2, qi3, qf1, qf2, qf3;


void setup() 
{
 Serial.begin(9600);
 Servo1.attach(9);
 Servo2.attach(10);
 Servo3.attach(11);
}

void loop() 
{
  if (Serial.available()>0)
  {
    lectura = Serial.readString();
    if(lectura.startsWith("Da"))
    {
      lectura.replace("Da","");
      //Serial.println("DoneA");
      xi = lectura.toFloat();
      Serial.println(xi);
    }
    
    if(lectura.startsWith("Db"))
    {
      lectura.replace("Db","");
      //Serial.println("DoneB");
      yi = lectura.toFloat();
      Serial.println(yi);
    }

    if(lectura.startsWith("Dc"))
    {
      lectura.replace("Dc","");
      //Serial.println("DoneC");
      zi = lectura.toFloat();
      Serial.println(zi);
    }

    if(lectura.startsWith("Dd"))
    {
      lectura.replace("Dd","");
      //Serial.println("DoneD");
      xf = lectura.toFloat();
      Serial.println(xf);
    }
    
    if(lectura.startsWith("De"))
    {
      lectura.replace("De","");
      Serial.println("DoneE");
      yf = lectura.toFloat();
      Serial.println(yf);
    }

    if(lectura.startsWith("Df"))
    {
      lectura.replace("Df","");
      //Serial.println("DoneF");
      zf = lectura.toFloat();
      Serial.println(zf);
    }

     if(lectura.startsWith("S"))
    {
        ri = sqrt(pow((zi-l1),2)+((xi*xi)+(yi*yi)));
        ai = (atan(zi/(sqrt((xi*xi)+(yi*yi)))))*(180/PI)+90;
        bi = (acos(((l1*l1)+(ri*ri)-(l2*l2))/(2*l1*ri)))*(180/PI);
        ci = (acos((((l1*l1)+(l2*l2)-(ri*ri)))/(2*l1*l2)))*(180/PI);
        qi1 = (atan(yi/xi))*(180/PI);
        qi2 = ai-bi;
        qi3 = 180-ci;
        
        rf = sqrt(pow((zf-l1),2)+((xf*xf)+(yf*yf)));
        af = (atan(zf/(sqrt((xf*xf)+(yf*yf)))))*(180/PI)+90;
        bf = (acos(((l1*l1)+(rf*rf)-(l2*l2))/(2*l1*rf)))*(180/PI);
        cf = (acos(((l1*l1)+(l2*l2)-(rf*rf))/(2*l1*l2)))*(180/PI);
        qf1 = (atan(yf/xf))*(180/PI);
        qf2 = af-bf;
        qf3 = 180-cf;
        delay(2000);
      
        Serial.print(qi1);
        Serial.print("|");
        Serial.print(qi2);
        Serial.print("|");
        Serial.print(qi3);
        Serial.print("|");
        Serial.print(qf1);
        Serial.print("|");
        Serial.print(qf2);
        Serial.print("|");
        Serial.println(qf3);
        
    }
   
  }
 }

Carlos4032:
If I don´t want to use the MIT app to connect myself, but instead I want to connect myself throug the phone settings it won´t let me.

This is complete gibberish. What exactly are you trying to explain?

Carlos4032:
I first upload the sketch to the arduino, and then I disconnect it from the PC, and connect it to and external power supply, so I don´t think the pins Rx and the Tx are being used by the PC.

No, no, no. What he was saying is that you should use a version of a software serial library to communicate with the HC-05 on Arduino pins different than 0 and 1.

This is because pins 0 and 1 are connected to the serial port that deals with Arduino to PC USB communications. This means the pins 0 and 1 are sending and receiving signals during program upload. If you leave your HC-05 connected during program upload, bad things can happen.

Power_Broker:
This is complete gibberish. What exactly are you trying to explain?

No, no, no. What he was saying is that you should use a version of a software serial library to communicate with the HC-05 on Arduino pins different than 0 and 1.

This is because pins 0 and 1 are connected to the serial port that deals with Arduino to PC USB communications. This means the pins 0 and 1 are sending and receiving signals during program upload. If you leave your HC-05 connected during program upload, bad things can happen.

I know all that, I obviously disconnect the bluetooth module when I am uploading the sketch.

And what I was trying to say was, that I can pair my phone with the bluetooth module, but I can't connect it.

Carlos4032:
I know all that, I obviously disconnect the bluetooth module when I am uploading the sketch.

Nope, not obvious - I don't watch you upload your code or see what you do to your circuit when you upload code.

Carlos4032:
And what I was trying to say was, that I can pair my phone with the bluetooth module, but I can't connect it.

Might try to reset to factory default settings by sending the command AT+ORGL while in AT command mode. After that, just power it up without connecting TX or RX. Then try connecting to the module. You should be able to both pair and connect to it at that point. Once the connection is successful, then you can add the arduino communication part of the project.

Carlos4032:
I meant that I can only connect my phone with the bluetooth module trhough the mit app that I did (and I am not %100 sure that it is connected, because if I go to the settings it doesn´t appear conected).

If you are unsure it is connected, it almost certainly isn’t. I rather suspect that you are just seeing Arduino stuff on the monitor, i.e. you are just talking to to yourself, or just seeing phone stuff on the phone, i.e. same thing.

I first upload the sketch to the arduino, and then I disconnect it from the PC, and connect it to and external power supply, so I don´t think the pins Rx and the Tx are being used by the PC.

This is a bit garbled, but I think I understand your intention and it appears that you know that you need to disconnect Bluetooth when uploading.

Here is the code, as I said I don´t have problems working with it through the Serial monitor.

#include<Servo.h> 

void setup()
{
Serial.begin(9600);
}

This shows you are using hardware serial only. I don’t really understand your intentions, particularly the serial input, but if you intend to use this as just an Arduino thingy talking to the phone via Bluetooth, that is fine. There is no obligation to use software serial just because you want Bluetooth. Indeed it can be a good idea not to, and Software Serial in that instance is just a resource-wasting refuge for the lazy and incompetent - and something you may eventually regret.

IF you have serial input from the monitor, you DO need Software Serial for Bluetooth as the Hardware Serial is reserved for the monitor. IF by

I don´t have problems working with it through the Serial monitor

you mean you are just proving up your code by using the monitor in place of Bluetooth, this is fine and, I would suggest, the smart way to do it. Further, it also suggests that the real problem is not in your Arduino code.

If you just want two-way comms Arduino to phone, I suggest you prove it with the note linked to above. Note particularly

  1. Arduino only talks to its comms port, hence kosher Arduino code is no guarantee of kosher comms with Bluetooth, as the wiring has to be kosher too - Tx>Rx and Rx>Tx, see the notes.

  2. Arduino is not involved with pairing, all it does is provide power to Bluetooth. Any pairing problem is resolved at the phone end. And I suspect you need to look there first…

Thank you for all your help, it seems that is working fine now. The problem was that both of the wires that I was using on the Tx and RX were broken, so thats why I could upload the sketch to the arduino while the bluetooth was connected, beacause it wasn´t really connected to the arduino due to the wires.

My bad, dumb mistake not testing the wires before, sorry, anyways thank you for all your help.