Skip to content

Instantly share code, notes, and snippets.

@ariffinzulkifli
Last active May 10, 2020 11:42
Show Gist options
  • Save ariffinzulkifli/fd77b92d28b2ead38f20a033a8bde72d to your computer and use it in GitHub Desktop.
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
#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