Hello everybody,
i tried to connect a DHT11 to send data on a LoRa gateway. The messages arrive correctly via LoRa but instead of the temperature and humidity value comes ‘nan’. The same message also arrives on the serial monitor. Someone could help me?
thanks!!!
#include “heltec.h”
#include “DHTesp.h”
DHTesp dht;
#define BAND 868E6
#define txPower 14
#define frequency 868E6
#define spreadingFactor 7
#define signalBandwidth 125E3
#define codingRateDenominator 5
#define preambleLength 8
#define syncWord 0x34
float tem = 0;
float hum = 0;
unsigned int counter = 0;
String rssi = “RSSI --”;
String packSize = “–”;
String packet ;
int device_id = 9413;
void setup()
{
dht.setup(25, DHTesp::DHT11);
delay(2000);
Heltec.begin(true /DisplayEnable Enable/, true /Heltec.Heltec.Heltec.LoRa Disable/, true /Serial Enable/, true /PABOOST Enable/, BAND /long BAND/);
LoRa.setFrequency(frequency);
LoRa.setSpreadingFactor(spreadingFactor);
LoRa.setSignalBandwidth(signalBandwidth);
LoRa.setCodingRate4(codingRateDenominator);
LoRa.setPreambleLength(preambleLength);
LoRa.setSyncWord(syncWord);
delay(1000);
}
void loop()
{
tem=dht.getTemperature();
hum=dht.getHumidity();
Serial.begin(115200);
Serial.println(tem);
Serial.println(hum);
LoRa.beginPacket();
LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
LoRa.print("<");
LoRa.print(device_id);
LoRa.print(">temperature:=");
LoRa.print(tem);
LoRa.print("&humidity=");
LoRa.print(hum);
LoRa.endPacket();
delay(10000);
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();*/
counter++;
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}