I've created a simple transmitter with an HC-12 and an Arduino Nano (clone), where I send the values of DHT11 and LM35 sensors to a receiver unit made only of a Wemos D1 and another HC-12.

Setup is really simple and worked fine for a couple of days (transmitter in the cellar 2 floors down, receiver in my living room, it was POSTing data to my own server correctly), then I unplugged the receiver and modified the transmitter to add a JSON library; when I plugged them back again the receiver is not getting anything anymore. Transmitter seems to be working fine, at least it prints the number of bytes written in the Serial Monitor.

I tried:

  • reverting back to the working version (no JSON), but still the same
  • tested each of the HC12 modules with a simple test code and AT commands, they all responds and are all set to factory configuration, like it was before actually (AT+DEFAULT)
  • made another receiver with an Arduino Uno and a lcd screen - a setup that I was successfully using before changing to the Wemos. Strangely, now this setup doesn't work too...
  • Switched the modules and what I got? The transmitter still transmits, the receiver doesn't receive, nothing changed.
    • Tried sending a simple string "Test", still no results.

Relevant code:


#include <ArduinoJson.h>      
#include <DHT_U.h>            // just Adafruit Library
#include <DHT.h>
#include <SoftwareSerial.h>
#define DHTTYPE DHT11   // DHT 11
SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin
int DHTPIN = 4;
int LMPIN = 5;
StaticJsonDocument<80> doc;

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

void loop() {
  float h = dht.readHumidity(); 
  float t = dht.readTemperature();
  int reading = analogRead(LMPIN);
  float lmt = reading/9.31;
  doc["dht_h"] = h;
  doc["dht_t"] = t;
  doc["ds_t"] = lmt;
  char result[50];
  serializeJson(doc, result);
  int written = HC12.print(result);
  Serial.println(written);    // it's 39 chars

Receiver (all wifi sections are removed):

#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
#define STASSID "....."
#define STAPSK  "....."
SoftwareSerial HC12(D13, D15); // HC-12 TX Pin, HC-12 RX Pin

const char* ssid     = STASSID;
const char* password = STAPSK;
const char* host = "...........";
const uint16_t port = 3000;

void setup() {
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500); Serial.print(".");

void loop() {

  String content = HC12.readString();
  if(content.length()) {
    // This will send a string to the server
    Serial.println("sending data to server");
    if (client.connected()) {

I'm pretty stumped by the fact that it stopped working, and that both the HC-12 modules seem to be working fine (at least they respond to all the AT commands). I even tried purging arduino from the system and reinstalling (I now have the very latest IDE release) but nothing....

Am I missing something obvious? (I've a weak electronic background, I'm a web developer by trade). Is there a way to check if data is actually sent? How can I debug these modules?

  • why not just run the DHT11 and LM35 from the ESP and save the debug effort? You should also use the server.on handlers instead of the painfully low-level client.connected stuff.
    – dandavis
    Feb 13, 2020 at 19:08
  • @dandavis Because there's no wifi connection where I put the sensors (it's floor -1th, I live at 2nd), and also I plan to add other devices to the receiver. But please don't focus on the ESP, the issue seems to be another Feb 14, 2020 at 8:11
  • Did you check that your receiver connects to the WiFi?
    – gbg
    Feb 14, 2020 at 12:48
  • @gbg Forget the WIFI (anyway, yes, it does), I cannot receive anymore with the HC-12 (it worked before) Feb 14, 2020 at 13:32

1 Answer 1


For what it's worth, I manage to make them working again by playing a bit with the settings of both modules.

Using a simple test sketch I issued some AT commands to both modules; I had already tried setting them to the DEFAULT setup with AT+DEFAULT, but that was fruitless. I decided to left the mode as is (FU3), same for the serial rate (B9600), but I tried switching channel so I set both modules with AT+C002.

That did the trick, maybe was some sort of external interference, or a lack of precision in the channel settings - I just know that's a week now they've been communicating just fine and that's what matters.

So, if they fail to communicate, first try to adjust their settings, don't assume the DEFAULT ones are surely working.

  • For long range, better using FU4 , even if it's sloooooow.
    – Peter
    Mar 24, 2021 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.