HC12 Transceiver program works with Nano but not Nano Every

The following code worked perfectly between two Arduino Nanos (both running the same code), but after changing one for a Nano Every it no longer functions properly. The Nano every can still transmit to the standard nano but will not receive anything. I'm not sure what is wrong since the Nano Every is described as needing no changes to existing Nano code.

#include <SoftwareSerial.h>
SoftwareSerial HC12(2,3);

String stringData = "";
bool transmission = false;

void setup() {
Serial.begin(9600);
HC12.begin(9600);
attachInterrupt(digitalPinToInterrupt(2), recievedTransmission, CHANGE);
HC12.print("Initialization Complete");
HC12.print("\n");
}

void loop() {
while (Serial.available()) {
HC12.write(Serial.read());
}
checkTransmission();
delay(100);
}

void recievedTransmission() { //Runs when any transmission is received
while (HC12.available()) {
stringData += char(HC12.read());
}
transmission = true;
}

void checkTransmission() { //Checks received transmission and print to serial
if (transmission == true) {
Serial.println(stringData);
stringData = "";
transmission = false;
}
}

For the Nano Every, instead of software serial, you should use Serial1 on the pins labeled RX and TX on the board. Unlike the classic nano, these pins are independent of the usb serial.
https://forum.arduino.cc/t/arduino-every-second-hardware-serial-port/600373/3

The reason I used digital pins 2 and 3 on the nano was to use an attachInterrupt (this section of code is part of a larger piece, and transmissions are missed without using interrupts). Can interrupts be used on the RX and TX pins?

You will need to explain more.
Hardware serial uses interrupts, and the RX buffer will fill regardless of what else is going on in the program. Serial1.available() should be as reliable as checkTransmision() reading an external interrupt flag set by the Rx pin.

The Nano Every does support interrupts on every digital pin.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.