Need help choosing the right circuit components in my HC12 transceiver

Hi everyone. I have problem with my HC12 transceiver. So I found this website that shows the right way to use HC12 transceiver base on datasheet. I follow the schematic they provide but they didnt specify the value of the capacitor but they mention the minimum which is 22µF and that is what i used. After soldering all the components I tested it with my arduino uno by sending "AT" to the serial and it replied "OK" so I believed theres nothing wrong my soldering and components. The PROBLEM is when I begin to interface it with my project which is to receive readings from another Arduino it didnt recieved anything. I am sure the code is correct coz if I just directly plug in the hc12 with no other components it works fine. I think those components are important to protect hc12, please help me correct my circuit. Here my circuit looks like.
gethelp

Did you remove the ground connection from the SET pin?

What purpose does the diode have, other than a 0.7 voltage drop?

In practice, these two elements are not used.
I have a couple of HC12 modules: one is in a teensy 3.2 that works as the main control, the other is in a teensy 4.1, in which is the video player based on a 7" TFT NHD FT813.

So far both work without problems.

Load this same example on both MCUs and try again with the AT instruction, both HC12 should respond:

/*  
 *  Abajo esta el autor original del sketch; yo le cambie algunos parámetros nomas 
 *  
 *  HC12 Send/Receive Example Program 2
    By Mark J. Hughes
    for AllAboutCircuits.com

    Conectar el pin RXD del HC12 al pin digital de Arduino 11
    Conectar el pin TXD del HC12 al pin digital de Arduino 10
    Conectar el pin SET del HC12 al pin digital de Arduino 9

    IMPORTANTE: El sketch original recomienda no alimentar al Arduino
    solo por el cable USB sino que conectarlo por USB pero ademas
    proveerle otra alimentación (como ser una pila de 9V).
    Respecto al capacitor de desacople recomendado en la imagen
    del conexionado, yo he trabajado sin el y no he tenido problemas.*/

#include <SoftwareSerial.h>

const byte HC12RxdPin = 1;                      // Pin de Arduino conectado al RXD del HC12
const byte HC12TxdPin = 0;                      // Pin de Arduino conectado al TXD del HC12
const byte HC12SetPin = 23;  //3 T41   A9/23 T32                   // Pin de Arduino conectado al SET del HC12

unsigned long timer = millis();                 // timmer para los delay
char SerialByteIn;                              // Variable temporal
char HC12ByteIn;                                // Variable temporal
String HC12ReadBuffer = "";                     // Escribir/leer el buffer 1 del HC12
String SerialReadBuffer = "";                   // Escribir/leer el buffer 2 del puerto serie
boolean SerialEnd = false;                      // Indicador de fin del string del puerto serie
boolean HC12End = false;                        // Indicador de fin del string del HC12
boolean commandMode = false;                    // Envío de comandos AT

// Creamos los pines de transmisión y recepción del "nuevo" puerto serie
SoftwareSerial HC12(HC12TxdPin, HC12RxdPin);

void setup() {

  HC12ReadBuffer.reserve(64);                   // Se reservan 64 bytes para el mensaje a la entrada del puerto serie
  SerialReadBuffer.reserve(64);                 // Se reservan 64 bytes para el mensaje a la entrada del HC12
  pinMode(HC12SetPin, OUTPUT);                  // Se configura el pin como salida (High for Transparent / Low for Command)
  digitalWrite(HC12SetPin, HIGH);               // Al ponerlo en alto, se activa el modo "Transparente" para setear parametros
  delay(80);                                    // 80 ms de delay recomendados en la hoja de datos
  Serial.begin(9600);                           // Abro el puerto serie de la computadora
  HC12.begin(9600);                             // Abro el puerto serie de Arduino que va al HC12
}

void loop() {

  while (HC12.available()) {                    // Mientras el puerto del HC12-Arduino tenga datos
    HC12ByteIn = HC12.read();                   // Se guarda cada caracter del buffer en byteIn
    HC12ReadBuffer += char(HC12ByteIn);         // Escribimos cada caracter del byteIn al buffer HC12ReadBuffer
    if (HC12ByteIn == '\n') {                   // Chequeamos si esta el caracter que indica el fin del string
      HC12End = true;                           // La variable HC12End (el indicador de fin del string del HC12) se pone en TRUE
    }
  }

  while (Serial.available()) {                  // Mientras en el puerto Arduino-computadora hay datos
    SerialByteIn = Serial.read();               // Se guarda cada caracter en byteIn
    SerialReadBuffer += char(SerialByteIn);     // Escribimos cada caracter del byteIn en el buffer SerialReadBuffer
    if (SerialByteIn == '\n') {                 // Chequeamos si esta el caracter que indica el fin del string
      SerialEnd = true;                         // Ponemos la variable SerialEND en TRUE
    }
  }

  if (SerialEnd) {                              // Lo siguiente ocurre cuando sea TRUE la variable SerialEnd

    if (SerialReadBuffer.startsWith("AT")) {    // Si el comando empieza con AT
      HC12.print(SerialReadBuffer);             // Se envía el comando
      delay(100);                               //
      digitalWrite(HC12SetPin, LOW);            // Sepone el pin de SET en estado bajo para entrar al modo de comandos
      delay(100);                               // Un delay recomendado antes de empezar a enviar comandos
      Serial.print(SerialReadBuffer);           // Vemos el "eco" del comando que enviamos en el monitor serie
      HC12.print(SerialReadBuffer);             // Enviamos el comando al HC12
      delay(500);                               // Esperamos 500 ms para la respuesta
      digitalWrite(HC12SetPin, HIGH);           // Salimos del modo de comandos y entramos al modo transparente
      delay(100);                               // Un delay antes de proceder
    } else {
      HC12.print(SerialReadBuffer);             // Transmit non-command messageAT
    }
    SerialReadBuffer = "";                      // Vaciamos el buffer SerialReadBuffer
    SerialEnd = false;                          // Reseteamos el indicador de fin del string
  }

  if (HC12End) {                                // Si el indicador HC12End esta en TRUE
    if (HC12ReadBuffer.startsWith("AT")) {      // Chequeamos si el comando AT fue recibido
      digitalWrite(HC12SetPin, LOW);            // Ponemos en bajo el pin de SET y entramos en el modo de comandos
      delay(100);                               // Un delay antes de enviar el comando
      Serial.print(SerialReadBuffer);           // Eco del comando para verlo en el monitor serie
      HC12.print(HC12ReadBuffer);               // Escribe el comando en el HC12
      delay(500);                               // Esperamos 500 ms para ver su respuesta
      digitalWrite(HC12SetPin, HIGH);           // Salimos del modo de comandos y volvemos al modo transparente
      delay(100);                               // Un delay antes de proceder
      HC12.println("Remote Command Executed");  // Una linea indicando si se ejecuto el comando
    } else {
      Serial.print(HC12ReadBuffer);             // Envio del mensaje a la pantalla
    }
    HC12ReadBuffer = "";                        // Vaciamos el buffer
    HC12End = false;                            // Reseteamos el indicador de fin del string
  }
}

The datasheet of the HC-12 states this: "If the module is working in transmitting state for a long time, it is suggested that one 1N4007 diode should be connected in series when the power voltage is greater than 4.5V, to avoid heating of built-in LDO of module."

The cap should be on the module side of the diode.

And then there is the issue of fakes/clones. They have different writing on the crystal.
Two originals can talk together, two clones too, but a clone and an original might not.
The correct writing on the crystal should be documented on the net somewhere.
Leo..

Yes. I remove the SET pin from the ground every time I'm testing it to receive data.

Thanks for sharing. Actually I already tried that, before I just directly use the hc12 without those capacitor and diode but since I am currently improving my project it got busted overtime I think I damage the the LDO regulator due to overheating. Thats why I buy another one and tried to search the right way to use it which is according to data sheet of hc12 I need to put diode and capacitor as well for some benefits. I just dont know if my circuit is correct.

And does it work if instead of connecting it to 5 V you connect it to 3.3V? The teensy boards I use are 3.3V and the two modules work perfectly.

Hi, @el11ven

You should try putting the capacitor cross the Vcc and gnd pins of the module, currently you have it on the wrong side.

What model Arduino controllers are you using and what is the power supply?

Some images of your project would also help.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

The HC-12 can be powered with 3.2volt to 5.5volt (200mA), but the chip works with 3volt logic.
It doesn't make a difference if you power it with 3.3volt or 5volt, as long as that supply can provide 200mA during transmit.
Leo..

Sorry, English is not my first language. What do you mean I have it in wrong side?? Im using Arduino Uno and it is powered through Vin pin by external 5.3v. While the hc12 is powered by 5v pin of arduino.
Here is the actual photo. The label on diode is already erased the red mark means the cathode side.

tyyt

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

Minimum voltage for the V-in pin is 7volt (see the documentation of the Uno).

Connect the cap between VCC and GND of the HC-12 module.
Leo..

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.