Go Down

Topic: How to interface Genuino Zero with Bluetooth by serial communication (Read 391 times) previous topic - next topic

rolgaber

Hello,
 I need some help with Genuine Zero, I have to use a Bluetooth module HC05 to communicate with another Genuine Zero + HC05.
I'm using the UART port (pin 0 and 1) and the library Serial().
I found a documentation  about my application, but referred to Arduino. I can't use the library SoftwareSerial or NewSoftSerial, as suggested in the example because they are imcompatible.
When I send the AT commands to configure the HC05, it doesn't answer.
 I am sure about my send message because I monitor with an oscilloscope the signal but i don't receive anythig on the RX.
The module HC05 is powered with 3.3V out, not with the out of two pins like suggested by the example, because the out isn't enought toreach the power supply tension.
When I power up the system, manually give the signal on KEY and then the power supply, to enter in the AT mode. The red led on the HC05 blink.
I try with another Genuino Zero and with a HC06 module, but i have the same result.
Have you got any suggest to fix the problem ?
Thamks in advance.
Rolgaber
 

rolgaber

Sorry, I read about the presentation.
I'm a computer engineer with expertise in Microprocessors
In the past I developed a system with ArduinoYun to control the temperature in a Server room, with email service and an HTML page.

I add some information about my question:
The link of the example project is :
https://arduino-info.wikispaces.com/BlueTooth-HC05-HC06-Modules-How-To

Thanks

Nick_Pyner

I believe you might need to use the Serial1 class for communication with Bluetooth instead of Serial, but you are not.
This is only a guess, because your code is apparently a secret.

These two quotes look incompatible
Quote
The module HC05 is powered with 3.3V out, not with the out of two pins like suggested by the example, because the out isn't enought toreach the power supply tension.
Quote
I'm a computer engineer with expertise in Microprocessors
I wouldn't be inclined to go along with the second until the first is more coherently explained, and I'm not surprised to hear the HC-06 didn't give any joy either. 

Your problem may be as simple as improper connections, and 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

rolgaber

Thanks for your answer,
I try to explain better the problem of the power supply.
When I used the HC05, i followed the linked example.
 Here a part of the sketch:

Sends, Receives AT commands
   For Setup of HC-05 type BlueTooth Module
   NOTE: Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right   
 - SEE the comments after "//" on each line below
 - CONNECTIONS:
   - GND7
   - Pin 2 to HC-05 TXD
   - Pin 3 to HC-05 RXD
   - Pin 4 to HC-05 KEY
   - Pin 5+6 to HC-05 VCC for power control
 - V1.02 05/02/2015
   Questions: terry@yourduino.com */


I follow this instruction but in this way the module HC05 doesn't receive a sufficient power supply. I measure a tension of 2.4V, so I decide to power the module with the out 3.3V of the Board.

About the Serial1 class, what is the difference with Serial class, I try tu use the Multiserial sketch but I am not sure about the pin for TX and RX. Are there other pins to use instead of the Pin0 and Pin1 ?

About HC06 I try to use a prposed sketch, but like for the other, I don't receive any answer when I use the serial monitor to communicate. 
This morning I  read  the document suggested by you, but it is not useful at the moment.

Thanks in advance.

Nick_Pyner

This morning I  read  the document suggested by you, but it is not useful at the moment.
The best I can suggest is that you change your mind about that - and also have a re-think about the power supply.  The non-secret part of your code suggests you have a bluetooth module on a backboard.

rolgaber

I don't mean to be mysterious, it's the copy of the example without the SerialSoftware library. the program part is commented.
This is my code:


/* YourDuino.com Example: BlueTooth HC-05 Setup
 - WHAT IT DOES:
   - Sets "Key" pin on HC-05 HIGH to enable command mode
   - THEN applies Vcc from 2 Arduino pins to start command mode
   - SHOULD see the HC-05 LED Blink SLOWLY: 2 seconds ON/OFF
 
 Sends, Receives AT commands
   For Setup of HC-05 type BlueTooth Module
   NOTE: Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right   
 - SEE the comments after "//" on each line below
 - CONNECTIONS:
   - GND7
   - Pin 0 to HC-05 TXD   
   - Pin 1 to HC-05 RXD
   - Pin 4 to HC-05 KEY
   - Pin 5+6 to HC-05 VCC for power control
 - V1.02 05/02/2015
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <dht11.h>

/*-----( Declare Constants and Pin Numbers )-----*/
#define HC_05_TXD_ARDUINO_RXD 0
#define HC_05_RXD_ARDUINO_TXD 1
#define HC_05_SETUPKEY        3
#define HC_05_PWR1            5  // Connect in parallel to HC-05 VCC
#define HC_05_PWR2            7  // Connect in parallel to HC-05 VCC
#define DHT11_PIN 4
dht11 DHT;

/*-----( Declare objects )-----*/
//Serial BTSerial(0, 1); // RX | TX
//NewSoftSerial BTSerial(HC_05_TXD_ARDUINO_RXD, HC_05_RXD_ARDUINO_TXD); // RX | TX
 
/*-----( Declare Variables )-----*/
//NONE


void setup()   /****** SETUP: RUNS ONCE ******/
{

  pinMode(HC_05_SETUPKEY, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  pinMode(HC_05_PWR1, OUTPUT);      // Connect in parallel to HC-05 VCC
  pinMode(HC_05_PWR2, OUTPUT);      // Connect in parallel to HC-05 VCC
 
  digitalWrite(HC_05_SETUPKEY, HIGH);  // Set command mode when powering up
 
  Serial.begin(9600);   // For the Arduino IDE Serial Monitor
//  Serial1.begin(9600);
  Serial.println("YourDuino.com HC-05 Bluetooth Module AT Command Utility V1.02");
  Serial.println("Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right");
  Serial.println("Vcc Power Up DELAY");
  delay(2000);
  Serial.println("Applying VCC Power. LED should blink SLOWLY: 2 Seconds ON/OFF");
  digitalWrite(HC_05_PWR1, HIGH); // Power VCC
  digitalWrite(HC_05_PWR2, HIGH); 
  delay(2000);
  Serial.println("Enter AT commands in top window.");
  Serial.begin(38400);  // HC-05 default speed in AT command mode
// reserve 200 bytes for the inputString:
boolean stringComplete = false;  // whether the string is complete

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  String inputString = "                             ";         // a string to hold incoming data
   boolean stringComplete = false;  // whether the string is complete
  // READ from HC-05 and WRITE to Arduino Serial Monitor
  if (Serial.available()>0){
    inputString=Serial.readString();
    Serial.print("HO RICEVUTO: ");
    Serial.println(inputString);
  }
  delay(2000);
  // READ Arduino Serial Monitor and WRITE to HC-05
  if (Serial.available()>0)
    Serial.write(Serial.read());
   

//   temperUmid();
}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/
//NONE

//*********( THE END )***********


temperUmid() is another file to manage a Umidity sensor, currently commented.

I don't use the pin 5 , 7 to power up my module
I manually provide the power supply to the module HC05, to enter in the AT MODE.

The modulo runs, I can connect it with the Bluetooth of my computer.
The problem is: when I send AT command non aswer from the HC05
I try 9600 and 38400 baudrate.
I am using a Genuino Zero, Processor 32bit with outputs level 3.3V
I wish it's enough to explain my problem.
Thanks


Nick_Pyner

If you need to configure HC-05, the speed required to do so is 38400, and using 9600 is complete waste of time.

One of the best secrets imparted so far is "with outputs level 3.3V", which absolves you from using a voltage divider on Arduino Tx. If you are using one, get rid of it.

The type of bluetooth module you are using is apparently still a secret. If it has any writing on the back, you might take the trouble to read it - twice.

I can only guess that you don't know what you've got, even though there is comprehensive commentary in the notes I referred you to, but I think you will get better guidance than you have on configuration at the Martyn Currey website, for which there is a link at the end of the notes.

Quote
I don't use the pin 5 , 7 to power up my module
is incomprehensible, but probably a good idea.

Go Up