Sending data through bluetooth?

Hi, I have hooked up an HC-05 bluetooth module to my Arduino Uno, and for some reason I'm not able to send data from the bluetooth module over to my Android phone (which is paired). Here's the code:

#include <SoftwareSerial.h>

int rx = 6;
int tx = 5;

SoftwareSerial myserial(rx, tx);

void setup() {
  // put your setup code here, to run once:
  myserial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  myserial.println("Hello world");
  delay(100);
}

Any help would be great :slight_smile:

u have to use a serial terminal software on ur android to receive hello world on it

I forgot to mention that I do in fact have a terminal software on my phone, but hello world will not print into the terminal. But I can send data from phone to BT module, but can't send data from BT module to phone for some reason...

Try using a Bluetooth terminal emmulator on your laptop (if you have a Windows 10).

SMM2:
But I can send data from phone to BT module

How do you know you are doing that? And I'm betting you are not.

There is nothing wrong with your code per se, which suggests there is a lot wrong with your wiring and procedure. All of the latter is at the phone end.

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

How do you know you are doing that? And I'm betting you are not.

Well, I'm pretty sure I'm able to do that because I had wrote a sketch where if the BT received data from the phone the code would check if the incoming data was either a '1' or '0' and depending on which one of those it recieved it would turn an LED on/off. And I was successful in doing this. So that tells me that there is a connection established between the BT module and phone.

That suggests there is nothing wrong with

  1. Your code
  2. your wiring
  3. your pairing
  4. your terminal
  5. your ability to make the connection with the terminal

and I'm not sure there is really anything else that can go wrong.

Okay, so I guess it was just the terminal software I was using, because I installed a different one and everything was working fine. I'm assuming the other terminal app just didn't print ASCII characters...