fbpixel
Tags: ,
3.7
(3)

Le module HC-12 permet la communication sans-fil semi-duplex entre deux appareils via les fréquences radio. Il travaille sur la mêmes plages de fréquences que le module RF433 mais permet d’atteindre des distances de communication beaucoup plus importante (<1km). De plus, le même module peut servir en émission ou en réception.

Material

  • Computer
  • Arduino UNO x2
  • USB A Male Cables
  • HC-12 modules x2

Principle of operation

The HC-12 module is a radio frequency module that transmits on the 433.4-470MHzz frequency range. It consists of a radio transceiver Si4463 which manages the wireless communication and a microcontroller STM8S003F3 which manages the serial communication with the micrcontroller. The SET pin is used to configure the operating mode of the HC-12 module.

Scheme

To communicate with the HC-12 module, we will use a UART (or TTL) output of the microcontroller. In this example we use pins 2 and 3. The module can be powered by the 3.3V or 5V output of the microcontroller.

To improve the stability of the communication, which depends greatly on the power supply, you can add a capacitor (~50µF) between the VCC and GND pins.

You have to make the same assembly for the transmitter side and the receiver side.

Code

To manage the HC-12 module, we use the SoftwareSerial.h library. The library allows to create a serial communication bus with some pins of the microcontroller. Check carefully in the technical documentation, which pins you can use. In this example, the code is identical for the transmitter and the receiver.

#include <SoftwareSerial.h>

SoftwareSerial HC12(2, 3); // HC-12 TX Pin, HC-12 RX Pin

void setup() {
  Serial.begin(9600);            
  HC12.begin(9600);           
}

void loop() {
  while (HC12.available()) {
    Serial.write(HC12.read());
  }
  while (Serial.available()) { 
    HC12.write(Serial.read());
  }
}

Results

Once the code is loaded on both Arduino’s, you can open two serial monitors. Then, you will be able to enter messages in one or the other serial monitor and it will be displayed on the other monitor.

Applications

  • Remote control of a system with a radio control based on a HC-12 module
  • Data exchange between two home automation devices

Sources

How useful was this post?

Click on a star to rate it!

Average rating 3.7 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?