1

I've got an Arduino Uno (Elegoo R3) and a Hc-05 bluetooth module. First of all i want to send data with an android app (Bluetooth terminal) to the Arduino and turn pin 13 (LED) on.

My Arduino code:

#include <SoftwareSerial.h>

int state = 0;

void setup() {
  //Serial.begin(38400);
  Serial.begin(9600);
  
  pinMode(13, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    state = Serial.read();

    if (state == '1') {
      Serial.println("Turned on LED");
      
      digitalWrite(13, HIGH);
    }

    if (state == '0') {
      Serial.println("Turned off LED");
      
      digitalWrite(13, LOW);
    }
  }
}

The RX and TX pins I have hooked up with the HC-05 but if I connect my smartphone with the HC-05 and type in a 1 or a 0 nothing happens. If I type a 1 or a 0 in my serial monitor on my computer (hooked up via usb to my arduino) it turns the LED on/off. The RX and TX lights also flashes one time. The bluetooth terminal app recognises all what was sent via serial monitor on pc and displays it in the app. But if I type something in the app, it won't flip the LED or show me some "Turned off LED" or "Turned on LED".

I also tried different apps from the PlayStore but all of them didn't work.

Does someone has an idea how I could fix this? Thank you for your answers.

EDIT: A drawing how my Arduino is connected to my HC-05 https://imgur.com/a/FtUz5So

3
  • It may be helpful to show how the RX and TX signals are connected between the bluetooth module and Arduino.
    – timemage
    Nov 27 '20 at 18:00
  • @timemage A drawing: imgur.com/a/FtUz5So
    – Verilyzed
    Nov 27 '20 at 18:45
  • I appreciate the effort, but what I was most interested in what what signals you connected to what on the HC-05, and this doesn't show the HC-05's pins labeled. So, rather than have a back and forth, I'll tell you what my wild guess is, and if I turns out to be correct I'd like you to post it an answer to you own question. The TX signal coming from either the Arduino or HC-05 should be connected to the RX of the other as I understand it, because both are labeled from the perspective of their respective chips.
    – timemage
    Nov 27 '20 at 19:52
2

The TX signal coming from either the Arduino or HC-05 should be connected to the RX of the other as I understand it, because both are labeled from the perspective of their respective chips

Like @timemage already said, I connected TX with TX and RX with RX but this is wrong. The solution was to plug TX (Arduino) with RX (HC-05) and RX (Arduino) with TX (HC-05).

Thank you for your help. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.