{"id":713,"date":"2023-07-20T18:51:43","date_gmt":"2023-07-20T17:51:43","guid":{"rendered":"https:\/\/arduino-developer.com\/arduino\/?p=713"},"modified":"2023-10-18T12:10:54","modified_gmt":"2023-10-18T11:10:54","slug":"bluetooth-wireless-arduino-programming-using-the-hc-05","status":"publish","type":"post","link":"https:\/\/arduino-developer.com\/arduino\/hardware\/programmers\/wireless-programming\/bluetooth-wireless-arduino-programming-using-the-hc-05","title":{"rendered":"Bluetooth Arduino programming using the HC-05"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Parts<\/h5>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/thepihut.com\/products\/hc-05-bluetooth-module\" target=\"_blank\">HC-05 Bluetooth Serial Transceiver<\/a>, you want the HC-05 that is mounted to the 6 pin breakout\/interfacing board like in this picture:<\/p>\n\n\n\n<figure class=\"wp-block-image size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"140\" src=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc-05-bluetooth-module-300x140.png\" alt=\"\" class=\"wp-image-716\" srcset=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc-05-bluetooth-module-300x140.png 300w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc-05-bluetooth-module-60x28.png 60w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc-05-bluetooth-module-150x70.png 150w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc-05-bluetooth-module.png 564w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">HC-05 pins<\/h4>\n\n\n\n<p>See our dedicated page on the HC-05 &#8211; <a rel=\"noreferrer noopener\" href=\"https:\/\/ibex.tech\/resources\/geek-area\/communications\/bluetooth-communications\/bluetooth-modules\/hc-05\" target=\"_blank\">click here<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Configuring the HC-05<\/h4>\n\n\n\n<p>See our dedicated page on how to configure the HC-05 &#8211; <a rel=\"noreferrer noopener\" href=\"https:\/\/ibex.tech\/resources\/geek-area\/communications\/bluetooth-communications\/bluetooth-modules\/hc-05-configuration\" target=\"_blank\">click here<\/a>.<\/p>\n\n\n\n<p>Follow these steps to configure the HC-05 for wireless Arduino programming. You should see an OK response for each command.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Return the HC05 to its default manufacture settings<\/h5>\n\n\n\n<p><em>You need to press and hold the push button when sending this one, as it causes the HC-05 to reset and it will exit config mode as it restarts without the button held<\/em>.<\/p>\n\n\n\n<p>AT+ORGL\\r\\n<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Set role to Slave<\/h5>\n\n\n\n<p>AT+ROLE=0\\r\\n<\/p>\n\n\n\n<p>(0 = Slave, 1 = Master)<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Change drive indication of LED pins<\/h5>\n\n\n\n<p>AT+POLAR=1,0\\r\\n<\/p>\n\n\n\n<p>PIO8<\/p>\n\n\n\n<p>PI08 outputs high level, PI09 (STATE pin) output low level on Bluetooth connectionconnection<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Change comms settings<\/h5>\n\n\n\n<p>AT+UART=115200,0,0\\r\\n<\/p>\n\n\n\n<p>Changes the baud rate to match the Arduino Uno programming setup (115200 baud, 1stop bit, no parity). N.B. this doesn&#8217;t change the baud rate for config mode, that is always 38400 baud.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Change device name from the default HC-05 (optional)<\/h5>\n\n\n\n<p>AT+NAME=NEWNAME\\r\\n<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Change default security code from 1234 (optional)<\/h5>\n\n\n\n<p>AT+PSWD=&#8221;5678&#8243;\\r\\n<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Initialise<\/h5>\n\n\n\n<p>AT+INIT\\r\\n<\/p>\n\n\n\n<p>(We got an ERROR response for this one, don&#8217;t know why?)<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Complete the config<\/h5>\n\n\n\n<p>Cycle the power to the module (without holding the button).<br>It will now be running at 115200 baud and be in pairing mode.<\/p>\n\n\n\n<p>The config settings are non-volatile (they are remembered when power is lost)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Connecting the HC-05 to your Arduino for remote programming<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Arduino<\/td><td>HC-05<\/td><\/tr><tr><td>IO0<\/td><td>TX (Arduino RX, HC05 TX)<br>Can be connected directly to the Arduino Uno as it will accept 3.3V as a high level.<\/td><\/tr><tr><td>IO1<\/td><td>RX (Arduino TX, HC05 RX)<br>Connect via 1K+2K potential divider.<br>The potential divider is required on the RX pin to shift the Arduino 5V TX pin down to 3.3V required by the HC-05 RX pin.<\/td><\/tr><tr><td>RESET<\/td><td>STATE, connect via a series 100nF capacitor and then add a 15K pulldown. The series capacitor is required because the STATE pin goes low for the entire time the Bluetooth connection is made, whereas the Arduino needs just a brief low pulse on its RESET pin for the bootloader to run and for it to be available to be programmed.<br>The 15K pull down works with the 10K pull up that is on the Arduiono Uno. The HC-05 output is 3V3 which means that without the pull down added the pulse through the 100nF doesn&#8217;t go low enough to reset the Arduino&#8217;s 5V microcontroller. Using the 15K combined with the Uno&#8217;s 10K lowers the Reset pin voltage, still above the min threshold for it to run, but nearer to 0V to allow the HC-05 to successfully pulse it low via the 100nF.<br>The reason this trick works is because the Bluetooth link is newly made each time the Arduino IDE carries out a programming operation. <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"529\" height=\"748\" src=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/arduino-bluetooth-programming.png\" alt=\"\" class=\"wp-image-833\" srcset=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/arduino-bluetooth-programming.png 529w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/arduino-bluetooth-programming-212x300.png 212w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/arduino-bluetooth-programming-42x60.png 42w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/arduino-bluetooth-programming-106x150.png 106w\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" \/><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading\">Connecting to your remote Arduino with its slave HC-05 from Windows Arduino IDE<\/h4>\n\n\n\n<p>Windows Control Panel &gt; Windows devices and printers &gt; Add a device<\/p>\n\n\n\n<p>When it appears select the HC-05 and connect it (its default PIN is 1234).<br>Note that its default name is actually incorporated with its software version, so for example our test device was named &#8220;H-C-2010-06-01&#8221; (you can set a name you choose in the steps above if you wish).<br>It may also be shown as &#8220;Unknown&#8221; without its proper name on the first &#8220;Add a device&#8221; screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"870\" height=\"679\" src=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/finding-hc-05.png\" alt=\"\" class=\"wp-image-770\" style=\"width:653px;height:509px\" srcset=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/finding-hc-05.png 870w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/finding-hc-05-300x234.png 300w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/finding-hc-05-768x599.png 768w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/finding-hc-05-60x47.png 60w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/finding-hc-05-150x117.png 150w\" sizes=\"auto, (max-width: 870px) 100vw, 870px\" \/><\/figure>\n\n\n\n<p>That&#8217;s it, it will now appear as a serial port in Windows<\/p>\n\n\n\n<p>Windows may add two serial ports when the device is added. To find the correct port to use, right click the HC-05 device and select Properties. Select the Hardware tab and the COM port number will be shown:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"745\" src=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc05-properties-com-port.png\" alt=\"\" class=\"wp-image-838\" srcset=\"https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc05-properties-com-port.png 581w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc05-properties-com-port-234x300.png 234w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc05-properties-com-port-47x60.png 47w, https:\/\/arduino-developer.com\/arduino\/wp-content\/uploads\/hc05-properties-com-port-117x150.png 117w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/figure>\n<\/div>\n\n\n<p>Select this COM port in the Arduino software.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Programming<\/h4>\n\n\n\n<p>You then program using the Arduino IDE as normal. You may find that programming occasionally fails and the Arduino IDE locks up in &#8220;Uploading\u2026&#8221; state. If this happens, give it a couple of minutes to time out. It&#8217;s much better to wait on the Arduino IDE to time out than to close it and then restart it to try again, as doing this can cause the com port to become unusable. Wait a bit and let the software exit the uploading state cleanly and then try again.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Troubleshooting<\/h4>\n\n\n<p>Windows doesn&#8217;t find it<\/p>\n<p style=\"padding-left: 40px;\">We found our PC running Windows 11 would not find it when adding a device from Bluetooth &amp; devices &gt; Devices, but would find it when using Add a device from Control Panel &gt; Devices and Printers.<\/p>\n<p>&#8220;The device stopped waiting &#8211; try adding it again&#8221;<\/p>\n<p style=\"padding-left: 40px;\">Being quicker in our responding to the Windows prompts seemed to solve this (select it as soon as it appears and enter the PIN as soon as it asks).<\/p>\n<p>There are 2 com ports created for the HC05<\/p>\n<p style=\"padding-left: 40px;\">Right click the HC-05 device and select Properties. Select the Hardware tab and the COM port number will be shown (don&#8217;t try and program with the Arduino IDE set to the other COM port number, it seems to lock up the Arduino software).<\/p>\n<p>Arduino IDE locks up in &#8220;Uploading&#8230;&#8221; state<\/p>\n<p style=\"padding-left: 40px;\">As mentioned above give it a couple of minutes to time out. It&#8217;s usually much better to wait on the Arduino IDE to time out than to close it and then restart it to try again, as this can cause the com port to become unusable. Wait a bit and let the software exit the uploading state cleanly and then try again.<\/p>\n<p style=\"padding-left: 40px;\">If you Windows added 2 com ports for your HC05 and you&#8217;ve selected the wrong one, then you may need to close the Arduino IDE to be able to try again with the other COM port as in our experience it can get stuck in the Uploading state forever in this case. Give it a couple of minutes first though just in case.<\/p>\n<p>We have found that Windows can be a little bit flaky at times, but in general programming over the Bluetooth link will work on retrying if you&#8217;re patient. It&#8217;s frustrating because if you watch the LED on the HC05 and maybe on your project too you can tell when it&#8217;s reset to program correctly or alternatively has failed pretty much straight away and you then have to sit there waiting on the Arduino software long timeout, just have to get over it and give it its time.<\/p>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parts HC-05 Bluetooth Serial Transceiver, you want the HC-05 that is mounted to the 6 pin breakout\/interfacing board like in this picture: HC-05 pins See our dedicated page on the HC-05 &#8211; click here. Configuring the HC-05 See our dedicated page on how to configure the HC-05 &#8211; click here. Follow these steps to configure [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50],"tags":[],"class_list":["post-713","post","type-post","status-publish","format-standard","hentry","category-wireless-programming"],"_links":{"self":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/comments?post=713"}],"version-history":[{"count":53,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/713\/revisions"}],"predecessor-version":[{"id":846,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/713\/revisions\/846"}],"wp:attachment":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/media?parent=713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/categories?post=713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/tags?post=713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}