I successfully tested all my hc12s on my win11 desktop computer, latest Arduino IDE, 2.3.5., using a USB-TTL converter and Termite. When I try to do the same with an UNO attached and using software serial to get an OK to AT prompt, I get question marks, like its a baud problem. When I attach the SAME circuit with all cables and jumper wires to a laptop computer running IDE 2.1.0 the HC12 responds to AT with an "OK". I've used these HC12 in 3-4 robots with no issues, but now I can't talk to them, at least not with the 2.3.5 IDE. I thought maybe it was USB2 (laptop) Vs USB3 (desktop) but I tried the USB2 on desktop with same results.
Any ideas? I'm grasping at straws.
#include <SoftwareSerial.h>
SoftwareSerial HC12(10,11); //TX of HC12, RX of HC12
void setup() {
Serial.begin(9600); // Serial port to computer
HC12.begin(9600); // Serial port to HC12
//FF pinMode (7,OUTPUT);// Select of HC12 for testing AT commands
//digitalWrite(7,LOW);//LOW to select
//digitalWrite(7,HIGH);// High to run normal
}
void loop() {
while (HC12.available()) { // If HC-12 has data
Serial.write(Serial.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
}
}type or paste code here
The only difference between not working on desktop to working with laptop is that the former has 2.3.5 IDE, the latter, 2.1.0 IDE. I have tried two different UNOs with same setup and the same results.
It is the same UNO, same wire connections, same HC12.
The tools are different because of the different versions of IDE, but in either case, I select the UNO R3, 9600 baud on each.
I did NOT change IDE on desktop to 2.1.0 (not sure how to do that other than re-installing)
And I didn't change the laptop to 2.3.5 because it is the one that is WORKING. I could change the desktop to 2.1.0, although I really like the GUI of 2.3.5. I'll look into it and see if I can downgrade.
I found version 2.1.0 but when I tried to install it, it said it couldn't find the server. Another popup said the "older version could not be removed". In this case the older version is my 2.3.5 which I didn't want to remove...it has so many board and library updates. (I use about 10 different boards).
All the HC12 I tested (with USB-TTL board) were set at DEFAULT (9600 baud, level 3, etc).
When you did that, did you upload the sketch to the UNO board again? Or is the board still running the program that you uploaded while the board was connected to the desktop.
I ask this because if you uploaded the sketch again then we need to consider differences in the sketch dependencies environments (e.g., having different versions of the "Arduino AVR Boards" platform installed) of each computer as a factor. Differences in the installed dependencies can result in different behaviors from the program compiled from an identical sketch code.
Termite displayed proper data at the git-go. The question marks (inside a "diamond" icon) were only on the Arduino monitor.
And yes, I did upload the sketch every time when I switched from one to the other. Of note is that when I went from desktop (2.3.5) to laptop (2.1.0) the HC12 did not immediately work, forcing me to download the UNO once again, then it was okay. But doing the other way, moving USB to the desktop and downloading the UNO there did not work. In other words desktop 2.3.5 never works, the USB-TTL always works and the laptop always works.
I tried 2.3.6 on another computer and got the question marks. So I took the plunge and upgraded my 2.1.0 laptop that worked, to 2.3.6. It works!! So I eliminated V2.3.6 as the problem. The two desktops and the laptop used USB3. I'm going to scope those ports to see if there's a difference: frequency, voltage, noise. (I had a 220uFd cap across the voltage input to the hc12 but it didn't make a difference one way or the other).