I'm trying to setup a simple one way data link between two Arduino using the HC12 433MHz serial communication bords. Should be simple. Lost of examples out there - but so far none of them work for me.
I have four HC12 boards to chose from in case one is bad (or even two!). All look good.
All of the boards will respond to the AT commands. All are setup to the defaults (9600 baud, channel 001, FU3 transmission mode, 20dBm output). On a spectrum analyzer all put out what appears to be a good signal at 433.4MHz. So I think all 4 boards are good, have the same settings and are capable of transmitting.
On both the Tx and Rx end of the link, I use software serial ports on pins 4 and 5 of the Arduino Uno. Pin 4 (UNO Rx) connects to the Tx pin on the HC12. Pin 5 on the UNO connects to the Rx pin on the HC12. The HC12 power is 5v with a 100uF cap to ground and a series diode to drop the voltage (to about 4.3v). Connecting wires are good (tested).
The setup pin on the HC12 boards is floating (but has in internal pullup resistor).
This is the simple TX code. It just sends out a single character twice a second. As far as I can tell, it works. My spectrum analyzer shows a signal at 433.4 MHz, twice a second. If I disconnect the connection between pin 5 (Tx) on the Arduino and the Rx pin on the HC12, the signal goes away (as it should).
#include <SoftwareSerial.h>
SoftwareSerial HC12(4, 5); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
Serial.print ("HC12 TX setup"); // Confirm setup via serial monitor
}
void loop() {
HC12.print("A"); // Send that data to HC-12
delay(500);
}
On a second Arduino, wired identically to the first, here's the code I'm using for testing
#include <SoftwareSerial.h>
SoftwareSerial HC12(4, 5); // HC-12 TX Pin, HC-12 RX Pi
void setup() {
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
Serial.println ("HC12 Rx setup");
}
void loop() {
while (HC12.available()) { // If HC-12 has data
Serial.println(HC12.read()); // Send the data to Serial monitor
}
}
All I get when I look at the serial monitor on the Arduino being used for Rx is the "HC12 Rx setup" message, then nothing. If I'm reading the code right, when there's something in the output buffer of the HC12, it will be read and sent to the serial monitor in the IDE to which that Arduino is connected. So it looks like the HC12 is not receiving anything (or at least isn't decoding any thing it receives)
It this point I'm stuck. I've tested and switched all four modules, I've tested all the wires, all the HC12 units are set to the default values and respond to AT commands (using a different sketch of course). The RF coming out of the Tx end of the link is on the right frequency and look like a digital signal (of some sort). I see nothing on the Rx Arduino.
I've done the usual switching of boards, powering things on and off, resetting the Arduinos etc. I've tried with both Arduinos powered by the same PC and with each one powered by a different PC. I've had similar results when trying sketches I've found on the web for HC12 testing. Something doesn't make sense. What am I missing here? It shouldn't be this hard. What don't I know!