Arduino Uno R4 Wifi Serial1 HC-12 Radio AT_Commander

I had a hell of a time tracking down this info so I figured I'd just post up a simple solution to help anybody having similar issues in the future.

The Arduino Uno R4 is a hot mess of poorly documented variations from a standard Uno board that n00bs like me would never know to watch out for.
One of those differences is that the microcontroller chip uses Serial to talk to the programming computer via USB, but then uses Serial1 on the Rx/Tx pins (Digital 0 and Digital 1, respectively) to talk to other serial devices.

This example is a modified version of the HC-12 radio tutorial found here: https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-12-long-range-wireless-communication-module/

/*
Serial = Arduino to USB comms
Serial1 = Arduino to HC12

HC12 VCC -> +5v
HC12 Ground -> Ground
HC12 TX -> Arduino pin 0(RX)
HC12 RX -> Arduino pin 1(TX)
HC12 Set -> Ground    *Note that this is only used to program the HC-12, if needed.
Once you're done setting the channel/power of the HC-12, disconnect the Set pin
*/

void setup() {
  Serial.begin(9600);             // Serial port to computer
  Serial1.begin(9600);               // Serial port to HC12
}

void loop() {
  while (Serial1.available()) {        // If HC-12 has received data
    Serial.write(Serial1.read());      // Send the data to Serial monitor
  }
  while (Serial.available()) {      // If Serial monitor has data
    Serial1.write(Serial.read());      // Send that data to HC-12 to be transmitted
  }
}

Arduino Uno R4 Wifi Serial Serial 1 not connecting serial doesnt work HC-12 AT_Commander

How hard did you look ?

See https://docs.arduino.cc/tutorials/uno-r4-wifi/cheat-sheet/

2 Likes

Mr UKHeliBob, I can't tell you how much I appreciate all your expertise, patience, and tutelage on this forum and others. I have learned so much from you by reading your articles, tutorials, and comments.
So I mean no disrespect when I say, dude, I looked so friggin much. I've read so many threads and got lost in rabbit holes and weeds building out my various projects. I probably read the page you linked to a couple times up and down, but I could not comprehend it all. Because it was not spelled out in crayon in exactly the context I was looking for, I didn't know what I was looking at.

My post here adds another hit on a search return, adds to the chatter, but hopefully someday the right lost soul will pick the signal out of the noise and find what they need to get their HC-12 working with their R4 when its 2am and they really should go to bed and they dont exactly know their UARTs from their SPIs yet.

Again, thank you for your dedication to this platform.

Try doing a search for this
"uno r4 wifi serial ports"

This is the Google AI generated response that I got back

The Arduino UNO R4 WiFi has two hardware serial ports: one accessible through the USB-C port (Serial) and another accessible via the RX/TX pins (Serial1).

It then goes on to provide a more detailed breakdown of how to use the two serial ports

  • Serial:

This is the default serial port used for communication with your computer, uploading code, and using the Serial Monitor in the Arduino IDE.

  • Serial1:

This port is connected to pins 0 and 1 and is used for communicating with other devices, like a GPS module or a Bluetooth module.

To use Serial1 in your code, you'll need to refer to it specifically, for example, as Serial1.begin(9600)

1 Like

Good suggestion. I'm not in the habit of using AI since my first attempt resulted in a terrible hallucination of an answer.
What I would need to figure out with the R4 is how to substitute the WiFiS3 library for the regular wifi /HTML etc libraries used in so many tutorials. It's unfortunately not a clean drop-in replacement and leads to lots of conflicts. I'll just stay away from the R4 for future projects since I don't know enough to rewrite the tutorials I'm following, and programming isn't where I want to spend a lot of time when building my larger physical projects.

I am not so much using AI as having it forced on me but it can be useful as a starting point