Forked from ariffinzulkifli/NodeMCU_receive_from_Arduino_NANO.ino
Created
July 11, 2021 12:24
-
-
Save VincentK16/55dad0c2c739f26bd0729f604bac76b7 to your computer and use it in GitHub Desktop.
Arduino sketch for NodeMCU to receive incoming data from Arduino NANO using SoftwareSerial library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial softSerial(D2, D3); // (RX, TX) | |
SimpleDHT11 dht11(5); | |
void setup() { | |
softSerial.begin(9600); | |
} | |
void loop() { | |
if(softSerial.available()){ | |
String data = softSerial.readStringUntil('\n'); // contoh terima 23,56 | |
String temperature = data.substring(0, data.indexOf(",")); | |
String humidity = data.substring(data.indexOf(",") + 1); | |
softSerial.flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment