Last active
May 10, 2020 11:42
-
-
Save ariffinzulkifli/fd77b92d28b2ead38f20a033a8bde72d to your computer and use it in GitHub Desktop.
Arduino sketch for Arduino NANO to send data to NodeMCU 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> | |
#include <SimpleDHT.h> | |
SoftwareSerial softSerial(2, 3); // (RX, TX) | |
SimpleDHT11 dht11(5); | |
void setup() { | |
softSerial.begin(9600); | |
} | |
void loop() { | |
byte temperature = 0; | |
byte humidity = 0; | |
int err = SimpleDHTErrSuccess; | |
if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { | |
return; | |
} | |
String data = String(temperature) + "," + String(humidity); | |
softSerial.println(data); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment