Problems with HC-12

Hello, I have been using two HC-12s with Arduino Unos with RX and TX connected to pin 0 and 1 on both Arduinos and GND and VCC connected to 5V and GND on the arduino. However, I cant get them to communicate after trying multiple methods.

#include <SoftwareSerial.h>

SoftwareSerial HC12(1, 0); // HC-12 TX Pin, HC-12 RX Pin

void setup() {
  Serial.begin(9600);             // Serial port to computer
  HC12.begin(9600);               // Serial port to HC12

}

void loop() {
  while (HC12.available()) {        // If HC-12 has data
    Serial.write(HC12.read());      // Send the data to Serial monitor
  }
  while (Serial.available()) {      // If Serial monitor has data
    HC12.write(Serial.read());      // Send that data to HC-12
  }
}

I have been using the same code on both Arduinos with the sending Arduino I get a blinking TX light whenever I send a message in the serial monitor but the receiver doesn't get anything. To see if it was just a code error I also used the code from this github GitHub - DIYTechBros/HC-12 and still no luck.

To ensure it wasn't a hardware error I used a second pair of HC12s and still nothing. Any help is appreciated!

1. Try the following connections (Fg-1) using NANO/UNO; where, DPin-1, 0 are not used as they are engaged with PC/Serial Monitor/IDE.


Figure-1:

2. Upload the following sketches on both UNOs:

#include <SoftwareSerial.h>

SoftwareSerial HC12(10, 11); // SRX = 10, STX = 11

void setup() 
{
  Serial.begin(9600);             // Serial port to computer
  HC12.begin(9600);               // Serial port to HC12
}

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

3. Enter Forum in the InputBox of SM1. Check that Forum has apperaed on SM2.
4. Enter Arduino in the InputBox of SM2. Check that Arduino has apperaed on SM1.

Along with what others have suggested above, kindly check if the transmitter and receiver have been paired properly. You can get help from here: https://www.allaboutcircuits.com/projects/understanding-and-implementing-the-hc-12-wireless-transceiver-module/

Don't use pins 0 and 1 with SoftwareSerial because they are used by the hardware serial interface. Use any other 2 pins except those

okay So I have done this and now I am transmitting but say I put "send" in the serial monitor of one the other just receives a string of numbers "4949534948494949484948484948" which is definitely an improvement but any idea why that's the case?

49 49 53 49 48 49 49 49 48 49 48 48 49 48
Looks suspiciously like the ASCII codes for the characters 11510111010010

yea I tried putting it into like an ACII converter to see if maybe I was getting the data in that form but I don't think it would make any sense to receive 11510111010010 when sending SEND

I should also add that I tried changing the setting of the module while connecting the SET pin to GND but even when I type just AT I receive a random string 69828279821310

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