HC-12 Module stopped receiving, cannot understand why

Hi, 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, sending every minute - 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.

  • Sending a simple string "Test", still no results.

Relevant code:

Transmitter:

#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);
int DHTPIN = 4;
int LMPIN = 5;
DHT dht(DHTPIN, DHTTYPE);
StaticJsonDocument<80> doc;


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

void loop() {
  delay(5000);                                // wait 5 seconds. @todo Change to millis() counter 
  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);
  Serial.println(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() {
  Serial.begin(9600);
  HC12.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

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

void loop() {

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

I'm pretty stumped by the fact that it stopped working, and that both the HC-12 modules seem to be fine (at least they respond to all the AT commands). I even tried purging arduino data from the file 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?

Thanks a lot!

damien_pirsy:
Transmitter seems to be working fine, at least it prints the number of bytes written in the Serial Monitor.

That only proves the Arduino is working.

If a wireless receiver is not producing data there is no way to tell whether it is the Tx or the Rx is at fault.

If it was working well and is now not working even though the software has not been changed or updated I would be looking for a poor electrical connection somewhere.

Another possibility is radio interference from some new device, maybe not even in your house.

Do you have some spare HC12s for testing?

Have you got a pair of very simple test programs that just send "hello world N" at one second intervals? With N being a number from 0 to 9 that increments with every transmission so you can see if any messages get lost?

I'm not familiar with HC12 modules, but another thought is that the power supply for the Tx may be insufficient.

...R

Robin2:
That only proves the Arduino is working.

I thought that meant the modules are fine - they respond to the serial communication, faulty device shouldn't be answering I think.

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.