Last active
July 11, 2021 12:24
-
-
Save ariffinzulkifli/0d8be195de02e8cbc23ee51c1337c903 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