0

I recently ordered an HC-06 Bluetooth module for my Arduino Uno, and after watching this video, and many others, I still have been having many issues figuring out how to get it to work, and some questions for how the code receives and reads serial data from my phone.

  1. I assume this wiring is correct, right?

    • Rx > Tx
    • Tx > Rx
    • Gnd > Gnd
    • Vcc > 3.3V
  2. When I sent a command over the Bluetooth terminal app I have, the serial monitor displays that command over and over, I assume that is correct also?

  3. How do I read the serial input? I've been using

    if(Serial.available() > 0)
            phoneInput = (char) Serial.read();
    

    and then displaying the value of phoneInput to the serial monitor, but for some reason I can't seem to have it control anything properly (in this case an LED)

  4. What datatype is the Serial.read() returning to my variable before I cast char on to it?

  5. I get errors uploading the code to the board (avrdude: stk500_recv(): programmer is not responding), until I remove the pin connected to the Rx on the arduino, is there a cleaner solution to uploading the board without unplugging wires?

1

I assume this wiring is correct, right?

Rx > Tx
Tx > Rx
Gnd > Gnd
Vcc > 3.3V

Almost. The Arduino's TX should be reduced to 3.3V using a 10k/20k potential divider.

How do I read the serial input? I've been using

if(Serial.available() > 0)
       phoneInput = (char) Serial.read();

You should read and digest this.

What datatype is the Serial.read() returning to my variable before I cast char on to it?

An integer. It holds either 0-255 representing the ASCII code for a character, or -1 if there is nothing in the buffer to read.

I get errors uploading the code to the board (avrdude: stk500_recv(): programmer is not responding), until I remove the pin connected to the Rx on the arduino, is there a cleaner solution to uploading the board without unplugging wires?

That will be because you are using pins 0/1 to communicate with the bluetooth which you can't do because those are used to communicate with the PC.

  • I'm away from my computer so I can't test your answers, but thanks so much, your answers were super helpful, but I do have one question; If I shouldn't use pins 0 and 1 as Rx and Tx, what pins should I use? – Zachary Elkins Feb 18 '17 at 14:42
  • 1
    Anything else - I assume you're using SoftwareSerial - that library is designed to use any pin except 0/1. You use Serial for pins 0/1. There seems to be a number of tutorials (videos?) around that show SoftwareSerial being incorrectly used with pins 0/1. – Majenko Feb 18 '17 at 14:44

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.