Weird Numbers on HC12 Communication

Hi guys I'm just new to this forum. I just bought 2 HC-12 clones for my uav project, Im just testing those modules before final installation to the platform. In one way communication, one of the modules reading (or because one of the sending) I'm reading numbers like "84,101,115,116" instead of string type "TEST" text. But when i switch the modules between the two Arduino Unos it just works fine. I also checked that big white capacitor's voltage, one of them shows 3.33volts and the other shows 3.32volts at the end. I think my problem is not about range it's about something other. Any ideas how can i fix that? I really need that two way communication.
My codes below:

TRANSMIT

#include <SoftwareSerial.h>;
#define RX 2 //Connect to the TX pin of the HC-12
#define TX 3 //Connect to the RX pin of the HC-12
SoftwareSerial mySerial(RX, TX);


void setup() {
  mySerial.begin(9600);

}

void loop() {
  mySerial.write("Test");
  delay(1000);

}

RECEIEVER

#include <SoftwareSerial.h>;
#define RX 2 //Connect to the TX pin of the HC-12
#define TX 3 //Connect to the RX pin of the HC-12
SoftwareSerial mySerial(RX, TX);

int x;
String t;

void setup() {
  mySerial.begin(9600);
 Serial.begin(9600);
pinMode(13,OUTPUT);
}

void loop() {
  if(mySerial.available()){
    Serial.println(mySerial.read());
   if (t==x){
   digitalWrite(13,HIGH);
    }else{digitalWrite(13,LOW);}

}}

try

    Serial.write(mySerial.read());

You are seeing numerical representations that are the foundation of the ASCII character set.

They will seem much less weird if you research ASCII.

84 is the decimal equivalent of the ASCII value for the character T. And the character string was "Test", not "TEST". Case makes a difference.

1 Like

Thank you for your reply, i just changed the line with your line it works.

1 Like

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