Go Down

Topic: Using HC-05 with Arduino Micro (Read 3248 times) previous topic - next topic

werther86

Jul 31, 2016, 08:56 pm Last Edit: Jul 31, 2016, 09:07 pm by werther86
Hi Everyone,

I am neither new nor old enough on Arduino but this is the first time I ask in the forum and to be honest surprised that I really couldn't find an answer to my question. Usually forum was the YODA for all my questions.

I am trying to communicate two micros in between.. and want to do it wireless via bluetooth connection. Decided to use well known HC05 and HC06 modules. Everything is fine as long as you use UNO or equivalent boards / micro controllers but whenever I want to use Micro, couldn't manage to configure HC05 via serial monitor with AT commands.

I know the reason is different chips used between the UNO and MICRO; the UART is on serial1 for MICRO as suggested via following sources:

https://forums.adafruit.com/viewtopic.php?f=25&t=35649
http://forum.arduino.cc/index.php?topic=326643.0

but whatever I did, I couldn't manage to make the following code work with MICRO, although it works fine with UNO:

Code: [Select]

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup()
{
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
}

void loop()
{

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());
}


I tried to change the serial.xxx into serial1.xxx but no output.

Problem IS NOT putting HC05 into AT mode, it is fine and can be put easily. There is no problem with configuring also on UNO. The problem is using the module with MICRO and the issue was tested on different MICRO boards as well.

Constantly changed & tried serial.monitoring and configuring the HC05 but nothing returns.

PIN 10 & 11 are fine to use in Micro according to the SoftwareSerial library.

My brain would have been frozen as well, so please guide me some; I feel stuck..

Thanks in advance.

Nick_Pyner

I am trying to communicate two micros in between...............
Code: [Select]
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more

Problem IS NOT putting HC05 into AT mode,
I believe the problem is WHY are you putting HC-05 into AT mode.

werther86

Hi Nick, thanks for the reply.
I put BC-05 into AT mode to configure it for connecting to a HC-06 module on another Arduino.

But as I said, I can't establish a serial communication on MICRO; if I could have, I may have the possibility to configure it.

Any suggestions?

Nick_Pyner

Actually, I can't think why I asked the question...

If your code works on a Uno, it should work on a Micro, but I believe it is more normal to use a char c

Code: [Select]
void loop()
{
    if (BTserial.available())
    { 
        c = BTserial.read();
        Serial.write(c);
    }
 
    if (Serial.available())
    {
        c =  Serial.read();
        BTserial.write(c); 
    }


Have you remembered to select Both NL & CR in the serial monitor?

werther86

Hi Nick,
Nope, doesn't work.
and I do remember "Both NL & CR". Unfortunatelly nothing comes from Micro.

I believe it is strongly related to the below topics:

HC-05 Bluetooth RX Not working
External TX/RX of arduino micro fails


Bu I couldn't manage by replacing "Serial"s into "Serial1".  :smiley-confuse:





Nick_Pyner

I can never remember that the Micro is different. When you use one,the Uno code is OK after you change all the Serial commands to Serial1, including in the Setup, i.e. Serial1.begin(38400);

werther86

Converting to Serial1 doesn't return any compiler error but I can't see any incoming Serial.print() output for debugging, hence there is no possibility to put Arduino into AT mode.

Nick_Pyner

#7
Aug 08, 2016, 01:34 am Last Edit: Aug 11, 2016, 02:05 am by Nick_Pyner
I suppose you can always simply configure it on the Uno, but the problem description doesn't make much sense.

Does the Micro work fine when used for other purposes involving the serial ports?

Is the hC-05 you are trying to configure the same one that you have already configured on the Uno?

What module HC-05 are you using? Or is it a bare one with no breakout board?

werther86

Hi Nick,

Dies the Micro work fine when used for other purposes involving the serial ports?

Is thwe hC-05 you are trying to configure the same one that you have already configured on the Uno?

What module HC-05 are you using? Or is it a bare one with no breakout board?
Indeed the Micro work fine for anything else.
HC-05 module is the one that I already configure on the Uno.  But unfortunatelly I can't name the module I am using, it is not a bare one, but there is no name on the breakout either. There is a big bluetooth symbol with SJ in a little circle. Not sure if that makes sense.

After all, there is nothing wrong on the sample code I share right?

Nick_Pyner

I can't name the module I am using, it is not a bare one, but there is no name on the breakout either. There is a big bluetooth symbol with SJ in a little circle. Not sure if that makes sense.
That's OK. I think all the modules are the same and there are essentially only two types of breakout, those with a button and those without. I'm afraid I can't comment on the code any more than I have. I think I used Martyn Currey. Try his website.

MartynC

as per the comment on the other website, please post clear photos of the HC-05, front and back, a clear photo of the Arduino Micro and your circuit diagram (hand drawn is fine).


Confirm if you tried the examples in the Bluetooth module - AT MODE guide and if so what results.responces did you get.



Go Up