HC-05 ModificationThe HC-05 bluetooth module is used to add bluetooth capability to any Arduino project. The module can be integrated into any project without the need to add complicated code. I've been using these modules for a number of years to get remote telemetry from projects and to send commands without the need for wires. During this time I have wished that I could program my micro controller through the bluetooth module however this isn't possible with a HC-05 out of the box. The HC-05 modification will allow you to program your micro controller via bluetooth. I will be designing and releasing a SMD version of this modification (incl HC-05) for purchase for around £10. The version that I will release will also have a control pin allowing remote programming to be disabled when desired.
The below diagram is of the HC-05 modification;
I have also added a schematic of the circuit for clarity;
The above diagram shows how the TX/RX pins should be connected, This will also work if the power comes from the USB port or the 5V pin.
The diagram shows the STATE pin of the HC-05 being connected to the reset pin of the Arduino via a 100nF capacitor. When the STATE pin logic level goes from high to low (3.3V - 0V) their will be a potential difference going over the capacitor forcing it to charge up, puting a 0V pulse on the reset pin of the Arduino. Once the capacitor is recharged the 0V on the reset pin will be removed and because the capacitor is only 100nF the CR time is very quick. The voltage divider circuit is their to reduce the voltage on the reset pin. If this voltage is too high the reset function will not work. For this circuit to work the voltage on the reset pin must be reduced to less than 3.9V, it would usually sit around 4.4V- 5V.
Once the modification is created and added to the HC-05 you will need to connect the HC-05 to a programmer (see my tutorial here) and use AT commands to change the baud rate to the same baud rate as the bootloader in your micro controller (see this link to view baud rates for different micro controllers), this will be 57600 or 115200. Once the baud rate is changed the POLAR variable will need to be changed to reverse the logic on the state pin.
The commands to do this are;
or if your baud rate is 115200;
After each line is entered the serial monitor should return the string "OK".
Below is a video of similar commands being entered via the serial monitor;
When uploading code to your micro controller ensure that you have paired the HC-05 with your computer and that you select the correct comm port in Arduino IDE.
Please note that when a bluetooth connection is made with your HC-05 the Arduino will be reset. This can't be avoided with this design however I will have a more complicated design available soon with a control pin where the remote programming feature can be disabled which will stop the Arduino from being reset upon a bluetooth connection.
If you have made this modification and it doesn't work as desired check your wiring and that you have the correct comm port selected in Arduino IDE. If all that seems fine try powering your Arduino via the VIN pin with a 3.7V battery. If it still doesn't work then your wiring will be wrong. If it does work you need to use a multimeter to see what the voltage is at the reset pin with respect to ground if its above 4V change R2 with a larger valued resistor. You could install a 5K potentiometer and adjust the voltage until the voltage at the reset pin is around 3.6 when powered from USB or 3.9V when powered from VIN. This modification will work if the voltage at the reset pin is 3.9 - 1.7V, if it's too low then the Arduino will constantly reset and if it's too high then the Arduino wont reset when a BT connection is made. with the stock R2 value you should have between 2.5 - 3V at the reset pin which is ideal.
Any issues or suggestion comment below.