top of page

Group

Public·10 members
Henry Seleznev
Henry Seleznev

Arduino with HC-05 (ZS-040) Bluetooth Module – AT Mode: Tips and Tricks


<h1>Arduino with HC-05 (ZS-040) Bluetooth Module AT MODE</h1>


<p>Bluetooth is a wireless technology that allows you to connect and communicate with various devices over short distances. It can be used for many applications, such as wireless headphones, keyboards, mice, speakers, printers, game controllers, and more. But did you know that you can also use Bluetooth to control your Arduino projects?</p>




Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE



<p>In this article, you will learn how to use the HC-05 (ZS-040) Bluetooth module with Arduino in AT mode. AT mode is a special mode that allows you to send commands to the Bluetooth module and change its default settings, such as the name, the password, the baud rate, and the role. You will also learn how to connect the HC-05 module to other Bluetooth devices and communicate with them wirelessly.</p>


<p>By the end of this article, you will be able to create interesting and fun Arduino projects with Bluetooth functionality. You will also be able to customize your Bluetooth module according to your needs and preferences.</p>


<h2>What is HC-05 (ZS-040) Bluetooth Module?</h2>


<p>HC-05 (ZS-040) is a popular and low-cost Bluetooth module that can be used with Arduino and other microcontrollers. It is based on the HC-05 chip, which supports Bluetooth 2.0+EDR (Enhanced Data Rate) protocol. It can operate in two modes: data mode and AT mode.</p>


<p>Data mode is the normal mode of operation, where the Bluetooth module acts as a serial port and communicates with other Bluetooth devices. You can use data mode to send and receive data between your Arduino and your smartphone or laptop.</p>


<p>AT mode is a special mode of operation, where the Bluetooth module accepts AT commands from a serial port and responds accordingly. You can use AT mode to configure and modify the settings of the Bluetooth module, such as the name, the password, the baud rate, and the role.</p>


<p>The HC-05 (ZS-040) module has six pins: VCC, GND, TXD, RXD, KEY, and STATE. The VCC pin is used to supply power to the module (3.6V to 6V). The GND pin is used to connect the ground of the module to the ground of your project. The TXD pin is used to transmit data from the module to another device. The RXD pin is used to receive data from another device to the module. The KEY pin is used to enter or exit AT mode. The STATE pin is used to indicate the connection status of the module.</p>


<h3>How to Connect HC-05 (ZS-040) Bluetooth Module to Arduino?</h3>


<p>To connect HC-05 (ZS-040) Bluetooth module to Arduino, you will need the following components:</p>


<ul>


<li>HC-05 (ZS-040) Bluetooth module x 1</li>


<li>Arduino UNO x 1</li>


<li>USB cable x 1</li>


<li>Breadboard x 1</li>


<li>Jumper wires x 4</li>


</ul>


<p>The connection diagram is shown below:</p>


<img src="https://roboindia.com/tutorials/wp-content/uploads/2018/01/HC_05_AT_MODE.png" alt="HC-05 connection diagram">


<p>The steps are as follows:</p>


<ol>


<li>Connect VCC pin of HC-05 module to 5V pin of Arduino UNO.</li>


<li>Connect GND pin of HC-05 module to GND pin of Arduino UNO.</li>


<li>Connect TXD pin of HC-05 module to RXD pin (pin 0) of Arduino UNO.</li>


<li>Connect RXD pin of HC-05 module to TXD pin (pin 1) of Arduino UNO.</li>


<li>Connect KEY pin of HC-05 module to VCC pin of Arduino UNO.</li>


<li>Connect USB cable from Arduino UNO to your computer.</li>


</ol>


<p>Note: Connecting KEY pin of HC-05 module to VCC pin of Arduino UNO will put the module in AT mode automatically. If you want to switch between data mode and AT mode manually, you can use a push button or a switch instead.</p>


<h4>How to Use HC-05 (ZS-040) Bluetooth Module in AT Mode?</h4>


<p>To use HC-05 (ZS-040) Bluetooth module in AT mode, you will need a serial terminal software on your computer. You can use Arduino IDE or any other software that supports serial communication. In this article, we will use Arduino IDE as an example.</p>


<p>The steps are as follows:</p>


<ol>


<li>Open Arduino IDE on your computer.</li>


<li>Select Tools > Port > COMX (where X is the number of your USB port).</li>


<li>Select Tools > Serial Monitor.</li>


<li>Select Both NL & CR from the drop-down menu at the bottom right corner.</li>


<li>Select 38400 baud from the drop-down menu at the bottom right corner.</li>


<li>Type AT in the input box at the top and click Send.</li>


<li>If everything is working correctly, you should see OK as a response from the module.</li>


</ol>


<p>Congratulations! You have successfully entered AT mode of HC-05 (ZS-040) Bluetooth module. You can now send various AT commands to configure and modify the settings of the module. For example:</p>


<ul>


<li>To check the firmware version of the module, type AT+VERSION and click Send. You should see something like +VERSION:2.0-20100601 as a response.</li>


<li>To change the name of the module, type AT+NAME=YourName and click Send. You should see OK as a response. YourName can be any alphanumeric string up to 20 characters long.</li>


<li>To change the password of the module, type AT+PSWD=YourPassword and click Send. You should see OK as a response. YourPassword can be any numeric string up to 16 digits long.</li>


<li>To change the baud rate of the module, type AT+UART=YourBaudRate and click Send. You should see OK as a response. YourBaudRate can be one of these values: 1200, 2400, 4800, 9600 (default), 19200, 38400, 57600 or 115200 bps.</li>


<li>To change the role of the module, type AT+ROLE=YourRole and click Send. You should see OK as a response. YourRole can be one of these values: 0 for slave role (default), 1 for master role or 2 for slave-loop role.</li>


</ul>


<p>You can find more AT commands in this document: https://www.olimex.com/Products/Components/RF/BLUETOOTH-SERIAL-HC-06/resources/hc06.pdf</p>


<h5>How to Connect HC-05 (ZS-040) Bluetooth Module to Other Devices?</h5>


<p>To connect HC-05 (ZS-040) Bluetooth module to other devices, such as your smartphone or laptop, you will need to exit AT mode and enter data mode. To do that, you will need to disconnect KEY pin from VCC pin on your breadboard or press your push button or switch if you are using one.</p>


<p>Once you are in data mode, you will need to pair your device with HC-05 module using its name and password. The default name is HC-05 and the default password is 1234. You can change them using AT commands as explained above.</p>


<p>After pairing your device with HC-05 module, you will need to establish a serial connection using a serial terminal software on your device or an app that supports serial communication over Bluetooth. For example, you can use Serial Monitor Lite app on Android or Serial app on iOS.</p>


<p>Once you have established a serial connection between your device and HC-05 module, you can send and receive data between them using serial protocol. For example, you can send commands from your device</p>


<p>Conclusion</p>


<p>In this article, you have learned how to use HC-05 (ZS-040) Bluetooth module with Arduino in AT mode. You have learned how to connect HC-05 module to Arduino using jumper wires and breadboard. You have learned how to enter AT mode using KEY pin or a push button or switch. You have learned how to use Arduino IDE as a serial terminal software on your computer. You have learned how to send various AT commands to configure and modify the settings of HC-05 module using serial monitor on Arduino IDE. You have learned how to exit AT mode using KEY pin or a push button or switch. You have learned how to pair your device with HC-05 module using its name and password. You have learned how to control an LED connected to Arduino using HC-05 module and a smartphone app. You have learned how to read sensor values from Arduino using HC-05 module and a smartphone app. You have learned how to use HC-05 module as a master and connect it to another Bluetooth device. You have learned how to change the name and password of HC-05 module using AT commands. You have learned how to reset HC-05 module to factory settings using AT commands.</p>


<p>We hope you enjoyed this article and found it useful for your Arduino projects with Bluetooth functionality. If you have any questions or suggestions, please feel free to leave a comment below.</p> ca3e7ad8fd


About

Welcome to the group! You can connect with other members, ge...
bottom of page