Membuat komunikasi serial Arduino Uno dengan NodeMCU

NodeMCU

#include <SoftwareSerial.h>

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>



char auth[] = "masukkan token project blynk di sini";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi access point";
char pass[] = "password";

SoftwareSerial SoftSerial(D6,D5); //(Rx, Tx)

void setup()
{
  // Debug console
  Serial.begin(9600);
  SoftSerial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  // Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8080);
}


void loop()
{
  Blynk.run();

  if (SoftSerial.available() > 0) {
    String dataReceived = SoftSerial.readString();
    Blynk.virtualWrite(V1,dataReceived);
  }
}

Arduino Uno

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Testing Software Serial");
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
  delay(3000);
}

void loop() { // run over and over
  long waktu = millis();
  String waktuStr = String(waktu);
  mySerial.println(waktuStr);
  delay(2000);
}
Bahasa Indonesia