Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#include <dht.h>
#include <SPI.h>
#include <RH_RF95.h>
// Singleton instance of the radio driver
RH_RF95 rf95;
float frequency = 868.0;
dht DHT;
#define DHT11_PIN A0
float temperature,humidity,tem,hum;
String datastring1="";
String datastring2="";
char tem_1[8]={"\0"},hum_1[8]={"\0"};
char *node_id = "<5678>";
uint8_t datasend[36];
unsigned int count = 1;
void setup()
{
Serial.begin(9600);
Serial.println(F("Start MQTT Example"));
if (!rf95.init())
Serial.println(F("init failed"));
rf95.setFrequency(frequency);
rf95.setTxPower(13);
}
void dhtTem()
{
temperature = DHT.read11(DHT11_PIN); //Read Tmperature data
tem = DHT.temperature1.0;
humidity = DHT.read11(DHT11_PIN); //Read humidity data
hum = DHT.humidity 1.0;
Serial.println(F("The temperature and humidity:"));
Serial.print("[");
Serial.print(tem);
Serial.print("℃");
Serial.print(",");
Serial.print(hum);
Serial.print("%");
Serial.print("]");
Serial.println("");
delay(2000);
}
void dhtWrite()
{
char data[50] = "\0";
for(int i = 0; i < 50; i++)
{
data[i] = node_id[i];
}
//Serial.println((char *)datasend);
//Serial.println(sizeof datasend);
}
void SendData()
{
Serial.println(F("Sending data to LG01"));
{
// Should be a reply message for us now
if (rf95.recv(buf, &len))
{
}
else
{
Serial.println("No reply, is LoRa server running?");
}
delay(5000);
}
void loop()
{
Serial.print("########### ");
Serial.print("COUNT=");
Serial.print(count);
Serial.println(" ###########");
count++;
dhtTem();
dhtWrite();
SendData();
}