wikiroute

networking recipes

User Tools

Site Tools


deploying_lorawan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
deploying_lorawan [2017/04/30 11:59] samerdeploying_lorawan [2017/04/30 12:06] – [1.1. Autonomo with LoRaBee] samer
Line 16: Line 16:
     - Add the following library {{ :sodaq_rn2483_2.zip |}} to your Arduino IDE as explained in [[https://www.arduino.cc/en/guide/libraries]].     - Add the following library {{ :sodaq_rn2483_2.zip |}} to your Arduino IDE as explained in [[https://www.arduino.cc/en/guide/libraries]].
  
-Now you are ready to write a sketch for the device. Here is one example sketch {{ :test-lorawan-combined-loraserver-example.zip |}} where the autonomo is connected to three sensors: light, moisture, and temperature. Let us analyse some extracts of the code:+Now you are ready to write a sketch for the device. Here is one example sketch {{ :test-lorawan-combined-loraserver-example.zip |}} where the autonomo is connected to three sensors: light, moisture, and temperature. Let us analyse some extracts of the code.
  
 +In this part, you should put the keys for Over-The-Air Activation (OTAA) as explained in the LoRaWAN specification: 
 <code c++> <code c++>
 // USE YOUR OWN KEYS! // USE YOUR OWN KEYS!
Line 30: Line 31:
 { }; { };
 </code> </code>
 + 
 +The pins for connecting the sensors are specified in these declarations (A0 for light sensor, A2 for moisture sensor, and D0 temperature sensor):
 +<code c++>
 +int light_pin = A0;
 +int moisture_pin = A2; 
  
- a light sensor on pin A0, A2 (moisture sensor), and D0 (temperature sensor). +int temperature_pin = 0; 
-  * OTA join method +int temperature_vcc_pin = 1; 
-  * Frequency channels +int moisture_vcc_pin = 8; 
-  * Message sending+int moisture_gnd_pin = 7; 
 +</code>
  
 +The OTAA method is used for joining the network and adaptive data rate is activated:
 +<code c++>
 +LoRaBee.initOTA(loraSerial, devEUI, appEUI, appKey, true)
 +</code>
  
 +Eight different sub channels are activated with data rate ranges from 0 to 5:
 +<code c++>
 +  LoRaBee.configChFreq(0, 868100000L,0,5,1);
 +  LoRaBee.configChFreq(1, 868300000L,0,5,1); 
 +  LoRaBee.configChFreq(2, 868500000L,0,5,1);
 +  LoRaBee.configChFreq(3, 867100000L,0,5,1);
 +  LoRaBee.configChFreq(4, 867300000L,0,5,1);
 +  LoRaBee.configChFreq(5, 867500000L,0,5,1);
 +  LoRaBee.configChFreq(6, 867700000L,0,5,1);
 +  LoRaBee.configChFreq(7, 867900000L,0,5,1);
 +</code>
 +
 +Finally, the message is sent in an unconfirmed upping message:
 +<code c++>
 +LoRaBee.send(1, (uint8_t*)message.c_str(), message.length())
 +</code>
 ==== -. Arduino with Dragino Shield ==== ==== -. Arduino with Dragino Shield ====
  
deploying_lorawan.txt · Last modified: 2021/08/28 09:50 by samer