# Unable to receive Downlink Message

**URL:** <https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608>\
**Category:** Application Development\
**Created:** [December 3, 2021, 4:36am UTC](https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608 "2021-12-03T04:36:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GideonTay](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/gideontay/32/35697_2.png) [@GideonTay](https://www.thethingsnetwork.org/forum/u/GideonTay)\
**Post date:** [December 3, 2021, 4:36am UTC](https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608/1 "2021-12-03T04:36:35Z")

</div>

I am a beginner in doing LoRa projects and using TTN and would really appreciate any help I can get.

I am trying to connect my device to TTN. Despite various attempts to, I am still failing. I am using an Arduino MKR WAN 1300 board together with a DHT11 Temperature & Humidity Sensor connecting to a public gateway. At this point, I am able to connect to the gateway but I get stuck at this point where nothing happens beyond this.  
 ![Snip1](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/0/5/058cc6c230c7f46d4dddc70acd6dd6d4572832f7.png)  
 ![snip2](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/f/2/f2eef9d0827cb6534825827720f5ee19b8732433.png)

I have read some forums which directed me to look into the duty cycles and network limitations but those are parameters that I am unable to modify or even look at. Thank you in advance for any help.

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [December 3, 2021, 5:17am UTC](https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608/2 "2021-12-03T05:17:56Z")

</div>

Your problem doesn’t seem to have anything to do with downlink messages.

Rather, it looks like the firmware’s duty cycle accounting is blocking transmission. The possibility of a downlink would exist only after the uplink is sent, and it appears no uplinks are being sent after the join/accept cycle.

---

<div class="post-metadata">

**Author:** ![GideonTay](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/gideontay/32/35697_2.png) [@GideonTay](https://www.thethingsnetwork.org/forum/u/GideonTay)\
**Post date:** [December 4, 2021, 2:40am UTC](https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608/3 "2021-12-04T02:40:36Z")

</div>

Oh I see. I have reached this part many times before but it doesnt allow me to progress beyond this. Below is the code I am using.

```auto
#include <MKRWAN.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht (DHTPIN,DHTTYPE);

LoRaModem modem;

//#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
String appEui = "0000000000000000";
String appKey = " ****";

void setup()
{
  Serial.begin(9600);
  while(!Serial);
  dht.begin();

  pinMode(LED_BUILTIN, OUTPUT); //check if board is receiving
  for (int i=1; i<=5; i++) {           
    digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000); // wait for a second
    digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
    delay(1000);
    // wait for a second
    Serial.println(5-i);
  }
  
  // change this to your regional band (eg. US915, AS923, ...)
  if (!modem.begin(AU915)) {
    Serial.println("Failed to start module");
    while (1) {}
  };
  delay(5000);
  Serial.print("Your module version is: ");
  Serial.println(modem.version());
  Serial.print("Your device EUI is: ");
  Serial.println(modem.deviceEUI());
  modem.sendMask("ff000000f000ffff00020000");
  Serial.println(modem.getChannelMask());
  modem.setADR(true);
  join();

  modem.minPollInterval(30);
}

void join(){
  Serial.println("Trying to join TTN ...");
  int connected = modem.joinOTAA(appEui, appKey);
  if (!connected) {
    Serial.println("Something went wrong; are you indoor? Move near a window and retry");
    join();
  }
  else
    Serial.println("Successfully joined"); // Set poll interval to 60 secs.
    modem.minPollInterval(60);
  // NOTE: independently by this setting the modem will
  // not allow to send more than one message every 2 minutes,
  // this is enforced by firmware and can not be changed.
}

void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h)||isnan(t)||isnan(f)){
  Serial.println(F("Fail to read sensor"));
float hif = dht.computeHeatIndex(f,h);
float hic = dht.computeHeatIndex(t,h,false);
  return;
}
int err;
modem.beginPacket();
    err = modem.endPacket(true);
    modem.write(t);
    Serial.println("Packet Sent.Sending Temperature");
    if (err > 0) {
      Serial.println("Message sent correctly!");
// Serial.print(F(" Humidity: "));
// Serial.print(h);
      Serial.print(F("% Temperature: "));
      Serial.print(t);
// Serial.print(F("Celcius "));
// Serial.print(f);
// Serial.print(F(" Heat Index: "));
// Serial.print(hic);
// Serial.print(F("Celcius "));
// Serial.print(hif);
// Serial.println(F("Farenheit "));
    } else {
      Serial.println("Error sending message :(");
      Serial.println("(you may send a limited amount of messages per minute, depending on the signal strength");
      Serial.println("it may vary from 1 message every couple of seconds to 1 message every minute)");
    }
    delay(1000);
    if (!modem.available()) {
      Serial.println("No downlink message received at this time.");
    }
    else {
      String rcv;
      rcv.reserve(64);
      while (modem.available()) {
        rcv += (char)modem.read();
      }
      Serial.print("Received: " + rcv + " - ");
      for (unsigned int i = 0; i < rcv.length(); i++) {
        Serial.print(rcv[i] >> 4, HEX);
        Serial.print(rcv[i] & 0xF, HEX);
        Serial.print(" ");
      }
      Serial.println();
    }
    Serial.println("waiting 60 seconds");
    delay(60000); 
}

```

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [December 4, 2021, 11:26am UTC](https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608/4 "2021-12-04T11:26:38Z")

</div>

> [@GideonTay](#):
>
> ```auto
> modem.beginPacket();
> err = modem.endPacket(true);
> modem.write(t);
> 
> ```

You’ve got these in the wrong order

---

<div class="post-metadata">

**Author:** ![system](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/6/2/6250ea44fd2b0d6259489e1a92748df681e1f970.png) [@system](https://www.thethingsnetwork.org/forum/u/system)\
**Post date:** [December 6, 2021, 9:46am UTC](https://www.thethingsnetwork.org/forum/t/unable-to-receive-downlink-message/53608/5 "2021-12-06T09:46:04Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
