Changes for page LG01v2 -- LoRa Gateway User Manual
Last modified by Kilight Cao on 2024/10/12 08:58
Change comment:
Uploaded new attachment "image-20221101160705-1.png", version {1}
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 5 removed)
Details
- Page properties
-
- Content
-
... ... @@ -340,33 +340,9 @@ 340 340 = **7. FAQ** = 341 341 342 342 343 - == **7.1Howdoes LG01v2 communicate with Lora shield (LoRa.h)** ==343 +7.1 344 344 345 345 346 -(% style="color:red" %)Prerequisites: The configurations of LG01v2 and Lora shield must match 347 - 348 -**LG01v2 configuration:** 349 - 350 -[[image:image-20221101160705-1.png]] 351 - 352 - 353 -**Lora shield configuration:** 354 - 355 -Lora Shield example: [[attach:LoRa_Shield_Sketch_For_MQTT.ino||target="_blank"]] , [[attach:arduino-LoRa-master.zip||target="_blank"]] 356 - 357 -[[image:image-20221101161318-2.png]] 358 - 359 - 360 -**Test LG01v2 to receive Lora Shield data:** 361 - 362 -[[image:image-20221101161951-3.png]] 363 - 364 - 365 -**Test the LG01v2 to send data:** 366 - 367 -[[image:image-20221101162527-4.png]] 368 - 369 - 370 370 = (% style="color:inherit; font-family:inherit; font-size:29px" %)**8. Supports**(%%) = 371 371 372 372
- LoRa_Shield_Sketch_For_MQTT.ino
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Kilight - Size
-
... ... @@ -1,1 +1,0 @@ 1 -2.9 KB - Content
-
... ... @@ -1,118 +1,0 @@ 1 -#include <SPI.h> 2 -#include <LoRa.h> 3 - 4 -// This is the LoRa Node side sketch for the MQTT example: http://wiki.dragino.com/index.php?title=MQTT_Forward_Instruction#Example_to_communicate_to_a_simple_MQTT_server 5 - 6 -float tem,hum; 7 -char tem_1[8]={"\0"},hum_1[8]={"\0"}; 8 -char *node_id = "<4567>"; //From LG01 via web Local Channel settings on MQTT.Please refer <> dataformat in here. 9 -uint8_t datasend[36]; 10 -unsigned int count = 1; 11 -unsigned long new_time,old_time=0; 12 - 13 -void setup() 14 -{ 15 - Serial.begin(9600); 16 - while (!Serial); 17 - Serial.println(F("Start MQTT Example")); 18 - if (!LoRa.begin(868100000)) //868000000 is frequency 19 - { 20 - Serial.println("Starting LoRa failed!"); 21 - while (1); 22 - } 23 - // Setup Spreading Factor (6 ~ 12) 24 - LoRa.setSpreadingFactor(12); 25 - 26 - // Setup BandWidth, option: 7800,10400,15600,20800,31250,41700,62500,125000,250000,500000 27 - //Lower BandWidth for longer distance. 28 - LoRa.setSignalBandwidth(125000); 29 - 30 - // Setup Coding Rate:5(4/5),6(4/6),7(4/7),8(4/8) 31 - LoRa.setCodingRate4(5); 32 - LoRa.setSyncWord(0x12); 33 - void disableCrc(); 34 - LoRa.disableInvertIQ(); 35 - LoRa.explicitHeaderMode(); 36 - Serial.println("LoRa init succeeded."); 37 - LoRa.onReceive(onReceive); 38 - LoRa.receive(); 39 -} 40 - 41 -void dhtTem() 42 -{ 43 - tem = random(15,40); 44 - hum = random(40,80); 45 - Serial.println(F("The temperature and humidity:")); 46 - Serial.print("["); 47 - Serial.print(tem); 48 - Serial.print("℃"); 49 - Serial.print(","); 50 - Serial.print(hum); 51 - Serial.print("%"); 52 - Serial.print("]"); 53 - Serial.println(""); 54 -} 55 -void dhtWrite() 56 -{ 57 - char data[50] = "\0"; 58 - //for(int i = 0; i < 50; i++) 59 - //{ 60 - // data[i] = node_id[i]; 61 - //} 62 - 63 - dtostrf(tem,0,1,tem_1); 64 - dtostrf(hum,0,1,hum_1); 65 - 66 - // Serial.println(tem_1); 67 - strcat(data,"tem="); 68 - strcat(data,tem_1); 69 - strcat(data,"&hum="); 70 - strcat(data,hum_1); 71 - strcpy((char *)datasend,data); 72 - 73 - //Serial.println((char *)datasend); 74 - //Serial.println(sizeof datasend); 75 - 76 -} 77 - 78 - 79 -void SendData() 80 -{ 81 - LoRa.beginPacket(); 82 - LoRa.print((char *)datasend); 83 - LoRa.endPacket(); 84 - Serial.println("Packet Sent"); 85 -} 86 - 87 - 88 - 89 -void loop() 90 -{ 91 - new_time=millis(); 92 - if (new_time - old_time >= 30000 || old_time == 0) 93 - { 94 - old_time = new_time; 95 - Serial.print("########### "); 96 - Serial.print("COUNT="); 97 - Serial.print(count); 98 - Serial.println(" ###########"); 99 - count++; 100 - dhtTem(); 101 - dhtWrite(); 102 - SendData(); 103 - LoRa.receive(); 104 - } 105 -} 106 - 107 -void onReceive(int packetSize) { 108 - 109 - // received a packet 110 - Serial.print("Received packet : "); 111 - 112 - // read packet 113 - for (int i = 0; i < packetSize; i++) { 114 - Serial.print((char)LoRa.read()); 115 - } 116 - Serial.print("\n\r"); 117 -} 118 -
- arduino-LoRa-master.zip
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Kilight - Size
-
... ... @@ -1,1 +1,0 @@ 1 -28.6 KB - Content
- image-20221101161318-2.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Kilight - Size
-
... ... @@ -1,1 +1,0 @@ 1 -46.3 KB - Content
- image-20221101161951-3.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Kilight - Size
-
... ... @@ -1,1 +1,0 @@ 1 -131.0 KB - Content
- image-20221101162527-4.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Kilight - Size
-
... ... @@ -1,1 +1,0 @@ 1 -290.1 KB - Content