Categories

Arduino wireless communication - Bluetooth HC-11 HC-12

 

Wireless communication with Arduino using module HC-11 and HC-12.

 

Shows an example of a method of wireless communication using the modules HC-12.

 

Attention!

Module HC-11 and OK-12 do not interact.

 

In the example, we used the following elements:

 

Connection with Arduino

Pin-HC-12Pin Arduino
SETnot connected
TXD2
RXD3
GNDGND
VCC

5 V

 

 

Sets of connected pairs in the same way, one Arduino Board from one module HC-12. The next step is to download the relevant software. Program created based on the example from the Arduino environment (Examples -> SoftwareSerial -> SoftwareSerialExample).

 

  • The program for the Arduino, acting as a transmitter:

 

#include  

SoftwareSerial mySerial(2, 3); // TX, RX 

void setup() 
{ 
 // Open port for communication 

 Serial.begin(9600); 
 mySerial.begin(9600); 
} 

void loop() 
{ 
 mySerial.println("Hello, world?"); // loop sends the message "Hello, world?" every second 

 delay(1000); 
} 

 

  • The program for the Arduino, acting as a receiver:

 

#include  

SoftwareSerial mySerial(2, 3); // TX, RX 

void setup() 
{ 
 // Open port for communication 

 Serial.begin(9600); 
 mySerial.begin(9600); 
} 

void loop() 
{ 
 if (mySerial.available()) 
 Serial.write(mySerial.read()); // if you get a message, displays it on the serial monitor 
} 

 

After you download both programs and connecting a set that works as a receiver, you must run a serial monitor (Tools> Serial monitor). The received message should look like the screenshot below: