Hi,
I have a setup with two LGT8F328P-LQFP32 (Arduino Nano clones) connected to an HC-12 radio module (HC12 RX to pin 11 and HC12 TX to pin 10).
My goal is to be able to send simple commands from one to another controller, but for some reason the messages seems "corrupted" when receiving by the other LGT8F328P.
For example when I'm sending "Hello" on one side, I receive "HY��" on the other side.
I've done a lot of research and troubleshooting, here is what I tried so far:
- Changing the baud rates -> No success
- Changing for other pins -> No success
- Changing for new HC12's -> No success
- Changing for new LGT8F328P-LQFP32 -> No success
- Trying SoftwareSerial library alternatives -> No success
My last test was to change the two LGT8F328P-LQFP32 for real arduino nano's (ATMega328P) and everything is working fine.
I'm using the correct board package (I think) from here: Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
My guess is that the clones I'm trying to use don't work properly with SoftwareSerial, or the differences in clock frenquency, timers (and other black magic like that for me) with the original arduino are causing the Serial monitor to interpret the messages wrongly.
Do you have any idea of how I could solve my problem?
Here are the RX and TX code (same for the two as I'm in the testing phase):
#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
//Simply to inform that the module is ready
delay(1000);
Serial.println("Ready");
}
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
}
}