Libelium Waspmote LoRa Networking Manual Download Page 34

-34-

v7.0

Connectivity

Figure: ACK structure inside a packet structure

Send packets in unicast mode and wait for a response:

www.libelium.com/development/waspmote/examples/sx-03a-tx-lora-ack

Send packets in unicast mode, wait for a response and retry to send the packet if there is no response:

www.libelium.com/development/waspmote/examples/sx-04a-tx-lora-ackwretries

11.5. Receiving data

Normally, the only receiver node in a network is the central node. 

Receiving data in Waspmote is a complex process which needs some special structures to carry out. These operations are 

transparent to the API user, so it is going to be explained the necessary information to be able to read properly a received packet.

Before any packet has been received, an structure of 

pack

 is created. This pack is called 

packet_received

The size of this array is defined by a field in the structure. 

Summary of Contents for Waspmote LoRa

Page 1: ...Waspmote LoRa 868MHz_915MHz SX1272 Networking Guide ...

Page 2: ...ons 14 4 3 1 Getting temperature 14 4 3 2 Getting maximum allowed current supply 15 4 4 Waspmote reboot 15 5 Transmission modes 16 5 1 LoRaTM mode 16 5 1 1 Bandwidth 17 5 1 2 Coding Rate 17 5 1 3 Spreading Factor 17 6 Initialization 18 6 1 Setting on 18 6 2 Setting off 18 7 Node parameters 19 7 1 Node address 19 7 2 Frequency band 19 7 3 Channel 20 8 Packet parameters 22 8 1 Structure used in pack...

Page 3: ...data 34 11 5 1 How to receive packets in Waspmote 35 11 5 2 How to show received Frames 35 11 5 3 Receiving all packets 36 12 Starting a network 37 12 1 Choosing a channel 37 12 2 Choosing a mode 37 13 Joining an existing network 38 13 1 Channel 38 13 2 Mode 38 14 Security and data encryption 39 14 1 Security in transmissions 39 15 Understanding LoRa 40 15 1 Introduction 40 15 2 Long Range VS Tran...

Page 4: ...heaper that the LoRaWAN ones LoRaWAN includes the network layer too so it is possible to send the information to any Base Station already connected to a Cloud platform LoRaWAN modules may work in different frequencies by just connecting the right antenna to its socket These modules are based on the same modulation technology the same PHY layer LoRa developed by Semtech The LoRa module implements a...

Page 5: ...on this chipset Libelium created the Waspmote compliant LoRa module or SX1272 module Module Dual frequency band Transmission power Sensitivity Channels Distance SX1272 863 870 MHz Europe 14 dBm 134 dBm 8 22 km 13 4 miles 902 928 MHz US 13 Figure LoRa module Figure LoRa module with 4 5 dBi antenna ...

Page 6: ...wn in the following figure Figure Frequency channels in the 868 MHz band Note These channels were chosen arbitrarily according to the UN 111 appeared in the Spanish BOE A 2013 4845 If necessary users can select the appropriate channels according to their country regulations The frequency used in USA Canada Australia Singapore or Israel is the free ISM band of 900 MHz using 13 channels with a bandw...

Page 7: ...z CH_08_900 920 36 MHz CH_09_900 922 52 MHz CH_10_900 924 68 MHz CH_11_900 926 84 MHz CH_12_900 915 MHz Figure Channels used by the LoRa modules in 868 MHz and 900 MHz Note Due to the propagation characteristics of the 868 900 MHz bands the near field effect could make that 2 modules cannot communicate if they are placed very close 1 m We suggest to keep a minimum distance of 3 or 4 meters between...

Page 8: ... LoRa module Figure LoRa module in Socket 0 Note The SX1272 module can only be used in special Waspmote v12 units which have been modified to drive the SPI pins to socket 0 The SX1272 module does not implement any security method Encryption is provided through the Waspmote Encryption library Specifically through the AES algorithm with symmetric key with a length of 128 192 or 256 bits The classic ...

Page 9: ... 9 v7 0 Hardware Figure Star topology Note OTA programming is not implemented for the LoRa module Due to its low datarate it would take much time to send one program ...

Page 10: ...LoRa WiFi GPRS GPRS GPS 3G 4G Sigfox LoRaWAN Bluetooth Pro Bluetooth Low Energy and RFID NFC Besides thefollowingIndustrialProtocolsmodulesareavailable RS 485 Modbus RS 232Serial ModbusandCANBus Some of the possible combinations are LoRaWAN GPRS 802 15 4 Sigfox 868 MHz RS 485 RS 232 WiFi DigiMesh 4G RS 232 RFID NFC WiFi 3G CAN bus Bluetooth etc Remark GPRS GPRS GPS 3G and 4G modules do not need th...

Page 11: ... for the Expansion Board Incompatibility with Sensor Boards Agriculture v30 and Agriculture PRO v30 Incompatible with Watermark and solar radiation sensors Events v30 Incompatible with interruption shift register Gases v30 DIGITAL6 is incompatible with CO2 SOCKET_2 and DIGITAL7 is incompatible with NO2 SOCKET_3 Smart Water v30 DIGITAL7 incompatible with conductivity sensor Smart Water Ions v30 inc...

Page 12: ...ere are many examples of using parameters In these examples API functions are called to execute the commands storing in their related variables the parameter value in each case Example of use sx1272 getPreambleLength Gets the preamble length that is going to be send Related variables sx1272 _preamblelength stores the preamble length When returning from sx1272 getPreambleLength the variable sx1272 ...

Page 13: ...ing CRC setCRC_ON Sets the module with CRC on setCRC_OFF Sets the module with CRC off getChannel Indicates the frequency channel within the module is configured setChannel Sets the indicated frequency channel in the module getPower Gets the signal power within the module is configured setPower Sets the signal power indicated in the module setPowerNum Sets the signal power indicated in the module g...

Page 14: ...eceiving functions receivePacketTimeout Receives information before a timeout expires receivePacketMAXTimeout Same as previous function with maximum timeout receivePacketTimeoutACK Receives information before a timeout expires and responds with ACK receivePacketMAXTimeoutACK Same as previous function with maximum timeout receiveAll Receives all the information on air with maximum timeout showFrame...

Page 15: ...x00 to 0x1B corresponding to a range from 45 to 240 mA Example of use sx1272 getMaxCurrent Gets the maximum current supply Related variables sx1272 _maxCurrent stores the maximum current supply of the module SX1272 getting current supply example www libelium com development waspmote examples sx 14 currentsupply 4 4 Waspmote reboot When Waspmote is rebooted the application code will start again cre...

Page 16: ...mission mode It is possible to set a predefined mode or to set these three parameters manually There are ten predefined modes in the API including the largest distance mode the fastest mode and eight other intermediate modes that Libelium has found interesting All of them can be modified or deleted and also it is possible to attach new modes in the appropriate function The predefined modes and its...

Page 17: ...e of use sx1272 setBW BW_250 Sets the 250 kHz bandwidth in LoRa mode 5 1 2 Coding Rate The coding rate value must be chosen among 4 options 4 5 4 6 4 7 and 4 8 It denotes that every 4 useful bits are going to be encoded by 5 6 7 or 8 transmission bits depending on its value The smaller the coding rate is the smallest is 4 8 the higher the time on air is in a transmission so it takes more time to t...

Page 18: ...5 spreadingFactor spreading factor to use in LoRaTM mode SF_7 channel transmission frequency channel CH_12_900 header specifies if header is enabled HEADER_ON CRC specifies if CRC is enabled CRC_OFF power power transmission level 15 Figure Configuration by default Also there are other global variables initialized when this function is called shown in the following table Global variable Description...

Page 19: ...he module we want to perform a broadcast transmission Example of use sx1272 setNodeAddress 2 Set the Node address into REG_NODE_ADDRESS register sx1272 getNodeAddress Get the assigned Node address Related variables sx1272 _nodeAddress stores the Node address The module rejects packets destined to other nodes although it is actually receiving all the packets in the network while it is in receiving ...

Page 20: ...band Channel Number Central Frequency Channel Number Central Frequency CH_10_868 865 20 MHz CH_00_900 903 08 MHz CH_11_868 865 50 MHz CH_01_900 905 24 MHz CH_12_868 865 80 MHz CH_02_900 907 40 MHz CH_13_868 866 10 MHz CH_03_900 909 56 MHz CH_14_868 866 40 MHz CH_04_900 911 72 MHz CH_15_868 866 70 MHz CH_05_900 913 88 MHz CH_16_868 867 MHz CH_06_900 916 04 MHz CH_17_868 868 MHz CH_07_900 918 20 MHz...

Page 21: ... sx1272 setChannel CH_00_900 Set channel sx1272 getChannel Get Channel Related variables sx1272 _channel stores the operating channel SX1272 configuration example www libelium com development waspmote examples sx 01 configure lora parameters ...

Page 22: ...es All the data to send must be stored in this field Its maximum size is defined by MAX_PAYLOAD a constant defined in the library retry Retry counter this parameter is filled by the application It is usually equal to 0 Only when we use the retries feature this value is incremented from 0 to the maximum number of retries stored in the global variable _maxRetries which value is 3 by default If the p...

Page 23: ... High H and Max M Parameter SX1272 power level L 0 dBm H 7 dBm M 14 dBm Figure Transmission power values It is also possible to set the conducted power indicating the quantity as a parameter in the function setPower Note dBm is a standard unit to measure power level taking as reference a 1 mW signal Values expressed in dBm can be easily converted to mW using the next formula mW 10 value dBm 10 Gra...

Page 24: ...cate the signal strength of the last hop so it does not provide an accurate quality measurement of a multihop link Example of use sx1272 getRSSIpacket Get the Receive Signal Strength Indicator sx1272 getRSSI Get the current Receive Signal Strength Indicator Related variables sx1272 _RSSIpacket stores the RSSI of the last received packet sx1272 _RSSI stores the current RSSI value SX1272 RSSI exampl...

Page 25: ...gure Map of the LOS long range tests in Zaragoza The following picture represents the profile of the link The blue line indicates the line of sight conditions taken in the test Besides the purple ellipse indicates the Fresnel zone clearance achieved in this path Figure Profile of the LOS path Test features Several LoRa modes frequency channels and output power modes were tested in order to know th...

Page 26: ... 21 6 km 13 4 miles High CH_12_868 0 117 Max 49 9 95 107 68 120 95 117 3 95 10 2 Non Line of Sight tests 10 2 1 Tests in Zaragoza The Non Line of Sight NLOS tests were taken between several points in the surrounding areas of the Libelium s headquarters in Zaragoza Spain The receiver was a Meshlium device installed on the roof of the Libelium s headquarters The emitter was set in several points in ...

Page 27: ...buildings In this case a large group of low residential houses are close to the point 2 Also a residential block is found in the way to the receiver Point 3 The signal goes through six buildings This point is placed at the side of a big square of the neighborhood The path finds out a big residential building and after this some industrial buildings too Point 4 The signal goes through fourteen buil...

Page 28: ...The transmitter is outside the first floor of an office building at a height of about 3 meters The receiver is at street except in one of them that is situated bellow ground floor in a garage There is no line of sight between the points Figure Test distance on the map Figure Detail of the garage test point ...

Page 29: ... central node Gateway LoRaTM This special Gateway enables the user to receive data directly in a standard PC It is interesting for the first development phase and can be used to test a real project or to do less advanced tasks Figure Star topology with Gateway as central node Waspmote It is the less interactive option In order to send the data to Cloud or via wireless it is necessary to have anoth...

Page 30: ...e Address Unicast always performs control time mechanisms time out to prevent perpetual waiting for a packet Unicast mode is the only one that supports additional services for more robust communication like 1 ACKconfirmation ifthedeveloperusesfunctionslikesendPacketTimeoutACK andreceivePacketWithTimeoutACK receiving modules will send an ACK packet which aim is to confirm the packet was correctly r...

Page 31: ... 04a tx lora ackwretries 11 2 2 Broadcast Broadcast is used to send a packet to all nodes in a network Any module within range will accept a packet that contains the broadcast address 0 To send a broadcast message the Destination Address should be set to BROADCAST_0 While in this mode there is no possibility to use ACK confirmations or retries ...

Page 32: ...3 Example of use sx1272 setRetries 2 Sets the number of retries that can be sent Related variables sx1272 _maxRetries stores the maximum number of retries that can be sent 11 4 Sending process Sending data is a complex process which needs some special structures and functions 11 4 1 SX1272 API packet structure The API packet structure used to transmit packets with LoRa modules is specified in the ...

Page 33: ... Frame examples www libelium com development waspmote examples sx 05a tx lora waspframe www libelium com development waspmote examples sx 06a tx lora ack waspframe www libelium com development waspmote examples sx 07a tx lora ackwretries waspframe 11 4 3 Sending data This is the process to send a packet between SX1272 devices Send data The API function responsible for sending data is called indica...

Page 34: ...mples sx 04a tx lora ackwretries 11 5 Receiving data Normally the only receiver node in a network is the central node Receiving data in Waspmote is a complex process which needs some special structures to carry out These operations are transparent to the API user so it is going to be explained the necessary information to be able to read properly a received packet Before any packet has been receiv...

Page 35: ...t packet received sx1272 ACK stores the structure of the ACK Receiving packets example www libelium com development waspmote examples sx 02b rx lora Receiving packets and answering with ACK example www libelium com development waspmote examples sx 03b rx lora ack Receiving packets sending a response and retrying to receive the packet example www libelium com development waspmote examples sx 04b rx...

Page 36: ...guration mode listen any packet Depending on the destination address each node will hold packets addressed to it and discard others The user can decide to receive all packets no matter the destination address This is called promiscuous mode The user should know that the only way to protect transmissions is using Encryption libraries Receive all the packets sent to any destination www libelium com ...

Page 37: ..._900 should be chosen This value will be used as the input parameter in the API function responsible for setting the channel Example of use sx1272 setChannel CH_04_900 Set channel SX1272 configuration example www libelium com development waspmote examples sx 01 configure lora parameters 12 2 Choosing a mode This parameter is only intended for LoRa Mode is different depending on the BW CR and SF pa...

Page 38: ...se the API function responsible for that matter Example of use sx1272 setChannel CH_04_900 Set channel number 4 in 900 band SX1272 configuration example www libelium com development waspmote examples sx 01 configure lora parameters 13 2 Mode To set mode use the API function responsible for that matter Example of use sx1272 setMode 3 Set LoRa mode number 3 SX1272 configuration example www libelium ...

Page 39: ...gin and the destination AES is classified as a block cipher algorithm This means it has different modes of operation like ECB or CBC mode In this case it has been used ECB electronic codebook mode which is the simplest of the encryption modes with a ZEROS padding scheme For further information please check the Waspmote encryption Programming Guide www libelium com development waspmote documentatio...

Page 40: ...ncy bands are lower than the popular 2 4 GHz band so path loss attenuation is better in LoRa In addition 868 and 900 MHz are bands with much fewer interference than the highly populated 2 4 GHz band Besides these low frequencies provide great penetration in possible materials brick walls trees concrete so these bands get less loss in the presence of obstacles than higher bands The great performanc...

Page 41: ...ode 1 gives the best range performance because the sensitivity is minimum however we must take into account that the transmission time of a typical packet is high Mode BW CR SF Sensitivity dB Transmission time ms for a 100 byte packet sent Power consumption mA ms 1000 reference 35 mA in TX mode Transmission time ms for a 100 byte packet sent and ACK received Comments 1 125 4 5 12 134 4245 149 5781...

Page 42: ...ons but best range For the time synchronization the RTC of Waspmote has been used to open temporal windows so as to perform the sending process 15 3 LoRa VS XBee 868 900 MHz Tests demonstrate that the LoRa module has much better long range performance than other communication modules including XBee 868 or 900 Dozens of km are easily achievable in good conditions thanks to the extremely low sensiti...

Page 43: ... of nodes and on the number of packets per hour that each node sends Power consumption is a major challenge so probably any LoRa node should be powered by a solar panel or even better connected to mains electricity Last we must note that due to the low bandwidth LoRa by itself does not support Over the Air Programming OTA however many of our clients use as a second radio the 3G GPRS or WiFi module...

Page 44: ...tChannel CH_11_868 USB print Setting Channel state USB println e Select implicit off or explicit on header mode e sx1272 setHeaderON USB print Setting Header ON state USB println e Select mode mode 1 is the better reach one e sx1272 setMode 1 USB print Setting Mode 1 state USB println e select CRC on or off e sx1272 setCRC_ON USB print Setting CRC on state USB println e Select output power Max Hig...

Page 45: ...rame createFrame ASCII WASP_PRO Adding sensor battery frame addSensor SENSOR_BAT uint8_t PWR getBatteryLevel Printing frame via USB frame showFrame Sending packet with timeout protection sx1272 sendPacketTimeout 5 frame buffer frame length delay 1000 ...

Page 46: ... 46 v7 0 API changelog 17 API changelog Keep track of the software changes on this link www libelium com development waspmote documentation changelog LoRa ...

Page 47: ...tifications See below the specific list of regulations passed More info at www libelium com products plug sense Besides Meshlium our multiprotocol router for the IoT is also certified with the certifications below Get more info at www libelium com products meshlium List of certifications for Plug Sense and Meshlium CE Europe FCC US IC Canada ANATEL Brazil RCM Australia PTCRB cellular certification...

Reviews: