0

I'm trying to read data sent from my phone to arduino via HM-10 Bluetooth Module. I downloaded the app, I paired the module to phone but I can't read data. If I just upload a blank sketch to arduino and open Serial Monitor, if I sent "1" from phone, it appears on the monitor, it's ok. But if I write Serial.begin(9600) in setup loop then noting happens and I can't see anymore the data from phone and Serial.read() is useless. Can you help me?

This don't work:

char incomingValue = 0;
int doorPin = 13;
void setup() {
  Serial.begin(9600);
  pinMode(doorPin, OUTPUT);
}

void loop() {  
  if (Serial.available() > 0) {
    incomingValue = Serial.read();
    Serial.print("\n");
    if (incomingValue == '1') {
      digitalWrite(doorPin, HIGH);
    } else {
      digitalWrite(doorPin, LOW);
    }
  }
}

And with this I cand see to the Serial Monitor what I'm sending from phone but I can't read the character.

char incomingValue = 0;
int doorPin = 13;
void setup() {
 // Serial.begin(9600);
  pinMode(doorPin, OUTPUT);
}

void loop() {  
  if (Serial.available() > 0) {
    incomingValue = Serial.read();
    Serial.print("\n");
    if (incomingValue == '1') {
      digitalWrite(doorPin, HIGH);
    } else {
      digitalWrite(doorPin, LOW);
    }
  }
}
  • 1
    Have you connected HM-10 RX to Arduino RX and HM-10 TX to Arduino TX? If yes, try to swap these two, vonnecting RX to TX and vice versa – chrisl May 14 at 15:10
  • I swapped thep and now I can't even connect my phone to the module. – Andrei Petrut May 14 at 15:27
  • I managed to reconnect the module to phone but with HM-10 RX to Arduino RX and HM-10 TX to Arduino TX, vice versa doesn't work. – Andrei Petrut May 14 at 15:37
  • how is the module connected to the arduino? ... you do not have any code that talks to the BT module ... it appears that you connected to pins D0 and D1, which makes the module connected directly to the serial converter chip ... the data you are seeing on the serial monitor is not passing through the arduino sketch – jsotola May 14 at 15:53
  • My module's pins are connected like this: - VCC -> 5V arduino - GND -> GND arduino - RX -> Digital Pin 0 (RX) -TX -> Digital Pin 1 (TX). How can I make the data pass through the arduino sketch? – Andrei Petrut May 14 at 16:23

Your Answer

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

Browse other questions tagged or ask your own question.