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-12 Pin Arduino
SET not connected
TXD 2
RXD 3
GND GND
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:

 

  1. #include
  2. SoftwareSerial mySerial(2, 3); // TX, RX
  3. void setup()
  4. {
  5. // Open port for communication
  6. Serial.begin(9600);
  7. mySerial.begin(9600);
  8. }
  9. void loop()
  10. {
  11. mySerial.println("Hello, world?"); // loop sends "Hello, world?" message every second
  12. delay(1000);
  13. }

 

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

 

  1. #include
  2. SoftwareSerial mySerial(2, 3); // TX, RX
  3. void setup()
  4. {
  5. // Open port for communication
  6. Serial.begin(9600);
  7. mySerial.begin(9600);
  8. }
  9. void loop()
  10. {
  11. if (mySerial.available())
  12. Serial.write(mySerial.read()); // if it receives a message, displays it on the serial monitor
  13. }

 

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:

 

style="padding-left: 15px;"

Botland.store - shop for makers!