Changes for page LG01v2 -- LoRa Gateway User Manual
Last modified by Kilight Cao on 2024/10/12 08:58
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 3 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -442,7 +442,7 @@ 442 442 == **7.1 How does LG01-V2 communicate with Lora shield (LoRa.h)** == 443 443 444 444 445 -This example describes how to use LG01-V2, LoRa Shield to set up a LoRa network 445 +This example describes how to use LG01-V2, LoRa Shield to set up a LoRa network, 446 446 447 447 [[image:image-20221103152238-8.png||height="251" width="654"]] 448 448 ... ... @@ -484,6 +484,44 @@ 484 484 [[image:image-20221101162527-4.png]] 485 485 486 486 487 +== **7.2 How does LG01-V2 communicate with Heltec LoRa Node** == 488 + 489 + 490 +This example describes how to use LG01-V2 and Heltec LoRa Node to set up a LoRa network, 491 + 492 +[[image:image-20221112161111-2.png||height="258" width="692"]] 493 + 494 +(% style="color:red" %)**Prerequisites: The configurations of LG01-V2 and Lora shield must match** 495 + 496 +**LG01-V2 configuration:** 497 + 498 +(% class="box infomessage" %) 499 +((( 500 +AT+FRE=868.100,868.100 ~-~--> TX and RX frequency set: 868100000 501 +AT+BW=0,0 ~-~--> TX and RX Bandwidth set: 125kHz 502 +AT+SF=12,12 ~-~--> TX and RX Spreading Factor set: SF12 503 +AT+POWER=14 ~-~--> TX Power Range 504 +AT+CRC=1,1 ~-~--> TX and RX CRC Type 505 +AT+HEADER=0,0 ~-~--> TX and RX Header Type 506 +AT+CR=1,1 ~-~--> TX and RX Coding Rate 507 +AT+IQ=0,0 ~-~--> TX and RX InvertIQ 508 +AT+PREAMBLE=8,8 ~-~--> TX and RX Preamble Length set: 8 509 +AT+SYNCWORD=0 ~-~--> Syncword**(0: private,1: public), **the corresponding Lora shield syncword is 0x12 510 +AT+RXMOD=65535,0 ~-~--> Rx Timeout and Reply mode,RX window always open 511 +AT+RXDAFORM=1 ~-~--> RX data format**(0: Hex ,1: String)** 512 +))) 513 + 514 +After we upload the sketch to Heltec LoRa Node, we can see below output from Arduino. 515 + 516 +Lora Shield example: [[attach:LoRa_send_trial.ino||target="_blank"]] 517 + 518 +[[image:image-20221112162733-3.png||height="524" width="927"]] 519 + 520 + 521 +And we can see the logread of gateway as below, means the packet arrive gateway: 522 + 523 +[[image:image-20221112163119-4.png||height="808" width="560"]] 524 + 487 487 = (% style="color:inherit; font-family:inherit; font-size:29px" %)**8. Supports**(%%) = 488 488 489 489
- LoRa_send_trial.ino
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Kilight - Size
-
... ... @@ -1,0 +1,1 @@ 1 +3.4 KB - Content
-
... ... @@ -1,0 +1,124 @@ 1 +#include "LoRaWan_APP.h" 2 +#include "Arduino.h" 3 + 4 + 5 +#define RF_FREQUENCY 868100000 // Hz 6 + 7 +#define TX_OUTPUT_POWER 5 // dBm 8 + 9 +#define LORA_BANDWIDTH 0 // [0: 125 kHz, 10 + // 1: 250 kHz, 11 + // 2: 500 kHz, 12 + // 3: Reserved] 13 +#define LORA_SPREADING_FACTOR 12 // [SF7..SF12] 14 +#define LORA_CODINGRATE 1 // [1: 4/5, 15 + // 2: 4/6, 16 + // 3: 4/7, 17 + // 4: 4/8] 18 +#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx 19 +#define LORA_SYMBOL_TIMEOUT 0 // Symbols 20 +#define LORA_FIX_LENGTH_PAYLOAD_ON false 21 +#define LORA_IQ_INVERSION_ON false 22 + 23 + 24 +#define RX_TIMEOUT_VALUE 1000 25 +#define BUFFER_SIZE 30 // Define the payload size here 26 + 27 +float tem,hum; 28 +char tem_1[8]={"\0"},hum_1[8]={"\0"}; 29 +char *node_id = "<GW01>"; //From LG01 via web Local Channel settings on MQTT.Please refer <> dataformat in here. 30 + 31 +char txpacket[BUFFER_SIZE]; 32 +char rxpacket[BUFFER_SIZE]; 33 + 34 +double txNumber; 35 + 36 +bool lora_idle=true; 37 + 38 +static RadioEvents_t RadioEvents; 39 +void OnTxDone( void ); 40 +void OnTxTimeout( void ); 41 + 42 +void dhtTem() 43 +{ 44 + tem = random(15,40); 45 + hum = random(40,80); 46 + Serial.println(F("The temperature and humidity:")); 47 + Serial.print("["); 48 + Serial.print(tem); 49 + Serial.print("℃"); 50 + Serial.print(","); 51 + Serial.print(hum); 52 + Serial.print("%"); 53 + Serial.print("]"); 54 + Serial.println(""); 55 +} 56 + 57 +void dhtWrite() 58 +{ 59 + char data[50] = "\0"; 60 + for(int i = 0; i < 50; i++) 61 + { 62 + data[i] = node_id[i]; 63 + } 64 + 65 + dtostrf(tem,0,1,tem_1); 66 + dtostrf(hum,0,1,hum_1); 67 + 68 + strcat(data,"tem_a="); 69 + strcat(data,tem_1); 70 + strcat(data,"&hum_a="); 71 + strcat(data,hum_1); 72 + strcpy((char *)txpacket,data); 73 + 74 + Serial.println((char *)txpacket); 75 +} 76 + 77 +void setup() { 78 + Serial.begin(115200); 79 + Mcu.begin(); 80 + 81 + txNumber=0; 82 + 83 + RadioEvents.TxDone = OnTxDone; 84 + RadioEvents.TxTimeout = OnTxTimeout; 85 + 86 + Radio.Init( &RadioEvents ); 87 + Radio.SetChannel( RF_FREQUENCY ); 88 + Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, 89 + LORA_SPREADING_FACTOR, LORA_CODINGRATE, 90 + LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, 91 + true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); 92 + } 93 + 94 + 95 + 96 +void loop() 97 +{ 98 + if(lora_idle == true) 99 + { 100 + delay(5000); 101 + txNumber += 0.01; 102 + Serial.println(txNumber); 103 + 104 + dhtTem(); 105 + dhtWrite(); 106 + Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out 107 + lora_idle = false; 108 + } 109 + Radio.IrqProcess( ); 110 +} 111 + 112 +void OnTxDone( void ) 113 +{ 114 + Serial.println("TX done......"); 115 + lora_idle = true; 116 +} 117 + 118 +void OnTxTimeout( void ) 119 +{ 120 + Radio.Sleep( ); 121 + Serial.println("TX Timeout......"); 122 + lora_idle = true; 123 +} 124 +
- image-20221112162733-3.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Kilight - Size
-
... ... @@ -1,0 +1,1 @@ 1 +78.7 KB - Content
- image-20221112163119-4.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Kilight - Size
-
... ... @@ -1,0 +1,1 @@ 1 +32.6 KB - Content