So im am fairly new to arduino. I am trying to make a long range alarm system using 2 HC12 modules and 2 leonardos. The problem is that I cant get the HC12 modules to work in any way. I just bought them and they just dont do anything they are supposed to do, but idk if it is my fault or if they were both broken when they arrived.
I first tried a simple program to test the communication between them:
/* Arduino Long Range Wireless Communication using HC-12
Example 01
by Dejan Nedelkovski, www.HowToMechatronics.com
*/
#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
}
void loop() {
while (HC12.available()) { // If HC-12 has data
Serial.write(HC12.read()); // Send the data to Serial monitor
}
while (Serial.available()) { // If Serial monitor has data
HC12.write(Serial.read()); // Send that data to HC-12
}
}
This didnt work, so I then tried to test if they even worked at all with the AT commands, but this didn't give any response.
Is there any way to test them so I can know for sure if they are broken or if it is just the method and code I've been using?
If you know a code and maybe something I should do that should always work on a hc12 I can test, that would be wonderful.
