Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
568 B
2
Indexable
Never
#include <SoftwareSerial.h>

SoftwareSerial mySerial(D3, D4);  // RX, TX pins on NodeMCU

void setup() {
  Serial.begin(9600);  // Serial monitor for debugging
  mySerial.begin(9600);  // SoftwareSerial for communication with Arduino
}

void loop() {
  if (mySerial.available()) {
    String data = mySerial.readString();
    Serial.print("Received from Arduino: ");
    Serial.println(data);
  }

  if (Serial.available()) {
    String data = Serial.readString();
    mySerial.print("Received from NodeMCU: ");
    mySerial.println(data);
  }
}