{"id":2694,"date":"2023-08-15T11:31:17","date_gmt":"2023-08-15T10:31:17","guid":{"rendered":"https:\/\/ibex.tech\/resources\/?p=2694"},"modified":"2023-10-17T14:39:18","modified_gmt":"2023-10-17T13:39:18","slug":"hc-05-configuration","status":"publish","type":"post","link":"https:\/\/ibex.tech\/resources\/geek-area\/communications\/bluetooth-communications\/bluetooth-modules\/hc-05-configuration","title":{"rendered":"HC-05 Configuration"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Config settings<\/h4>\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\">Sending config commands to the HC-05 using a PC using a USB to serial cable<\/h4>\n\n\n\n<p>You might want to do this so you can configure the HC-05 without using an Arduino, or even if you want to connect your computer to a remote HC-05 without using the computer\u2019s Bluetooth adapter for some reason.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Parts<\/h5>\n\n\n\n<p><a href=\"https:\/\/thepihut.com\/products\/hc-05-bluetooth-module\" target=\"_blank\" rel=\"noreferrer noopener\">HC-05 Bluetooth Serial Transceiver<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.adafruit.com\/product\/4364\" target=\"_blank\" rel=\"noreferrer noopener\">FTDI Serial TTL-232 USB Type C Cable &#8211; 5V Power \/ 3.3V Logic<\/a> or <a rel=\"noreferrer noopener\" href=\"https:\/\/uk.rs-online.com\/web\/p\/development-tool-accessories\/0429303?gb=s\" target=\"_blank\">TTL-232R-3V3-WE FTDI USB to UART Cable<\/a><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Wiring<\/h5>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>TTL-232R \/ TTL-232R<\/strong><\/td><td><strong>Function<\/strong><\/td><td><strong>TC-05<\/strong><\/td><\/tr><tr><td>Black<\/td><td>GND<\/td><td>GND<\/td><\/tr><tr><td>Red<\/td><td>VCC<\/td><td>VCC<\/td><\/tr><tr><td>Yellow<\/td><td>RXD<\/td><td>TXD<\/td><\/tr><tr><td>Orange<\/td><td>TXD<\/td><td>RXD<\/td><\/tr><tr><td>Brown<\/td><td>CTS<\/td><td>Link CTS to RTS<\/td><\/tr><tr><td>Green<\/td><td>RTS<\/td><td>Link CTS to RTS<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Configure your serial port \/ terminal software to use 38400-8-N-1 (baud 38400, 8-bit, no parity, 1 stop bit).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Sending config commands to the HC-05 via an Arduino<\/h4>\n\n\n\n<p>E.g. connecting the TX and RX pin of the HC-05 to the TX and RX pins of the Arduino Uno TX and RX pins (don\u2019t connect the STATE pin for this).<\/p>\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) (fine to connect directly to the Arduino Uno)<\/td><\/tr><tr><td>IO1<\/td><td>RX (Arduino TX, HC05 RX)  (connect via 1K2+2K2 potential divider)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>A 1K2+2K2 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.<\/p>\n\n\n\n<p>Menu &gt; Tools &gt; Serial Monitor<\/p>\n\n\n\n<p>Line ending dropdown: \u201cBoth NL &amp; CR\u201d. Note you shouldn\u2019t include the \\r\\n characters at the end of all the commands below. (\u201cNo line ending\u201d and using the characters doesn\u2019t work via the Arduino serial monitor, it seems it doesn\u2019t convert back slashed special characters).<\/p>\n\n\n\n<p>Baud dropdown: \u201c38400\u201d<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Programming the HC-05 using AT commands<\/h4>\n\n\n\n<p>You may need to make sure the HC-05 module is not paired with any other Bluetooth device before doing this.<\/p>\n\n\n\n<p>Connect the HC-05 TX and RX pins to your serial port of choice (e.g. to your Arduino or your computer via a USB to serial adapter, etc).<\/p>\n\n\n\n<p>Configure your serial port \/ terminal software to use 38400-8-N-1 (baud 38400, 8-bit, no parity, 1 stop bit).<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>With power off, press and hold the push button (to tied the PIO11 pin to 3.3V).<\/li>\n\n\n\n<li>Turn the power on to the HC-05.<\/li>\n\n\n\n<li>The HC-05 LED will blink on and off at about 2 second intervals, confirming that it is in AT command mode.<\/li>\n\n\n\n<li>Release the push button.<\/li>\n\n\n\n<li>To test send the following from your serial port: AT\\r\\n<br>You should see the HC-05 respond with: OK\\r\\n<\/li>\n<\/ol>\n\n\n\n<p>The \u201c\\r\\n\u201d means the carriage return and line feed characters. They must be present after each command you send. Your terminal software may add them for you automatically when you hit return \u2013 if you\u2019re not sure try without using them and if you get no response try again with them added.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example commands you can use<\/h4>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/techbitar.weebly.com\/uploads\/2\/0\/3\/1\/20316977\/hc-05_at_commands_1.pdf\" target=\"_blank\">AT Commands pdf doc<\/a><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Check it\u2019s in AT command mode<\/h5>\n\n\n\n<p>AT<\/p>\n\n\n\n<p>(You should get the OK response)<\/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 Master or 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<p><em>You need to press and hold the push button when sending this one, as it causes a HC-05 configured in the opposite mode to reset and it will exit config mode as it restarts without the button held.<\/em><\/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 (e.g. 115200 baud, 1stop bit, no parity). N.B. this doesn\u2019t change the baud rate for AT 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<\/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<\/h5>\n\n\n\n<p>AT+PSWD=&#8221;5678&#8243;\\r\\n<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Read Slave HC-05 Bluetooth address<\/h5>\n\n\n\n<p>AT+ADDR?\\r\\n<\/p>\n\n\n\n<p>You will get back an address like this:<\/p>\n\n\n\n<p>+ADDR:98D3:51:F63A39\\r\\n<br>OK\\r\\n<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Set master HC-05 to fixed address mode<\/h5>\n\n\n\n<p>Change the HC-05 to fixed address mode: AT+CMODE=0\\r\\n<br><em>So it won\u2019t auto-connect to any other device in range<\/em><\/p>\n\n\n\n<p>Set the address of the slave to pair with: AT+BIND=98D3,51,F63A39\\r\\n<br><em>Note that you need to use commas instead of colons here.<\/em><br>There are 6 bytes (pairs of hex characters) used for the address. The first two 00 00 bytes of the devices MAC address are not used.<\/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\u2019t know why?)<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Completing config<\/h5>\n\n\n\n<p>Cycle the power to the module (without holding the button).<br>It will now be running with your new settings.<\/p>\n\n\n\n<p>The config settings are non-volatile (they are remembered when power is lost)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Config settings The config settings are non-volatile (they are remembered when power is lost). Sending config commands to the HC-05 using a PC using a USB to serial cable You might want to do this so you can configure the HC-05 without using an Arduino, or even if you want to connect your computer to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[140],"tags":[],"class_list":["post-2694","post","type-post","status-publish","format-standard","hentry","category-bluetooth-modules"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/2694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/comments?post=2694"}],"version-history":[{"count":19,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/2694\/revisions"}],"predecessor-version":[{"id":2752,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/2694\/revisions\/2752"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/media?parent=2694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/categories?post=2694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/tags?post=2694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}