The first time we go to use this Bluetooth module 4.2, if you have never dealt with them, it is likely to be taken by despair, as you need to know some small details to use them correctly, but do not worry, it will become clear. Soon, and soon we will be able to use them without even thinking about it for a few seconds.
Bluetooth modules are a very convenient way of communication if you do not want to transmit data through a cable connection; they really have a lot of potential, as it is possible to simply transmit numbers, decimal numbers, character strings and everything we need.
So let's start with how to connect our module to Arduino. This has four pins already soldered, plus two possibly to solder, but which we will not need: the four pins are RXD (<), TXD (>), GND (<), VCC (<).
At first sight it all seems clear enough, but it's easy to make the first mistakes right now; first of all, we are going to power, our module through a voltage of 3.3 V, and not 5 V as we usually do.
Then obviously we connect the GND pin to GND of Arduino, and finally we connect the RXD pin to the TX pin of Arduino, and TXD to RX; yes, the names of the two pins reverse, so by connecting them backwards we will not see any type of data transmission, Bluetooth module 4.2 and this is a very common problem.
The connections with our board appear, only a few small details are missing. First of all we have to understand how to enter AT mode; otherwise it will be impossible to connect two bluetooth modules with correct communication.
This is not very simple in some types of modules, as some have a small side button on the right of the pins that allows us to perform the operation, while others do not.
In any case, now we are going to see how to solve this problem. We always remember that our component we call a module because it comes on a base with copper tracks that allow us to use the micro controller without having to build a circuit every time.
This is fundamental, since to allow our HC-05 to enter AT mode it is necessary to use a cable connected to a voltage of 3.3 V.
Bluetooth module 4.2 is a powerful device, after which put our cable in contact with pin 34 of the micro controller, which is the last one on the top right next to the resistors. At this point, always keeping the cable firmly in contact with the pin, we must disconnect the power supply from VCC, and immediately reconnect it, then removing the contact with pin 34.
We could therefore observe that the red led that indicates that our module is working slows down, remaining on for about two seconds and off as well. If the Led has this rhythm, we will have entered the AT mode.
Below you will find an image of our micro controller (EGBT046S) installed in the HC-05 module which represents the pins whose functions you need to know.
Instead, if our module has the small side button, it will take the place of our hand-made contact, and the procedure will be to press the button while the Bluetooth module 4.2 is running, disconnect VCC, reconnect it and then release the button, which we have held down until then.
When we enter AT mode, we must remember that the transmission baud rate between our component and the serial interface automatically switches to 38400 baud, so if we try to use AT commands at a different baud rate we will not have any results; it is therefore necessary to enter the serial monitor window and set it correctly before proceeding.
I have developed this simple example to make you understand the potential of this module. In the meantime, we need to know that we must have two modules available to be able to do it; you need two Adriano’s, a ONE and a Mega, where the ONE controls the Bluetooth module 4.2 defined as master and the Mega the slave component.
Let's install the two devices in different places, so that they communicate through a wireless connection; in this project we will in fact take data from a certain room to process them and output them in a visible way in another place, in particular I will use a photo resistor to process the light of one position and change the luminous intensity of a LED in the other and write a certain sentence.
The Bluetooth module 4.2 is very convenient for certain things, in fact, thinking about the use of a PIR to create a home security system, this component could play a fundamental role in transmitting information when the module detects a presence at the front door, to notify us immediately. .
We could therefore say that the Bluetooth module offers us transmission speed, convenience and versatility, and even if it is more expensive than making connections through data using the SDA and the SCL, its characteristics fully pay off for this detail.
After entering the AT mode (above we explain how to do it), we need to connect our two modules to make them communicate correctly.
Let's act on our master module, and, after loading the correct code shown above on the Arduino, we enter the serial monitor and write: AT, to verify that the module recognizes the AT commands, and will reply OK.
We hope that you have learnt some new concepts about Bluetooth module 4.2. If you are a beginner, this guide is going to help you a lot.
Prev:Bluetooth ble 5.0 Module Pros & Cons 2021
Free A Quote
Copyrights 2021Technology Co.,Ltd.All Rights Reserved.