Go Down

Topic: HC-05 Bluetooth modules for remote programming Arduino (Read 8310 times) previous topic - next topic

PaulRB

I wanted to ask gabenix some more questions about use of HC-05 Bluetooth Modules but didn't want to hijack CSGuy's thread further. Here is gabenix's initial reply. I have a few more questions I am hoping he/she can answer but anyone please feel free to chip in.


Hi Paul... To be honest I couldn't find any tutorials to explain how to program/upload sketches with the HC-05. In fact, the conclusion you came up with is in-line with all the information out there. But it's actually an extremely simple solution.

The only thing that keeps the HC-05 from uploading a program to arduino is that it doesn't have a DTR (Data Terminal Ready) pin which tells the arduino to reset and accept a new sketch.

The solution is to re-purpose the "state" pin (PI09)  on the breakout board. It's purpose is to attach to an LED and indicate the connection status. It's default setting is to send the pin HIGH when a connection is made, but you can simply enter into command mode of the HC-05 and use an AT COMMAND to tell it to send the pin LOW when a connection is made.

Voila! In about 1 minute of time you have successfully re-purposed the LED pin to a DTR pin which will reset your arduino to accept a new sketch when you hit the upload button.

A couple things to note... This will work for a pro-mini without additional hardware by connecting to the DTR pin. If you're using an UNO or similar, you will need a capacitor in between our custom "state" pin and the reset pin on the uno. The reason is that the HC-05 will drive our custom pin LOW for the entire connection which would essentially be the same as holding the reset button the entire time. Having the cap in between solves that problem.

It a quick easy fix, takes about a minute to do. It's just a lot harder to explain the steps to do it in a couple sentences.

Here's a link to the AT COMMAND set ---> http://robopoly.epfl.ch/files/content/sites/robopoly/files/Tutoriels/bluetooth/hc-05-at_command_set.pdf

and here's a link to a tutorial, video, and sketch on how to enter the AT COMMANDS. ---> http://www.techbitar.com/modify-the-hc-05-bluetooth-module-defaults-using-at-commands.html

Hope this helps answer some questions...




Thanks again gabenix. I have more questions!

Are these settings (changed with the AT commands) saved in its non-volatile memory? So they don't have to be repeated after each power-up?

If the STATUS pin indicates that a BT connection is running, then resetting the remote Arduino will involve breaking and re-making the connection? Does the Arduino IDE do this somehow each time you hit Upload, or is some extra step needed?

Will this technique work with Pro Micro/Leonardo (I suspect not, only Uno/Pro Mini etc based on ATmega328, not Atmega32U4)?

Have you seen any long-range (class 1?) BT modules with breakout boards available at reasonable cost? I need the 100m/through-walls range for the project I have in mind. (Don't worry, I would be building a weather station or remote Chicken-house lights controller, not a bomb!)

Thanks,

Paul

gabenix

#1
Feb 15, 2014, 08:30 pm Last Edit: Feb 15, 2014, 08:39 pm by gabenix Reason: 1
Sure thing, no problem...

Quote
Are these settings (changed with the AT commands) saved in its non-volatile memory? So they don't have to be repeated after each power-up?


Correct, you only have to do this once.

Quote
If the STATUS pin indicates that a BT connection is running, then resetting the remote Arduino will involve breaking and re-making the connection? Does the Arduino IDE do this somehow each time you hit Upload, or is some extra step needed?


Bluetooth does not maintain a constant connection although it remains "paired". It only remains connected when data is actively being sent or received. If nothing is being sent or requested the connection automatically terminates. When you hit the upload button, your computer will initiate a connection, when the upload is done and all data is sent, the connection will be automatically terminated. The same happens when you open a serial monitor. The connection will remain active until you close the serial monitor, then it will automatically terminate.

The identical thing happens when you open the serial monitor when tethered with USB. A new connection is established when you open the serial monitor and the DTR resets the arduino. This is why, when tethered with USB, your sketch is reset when you open the serial monitor. I place a switch on our custom bluetooth "DTR" pin so that it can be disconnected. This will allow you to open a serial connection without reseting the chip/program.

Quote
Will this technique work with Pro Micro/Leonardo (I suspect not, only Uno/Pro Mini etc based on ATmega328, not Atmega32U4)?


I don't see why it wouldn't work. It would be dependent on the bootloader you're using. I have not had to use it on those platforms so I cannot give a definitive answer.

Quote
Have you seen any long-range (class 1?) BT modules with breakout boards available at reasonable cost? I need the 100m/through-walls range for the project I have in mind. (Don't worry, I would be building a weather station or remote Chicken-house lights controller, not a bomb!)


I don't have any experience with anything besides the HC-05. But again, it should be possible with any serial over Bluetooth connection. The bluetooth is simply another conduit for TX/RX.. In it's simplest form, it's just replacing 2 wires. You will need to source a pin from the module that will go LOW when a connection is initiated.




Paul__B


Quote
Will this technique work with Pro Micro/Leonardo (I suspect not, only Uno/Pro Mini etc based on ATmega328, not Atmega32U4)?


I don't see why it wouldn't work. It would be dependent on the bootloader you're using. I have not had to use it on those platforms so I cannot give a definitive answer.


The Leonardo/ Pro Micro expects its bootloader source through its internal USB interface - you would have to use a bootloader that looked for downloads on its "serial1" interface.

zootalaws

The Leonardo/ Pro Micro expects its bootloader source through its internal USB interface - you would have to use a bootloader that looked for downloads on its "serial1" interface.



AFAIK, the bootloaders expect the code to be loaded via a hardware UART/serial connection. The USB ports are really USB>Serial implementations. That's why you have issues with serial connections on D0/D1 (pins 0 and 1) when plugged into USB.

Anyway - enough information on these posts to be going on with, thanks. Off to play about :)

bhuvaneshnick

hi, if u having trouble in making  into AT mode of HC-05 (ZS-040)(especiall if one having en/wakeup up pin instead of key pin) and trouble in transfering data between two hc05 module . Follow they bellow procedure
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.

for more info  visit below site:
http://abratukhin.blogspot.in/2015/04/connect-atmega328-with-hc-05-zs-040.html

another good reference for making it into master mode is here:
https://alselectro.wordpress.com/2014/10/18/bluetooth-module-hc-05how-to-pair-2-modulesat-command-walkthrough/#comment-1964

aftermaking connection if you stuck in transmitting data from one module to another see below:
http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-easy-method-using-cmode/

Go Up