How do I send data from my gateway to node

hey i use the IC880A and RPI3 as a gateway lora an d dragino as node … si [How do I send data from my gateway to node?

https://www.thethingsnetwork.org/docs/

1 Like

I am currently working on the same thing. Sending data to a node is called a Downlink and you can do it by typing numbers in the Downlink field (console -> Application Device -> Downlink field). TTN has a nice video about this.

You can also send them directly via MQTT.

The trickiest part is handling the data on the node’s side. I am using the LMIC library on my node, and it receives data in one of the event cases.

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;

So the data will be in LMIC.frame[index], index being the number of whatever byte of received data you want to access (each hex number you send is one byte therefore in one index). Be careful though you are only allowed to send up to 10 Downlink messages a day (I don’t know if this is per device or per account so play it safe). But it should be enough for testing.

What I am personally trying to figure out is how you can Acces FPORT number and other information with LMIC.

The LMiC documentation explains:

struct lmic_t {
 u1_t frame[MAX_LEN_FRAME];
 u1_t dataLen; // 0 no data or zero length data, >0 byte count of data
 u1_t dataBeg; // 0 or start of data (dataBeg-1 is port)
 ...

For the EV_RXCOMPLETE and EV_TXCOMPLETE events, the txrxFlags field sould be evaluated and the following flags are defined:

  • TXRX_PORT: a port field is contained in the received frame

And to print the downlink data to the serial output, see Downlink to Node with LMIC.

You don’t, really.

Some computer (or human user of the web console) asks the TTN backend to send data to a node.

The backend routes it via the most appropriate gateway - probably yours, but not always necessarily, especially in the future when the network gets more built out, or if your node is no longer sitting on the lab bench next to your gateway.

While you can have the request originate on the same physical computer as the gateway software is running on, it really has nothing to do with the fact that the computer is also being gateway - the request has to go through the TTN backend infrastructure first.

Otherwise you’d have to be doing your own thing, not using TTN.

I have another question here… I’m a total beginner so excuse me if this is covered in the LIMC library…

If my node is asleep - and I try and send it some data - is there anyway to push it to the node or does it have to wait for it to connect first?

In the case of time critical instruction sent to the node… is that possible?

The downlink packets are scheduled/timed to arrive just after the uplink is sent from the node, as a total beginner it would be worth your while reading the basics > https://www.thethingsnetwork.org/docs/

(I meant that is a nice way)

This is not supported in LoRaWAN class A which is all the TTN supports.

You can only send downlinks in response to uplinks, which aren’t allowed to be all that frequent themselves.

TTN is not currently usable for applications which need to send downlink commands with a low latency.

Note that even other network schemes cannot really support low latency downlinks either, if the node must be battery powered, as even if you have a schedule of downlink opportunities, waking up the processor and radio to check for messages has a power cost.

@cslorabox Thanks for the reply. Thats good info.