Dht11 cannot read temp and humidity on Lora shield gps

Hi,
Im new in this Lora Technology. Im sorry If my question was basic. so Im from Indonesia which is have a bit Lora Technology expertise.

MY PROBLEM
I build a single channel gateway with rpi + Lora GPS/HAT as a gateway and arduino+Lora GPS Shield as a node. trying to transmitting the temperature & humidity using dht11. my code on this github Lora dht11. and I take the example on this web wiki dragino
and will show the data humidity and temperature to cayenne mydevice.
my problem is, the sensor dht11 cannot appear on the serial monitor(try on first monitoring), and in the ttn. it always nan or 0,00%.

My Question

  • is it related with the code hex in static uint8_t mydata[22] ?
    `

static uint8_t mydata[22] = {0x06,0x67,0x00,0x00,0x02,0x68,0x00,0x03,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x65,0x00,0x00};

`
because I take that hex from this ttn_mydevice.

  • is it any wrong code with the dht11 library on it ?
  • if I add sensor GY-906 Infrared Temperatur Sensor MLX90614 ESF for contacless temperature sensor. what should I add for the code? static uint8_t mydata[] is probably add again with the differen code hex ?

Background
I build a monitoring and detection forest fires using Lora Technology. so Im using temperature sensor. with 2 nodes. for now I still trying to read sensor dht11 with 1 node first. if it can read and monitoring, I will trying to dual channel gateway. :slight_smile:

please help on my project…

Back to basics, ignore the LoRa stuff for now.

Can you confirm that, with a simple program, and no LoRa device code involved, you can read the DHT11 sensor and print the results to the serial monitor ?

Hi @LoRaTracker.
Yes I already tried to do that. Everything normal. I think its wrong with the pin dht11 which it has a digital pin but the example to analog pin. When I tried with a simple program to run the sensor using analog pin, it can read to the serial monitor. And when I back to the code using Lora, it can’t.

Your code will only even attempt to read from the DHT11 if do_send() is called when OP_TXRXPEND is unset. In practice, that flag can often get stuck on in LMiC for various reasons.

What sort of output are you seeing from the sketch?

Likely you should add additional logging to see when do_send() is called at all, see which path it takes, see if your dhtTem() function is called at all, and if it exists with a success

Attempting to read from a GPS with software serial could also be causing problems, though it looks like maybe you aren’t actually calling that in the current version.

Hi @cslorabox,

here is the output.

test%20arduino .

you seem to have commented out all calls to dht.begin()

1 Like

in where I add that code?
after

#define

or in the

void setup() {

?

Wherever you would usually put it if you were not using LoRaWAN, setup() isn’t a bad guess

I’ve run in to this issue. Did you ever get it solved?

I believe the issue is caused by something relating to the following code, though I can’t be sure as I’m very new to the Arduino. dhtTem is getting called, presumably if both of LMIC.opmode and OP_TXRXPEND are set. I’m not quite sure how to unset OP_TXRXPEND, what further issues that might cause, or how to move the function around to avoid cases where OP_TXRXPEND is set.

void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println(F("OP_TXRXPEND, not sending"));
    } else {
        // Prepare upstream data transmission at the next possible time.
        dhtTem();
        //LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
        Serial.println(F("Packet queued"));
        Serial.print(F("Sending packet on frequency: "));
        Serial.println(LMIC.freq);
    }
    // Next TX is scheduled after TX_COMPLETE event.
}

You shouldn’t. Unless you’re referring to:

Just to be clear: bugs aside, it’s set when another transmission is already scheduled, so you should not run into that condition unless you’re transmitting too much. So: just adhere to the regulations and other limitations and you should not run into that branch of the code at all.

(Aside: note that the LMIC_setTxData2 is commented out in your sample code. So, that code is not sending anything. Also, it’s very unlikely you want the -1 in sizeof(mydata)-1.)