I purchased 30 HC12's and designed a simple Eagle CAD PCB which I got in and hooked everything up. I was sure to use a decoupling capacitor and a GP diode since my in voltage to the HC12 was 4.6V. (This dropped the voltage down to 3.9V) so I ran several Codes through it using a Arduino Pro Micro. I double checked the Serial out on it and everything is working fine on the Arduino. However... Out of 30... Not one will transmit. I have to be doing something wrong. Pin 2 (TX) Pin 3 (RX) and I'm running simple code but I can't get these things to transmit anything. I can't even get an AT command to respond. Is there something I could be missing? Checked GND.. Checked VCC.. Checked Voltage at the HC12. I've run the simple code and I've run more complex codes but nothing works.. I even took the HC12's and ran them on a bread board with the exact same circuit.. Still nothing.. Not even 1 ft.. Any ideas anyone?
Transmit Code:
#include <SoftwareSerial.h>
#define setPin 4
SoftwareSerial HC12(2, 3); // HC-12 TX Pin, HC-12 RX Pin
byte incomingByte;
String readBuffer = "";
void setup() {
Serial.begin(9600); // Open serial port to computer
HC12.begin(9600); // Open serial port to HC12
pinMode(setPin, OUTPUT);
digitalWrite(setPin, LOW);
delay(250);
HC12.write("AT+DEFAULT");
delay(250);
digitalWrite(setPin, HIGH); // HC-12 normal, transparent mode
}
void loop() {
delay(100);
Serial.println("I am tran'smission");
while (HC12.available()) { // If HC-12 has data
incomingByte = HC12.read(); // Store each incoming byte from HC-12
readBuffer += char(incomingByte); // Add each byte to ReadBuffer string variable
}
delay(1000);
while (Serial.available()) {
HC12.write(Serial.read());
}
HC12.write("123");
Serial.println("Sending Signal...");
while (HC12.available()) {
Serial.write(HC12.read());
Serial.println("");
Serial.println("***********************");
}
readBuffer = "";
delay(1000);
}
Receive Code:
#include <SoftwareSerial.h>
int setPin = 4;
SoftwareSerial HC12(3, 2); // HC-12 TX Pin, HC-12 RX Pin
byte incomingByte;
String readBuffer = "";
void setup() {
Serial.begin(9600); // Open serial port to computer
HC12.begin(9600); // Open serial port to HC12
pinMode(setPin, OUTPUT);
digitalWrite(setPin, LOW);
delay(250);
HC12.write("AT+DEFAULT");
delay(250);
digitalWrite(setPin, HIGH); // HC-12 normal, transparent mode
}
void loop() {
delay(100);
while (HC12.available()) { // If HC-12 has data
incomingByte = HC12.read(); // Store each icoming byte from HC-12
readBuffer += char(incomingByte); // Add each byte to ReadBuffer string variable
}
delay(100);
while (Serial.available()) {
HC12.write(Serial.read());
}
if (readBuffer == "Testing, testing...123") {
Serial.println("DATA RECEIVED!!!");
Serial.println("**************************");
HC12.print(readBuffer);
delay(100);
}
readBuffer = "";
delay(1000);
}
[Code]