# Downlink not working: Dragino LG01 Gateway + TTGO LoRa V1 with LMIC

**URL:** <https://www.thethingsnetwork.org/forum/t/downlink-not-working-dragino-lg01-gateway-ttgo-lora-v1-with-lmic/47137>\
**Category:** LMIC\
**Created:** [April 26, 2021, 8:01pm UTC](https://www.thethingsnetwork.org/forum/t/downlink-not-working-dragino-lg01-gateway-ttgo-lora-v1-with-lmic/47137 "2021-04-26T20:01:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianoMoviles](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/marianomoviles/32/35697_2.png) [@marianoMoviles](https://www.thethingsnetwork.org/forum/u/marianoMoviles)\
**Post date:** [April 26, 2021, 8:01pm UTC](https://www.thethingsnetwork.org/forum/t/downlink-not-working-dragino-lg01-gateway-ttgo-lora-v1-with-lmic/47137/1 "2021-04-26T20:01:41Z")

</div>

Hi! I wanted to tell you about a problem I am having with my LoRa network. The network is made up of a Dragino LG01 gateway and a TTGO LoRa v1 module with the LMIC library.

Everything about UPLINK is working fine. Upload the data with SF8 BW125 on the 904.6MHz frequency. The problem is in the DOWNLINK that I can’t make it work and I don’t know where else to check. According to TTN, it sends the data through SF12 BW500 and in the frequency of 923.3MHz, but I have this configured in the gateway (capture attached) and I think I am correct in the module but it does not work when I send a data with the console’s downlink by TTN. On the gateway I use the " simple\_pkt\_forwarder\_v004".

Any ideas? I checked the LMIC.dn2Freq parameter and it is correctly at 923300000.

I attach other photos of the configuration and the implemented code.  
Thanks!!

 ![Captura de pantalla 2021-04-26 a las 16.55.20 p. m.](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/d/2/d2b1c8fd34568581ff9bc4381712183cc54cdcd7.png) ![Captura de pantalla 2021-04-26 a las 16.Captura de pantalla 2021-04-26 a las 16.55.20 p. m.|735x1000 Captura de pantalla 2021-04-26 a las 16.Captura de pantalla 2021-04-26 a las 16.55.20 p. m.|735x1000 Captura de pantalla 2021-04-26 a las 16.57.02 p. m.|999x444 test_ttgo.pdf|attachment (28.2 KB) 57.02 p. m.|999x444 57.02 p. m.](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/7/a/7a1db70ef53998721e4e31ec9507803b1e21ff5c.png)

This is the implemented code:

#include \<lmic.h\>  
#include \<hal/hal.h\>  
#include \<SPI.h\>

//Libreria usada para el DHT22  
#include \<SimpleDHT.h\>  
// DHT digital pin  
#define DHTPIN 25  
SimpleDHT22 dht22;

#ifdef COMPILE\_REGRESSION\_TEST

# define FILLMEIN 0

#else

# warning “You must replace the values marked FILLMEIN with real values from the TTN control panel!”

# define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN)

#endif

static const PROGMEM u1\_t NWKSKEY[16] = { /_This is private_/ };  
// LoRaWAN AppSKey, application session key  
static const u1\_t PROGMEM APPSKEY[16] = { /_This is private_/ };  
//Device Address  
#ifndef COMPILE\_REGRESSION\_TEST  
static const u4\_t DEVADDR = 0x/_This is private_/ ;  
#else  
static const u4\_t DEVADDR = 0;  
#endif

// payload to send to TTN gateway  
static uint8\_t payload[5];  
static osjob\_t sendjob;

// Schedule TX every this many seconds (might become longer due to duty  
// cycle limitations).  
const unsigned TX\_INTERVAL = 60;

// These callbacks are only used in over-the-air activation, so they are  
// left empty here (we cannot leave them out completely unless  
// DISABLE\_JOIN is set in arduino-lmic/project\_config/lmic\_project\_config.h,  
// otherwise the linker will complain).  
void os\_getArtEui (u1\_t\* buf) { }  
void os\_getDevEui (u1\_t\* buf) { }  
void os\_getDevKey (u1\_t\* buf) { }

//Pin mapping  
//For TTGO LoRa32 V1 use:  
const lmic\_pinmap lmic\_pins = {  
.nss = 18,  
.rxtx = LMIC\_UNUSED\_PIN,  
.rst = LMIC\_UNUSED\_PIN,  
//If DIO2 is not connected use:  
.dio = {/_dio0_/ 26, /_dio1_/ 33, /_dio2_/ LMIC\_UNUSED\_PIN}  
//If DIO2 is connected use:  
//.dio = {/_dio0_/ 26, /_dio1_/ 33, /_dio2_/ 32}  
};

void onEvent (ev\_t ev) {  
Serial.print(os\_getTime());  
Serial.print(": ");  
switch(ev) {  
case EV\_SCAN\_TIMEOUT:  
Serial.println(F(“EV\_SCAN\_TIMEOUT”));  
break;  
case EV\_BEACON\_FOUND:  
Serial.println(F(“EV\_BEACON\_FOUND”));  
break;  
case EV\_BEACON\_MISSED:  
Serial.println(F(“EV\_BEACON\_MISSED”));  
break;  
case EV\_BEACON\_TRACKED:  
Serial.println(F(“EV\_BEACON\_TRACKED”));  
break;  
case EV\_JOINING:  
Serial.println(F(“EV\_JOINING”));  
break;  
case EV\_JOINED:  
Serial.println(F(“EV\_JOINED”));  
break;  
/\*  
|| This event is defined but not used in the code. No  
|| point in wasting codespace on it.  
||  
|| case EV\_RFU1:  
|| Serial.println(F(“EV\_RFU1”));  
|| break;  
_/  
case EV\_JOIN\_FAILED:  
Serial.println(F(“EV\_JOIN\_FAILED”));  
break;  
case EV\_REJOIN\_FAILED:  
Serial.println(F(“EV\_REJOIN\_FAILED”));  
break;  
case EV\_TXCOMPLETE:  
Serial.println(F(“EV\_TXCOMPLETE (includes waiting for RX windows)”));  
if (LMIC.txrxFlags & TXRX\_ACK)  
Serial.println(F(“Received ack”));  
if (LMIC.dataLen) {  
Serial.println(F(“Received “));  
Serial.println(LMIC.dataLen);  
Serial.println(F(” bytes of payload”));  
}  
// Schedule next transmission  
os\_setTimedCallback(&sendjob, os\_getTime()+sec2osticks(TX\_INTERVAL), do\_send);  
break;  
case EV\_LOST\_TSYNC:  
Serial.println(F(“EV\_LOST\_TSYNC”));  
break;  
case EV\_RESET:  
Serial.println(F(“EV\_RESET”));  
break;  
case EV\_RXCOMPLETE:  
// data received in ping slot  
Serial.println(F(“EV\_RXCOMPLETE”));  
break;  
case EV\_LINK\_DEAD:  
Serial.println(F(“EV\_LINK\_DEAD”));  
break;  
case EV\_LINK\_ALIVE:  
Serial.println(F(“EV\_LINK\_ALIVE”));  
break;  
/_  
|| This event is defined but not used in the code. No  
|| point in wasting codespace on it.  
||  
|| case EV\_SCAN\_FOUND:  
|| Serial.println(F(“EV\_SCAN\_FOUND”));  
|| break;  
_/  
case EV\_TXSTART:  
Serial.println(F(“EV\_TXSTART”));  
break;  
case EV\_TXCANCELED:  
Serial.println(F(“EV\_TXCANCELED”));  
break;  
case EV\_RXSTART:  
/_ do not print anything – it wrecks timing \*/  
Serial.println(F(“EV\_RXSTART”));  
break;  
case EV\_JOIN\_TXCOMPLETE:  
Serial.println(F(“EV\_JOIN\_TXCOMPLETE: no JoinAccept”));  
break;  
default:  
Serial.print(F("Unknown event: "));  
Serial.println((unsigned) ev);  
break;  
}  
}

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 {  
float temperatura = 58;  
float humedad = 45;  
//Lectura de la temperatura y humedad del DHT22  
[//dht22.read2](https://dht22.read2)(25, &temperatura, &humedad, NULL);  
int centTemperatura=temperatura_100.0;  
int centHumedad=humedad_100.0;

```
    payload[0] =(byte)(centTemperatura/100);
    payload[1] = (byte)(centTemperatura%100);
    payload[2] = (byte)(centHumedad/100);
    payload[3] = (byte)(centHumedad%100);

    // prepare upstream data transmission at the next possible time.
    // transmit on port 1 (the first parameter); you can use any value from 1 to 223 (others are reserved).
    // don't request an ack (the last parameter, if not zero, requests an ack from the network).
    // Remember, acks consume a lot of network resources; don't ask for an ack unless you really need it.
    LMIC_setTxData2(1, payload, sizeof(payload)-1, 0);
    Serial.println(F("Packet queued"));
    
    //For test     
    Serial.print(F("LMIC.dndr = "));
    Serial.println(LMIC.dndr); // Datarate TX
    Serial.print(F("LMIC.freq = "));
    Serial.println(LMIC.freq);

    Serial.print(F("LMIC.dn2Freq = "));
    Serial.println(LMIC.dn2Freq);

    Serial.print(F("LMIC.dn2Dr = "));
    Serial.println(LMIC.dn2Dr);

```

}  
// Next TX is scheduled after TX\_COMPLETE event.

}

void setup() {  
delay(1000);  
while (!Serial);  
Serial.begin(115200);  
delay(100);  
Serial.println(F(“Starting”));

```
// LMIC init
os_init();
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();

// Set static session parameters. Instead of dynamically establishing a session
// by joining the network, precomputed session parameters are be provided.
// On AVR, these values are stored in flash and only copied to RAM
// once. Copy them to a temporary buffer here, LMIC_setSession will
// copy them into a buffer of its own again.
uint8_t appskey[sizeof(APPSKEY)];
uint8_t nwkskey[sizeof(NWKSKEY)];
memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
LMIC_setSession (0x13, DEVADDR, nwkskey, appskey);

// Let LMIC offset for +/- 1% clock error
LMIC_setClockError (MAX_CLOCK_ERROR * 10/100);

// TTN uses SF9 for its RX2 window.
LMIC.dn2Dr = 8;

for (int c = 0; c < 72; c++){
  LMIC_disableChannel(c);
}

LMIC_enableChannel(65); //Gateway RX-frequency (904.6MHz)

// Disable link check validation
LMIC_setLinkCheckMode(0);

// Set data rate and transmit power for uplink
LMIC_setDrTxpow(DR_SF8,14);

// Start job
do_send(&sendjob);

```

}

void loop() {  
os\_runloop\_once();  
}

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [April 26, 2021, 8:14pm UTC](https://www.thethingsnetwork.org/forum/t/downlink-not-working-dragino-lg01-gateway-ttgo-lora-v1-with-lmic/47137/2 "2021-04-26T20:14:44Z")

</div>

1. Disconnect your LG01 Single Channel Packet Forwarder from the TTN it is not supported and is disruptive to other users.
2. Use Forum search(\*) to understand why we do not support these LoRa (note _NOT_ LoRaWAN) devices
3. Treat yourself to a LoRaWAN Gateway (Dragino also provide proper GW’s)

(\*) Terms like LG01, LG02, SCPF, DCPF, single/dual channel packet forwarder etc.
