0

I'm working on transmitting data from Arduino to Mac for sensor logging by HC-05 Bluetooth module. I've succeeded in transmitting data, but received data is bit weird and unstable.

This is a log of received data on a serial monitor.

serial monitor

This is an Arduino program for communicating with my Mac using Bluetooth via Hardware Serial.

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

void loop() {
  Serial.println("1024");
  delay(100);
}

I also tried to use software serial.

#include <SoftwareSerial.h>

SoftwareSerial sSerial(10, 11); // New RX, TX pins

void setup(){
   sSerial.begin(115200);
}

void loop(){
   sSerial.println("1024");
   delay(100);
}

The data ("1024") should be shown on the serial monitor every 100ms. But, serial monitor shows many of received data at one time or not separated in both case. video

I want to know the reason and its solution.

Kiyu
  • 13
  • 5
  • Is this the only code in your sketch or you are showing what you think is relevant? – Nino Jun 16 '21 at 14:53
  • This is the only code in my sketch. I used Arduino Uno and HC-05 module. Connect Arduino RXD(D0) → HC-05 TXD, TXD(D1) → RXD, 5V → Vcc, GND → GND – Kiyu Jun 16 '21 at 15:34
  • Your code has nothing to do with the HC-05 module, it simply prints a string on the serial monitor. On top of that, most likely the screenshot you presented is not a result of the code you are showing. – Nino Jun 16 '21 at 18:16
  • I thought that I can use hardware serial for hc-05, so I connect Arduino d0 and d1 to hc-05... I have tried to use software serial just now (I added its code above). but it results the same. – Kiyu Jun 17 '21 at 03:41

1 Answers1

0

This is not a typical answer with a solution to your problem but more an attempt to take you on the right path.

What you are showing is missing the basic understanding of how the devices talk to each other and therefore I suggest you carefully read at the following short articles:

Software Serial Example

Getting Started with HC-05

What you will find is that you need to:

  1. Understand what you need to send and what you should expect as a response data
  2. Establish connection with PC using Serial port, it helps with sending commands and getting info from the BT module
  3. Establish connection with the BT module using SoftwareSerial
Nino
  • 702
  • 2
  • 6
  • 12