wikiroute

networking recipes

User Tools

Site Tools


iot_leb_hackathon

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
iot_leb_hackathon [2019/02/26 16:49] – [3. Devices] sameriot_leb_hackathon [2021/08/28 09:55] (current) samer
Line 7: Line 7:
  
 In the evolution towards the Internet of Things, an increasing number of devices equipped with sensors and communication interfaces will interact and collect data, communicate over the internet, and provide valuable monitoring and automation services. IoT-Leb Hackathon is a unique opportunity to get acquainted with the technologies that are set to play an essential role in the IoT landscape. During the Hackathon, you will get exclusive access to the latest IoT technologies. In the evolution towards the Internet of Things, an increasing number of devices equipped with sensors and communication interfaces will interact and collect data, communicate over the internet, and provide valuable monitoring and automation services. IoT-Leb Hackathon is a unique opportunity to get acquainted with the technologies that are set to play an essential role in the IoT landscape. During the Hackathon, you will get exclusive access to the latest IoT technologies.
-===== -Platform =====+===== - Platform =====
  
 During this lab, you will benefit from the first experimental platform implementing an end-to-end LoRaWAN solution in Lebanon. The platform consists of the following elements: During this lab, you will benefit from the first experimental platform implementing an end-to-end LoRaWAN solution in Lebanon. The platform consists of the following elements:
Line 19: Line 19:
  
 [{{ :img_20170124_160141.jpg?nolink&400 | Figure 2. Outdoor antenna at ESIB-USJ}}] [{{ :img_20170124_160141.jpg?nolink&400 | Figure 2. Outdoor antenna at ESIB-USJ}}]
-===== -Backend ===== +===== - Backend ===== 
-In a LoRaWAN network, the devices communicate with a Network Server through the gateway. The backend installed in the platform is based on an open-source LoRaWAN network-server https://www.loraserver.io. A web interface is available for configuring the applications and devices on the platform (https://212.98.XX.XX:8080).+In a LoRaWAN network, the devices communicate with a Network Server through the gateway. The backend installed in the platform is based on an open-source LoRaWAN network-server https://www.loraserver.io. A web interface is available for configuring the applications and devices on the platform (https://212.98.ZZ.ZZ:8080).
  
 Start by choosing the application named ''hackathon'' to create a new device.  Start by choosing the application named ''hackathon'' to create a new device. 
  
 You should provide the following information for creating your device: You should provide the following information for creating your device:
-  * A unique device name: ''IoTX'' (where ''X'' is your group number)+  * A unique device name: ''IoTXX'' (where ''XX'' is your group number)
   * The device description   * The device description
-  * A unique device EUI on 64 bits: Random identifiers can be generated on [[https://www.random.org/bytes/]] +  * A unique device EUI on 64 bits 
-  * A unique application key on 128 bits also obtained by random generation.+  * A unique application key on 128 bits
    
 Make sure to choose ''lora-profile'' as a ''Device-profile'' in order to enable OTAA join method. Make sure to choose ''lora-profile'' as a ''Device-profile'' in order to enable OTAA join method.
-===== -Devices =====+===== - Devices =====
  
-Devices in the LoRaWAN platform are implemented on [[TTGO boards | https://bit.ly/2HvgAa9]] with ESP32 system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth, and an additional LoRa transceiver. The combined module as well as the basic configuration steps are presented in [[exploring_lora|Exploring LoRa lab]]+Devices in the LoRaWAN platform are implemented on [[https://bit.ly/2HvgAa9 | TTGO boards]] with ESP32 system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth, and an additional LoRa transceiver.
  
-Start by verifying the installation on your PC of the latest Arduino IDE and the presence of the  LoRaWAN {{ :arduino-lmic-master-esp32.zip |LMIC library}}. Then, download and open the example sketch {{ :example-code-idoe-iot-lab.zip |example-code-idoe-iot-lab.ino}} with Arduino IDE.+Start by verifying the installation on your PC of the latest Arduino IDE and the presence of the LoRaWAN {{ :arduino-lmic-master-esp32.zip |LMIC library}}. Then, download the example sketch from [[https://github.com/samerlahoud/iotleb-hacktools]] and open with Arduino IDE.
  
 Now you should configure your device with the same identifiers ''DEVEUI'' and ''APPKEY'' as in the backend: Now you should configure your device with the same identifiers ''DEVEUI'' and ''APPKEY'' as in the backend:
  
 <code c++> <code c++>
-// Change this! +// This EUI must be in little-endian format, so least-significant-byte 
-// This should also be in little endian format, see below+// first. When copying an EUI from loraserver, this means to reverse 
-static const u1_t PROGMEM DEVEUI[8]= { };+// the bytes
 +static const u1_t PROGMEM DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};   // LSB mode
 void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}
  
-// Change this! +// This key should be in big endian format (or, since it is not really a 
-static const u1_t PROGMEM APPKEY[16] = { }; +// number but a block of memory, endianness does not really apply). In 
-void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY, 16);}+// practice, a key taken from loraserver can be copied as-is. 
 + 
 +static const u1_t PROGMEM APPKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // MSB mode 
 +void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}
 </code> </code>
  
Line 54: Line 58:
 </WRAP> </WRAP>
  
-Let us analyze the radio parameters in the sketch by answering the following questions.+The LMIC library (see {{ :lmic-v1.5.pdf | documentation}}) defines a set of events corresponding to the protocol machine state. These events appear in the ''onEvent()'' function. For instance, the ''EV_TXCOMPLETE'' event is called after the completion of a LoRa transmission.
  
-<WRAP left round help 100%> +The ''do_send'' function enables to transmit data over LoRaWAN. After each transmission (''EV_TXCOMPLETE'' event) the next one is scheduled in a way to obtain periodic messagingThis period is defined by ''TX_INTERVAL'' and is subject to duty cycle limitations.
-  * In the setup function, which channels are activated on the device?  +
-  * What are the different spreading factors on each channel? +
-  * What is the regulation on the radio channels in LoRa? +
-</WRAP> +
- +
-The LMIC library (see {{ :lmic-v1.5.pdf | documentation}}) defines set of events corresponding to the protocol machine stateThese events appear in the ''onEvent()'' function. +
- +
-<WRAP left round help 100%> +
-  * What is the difference between the JOINING and the JOINED events?  +
-  * When is the EV_TXCOMPLETE event called? +
-</WRAP> +
- +
-Finally let us look at the message sending on the device. +
- +
-<WRAP left round help 100%> +
-  * What is the function for sending messages on the device? How it is called? +
-  * What is the period of message sending? Explain the implementation choice. +
-  * Is this period guaranteed according to the LoRaWAN specification? +
-</WRAP>+
  
-Now you are ready to compile the sketch and upload it to the LoRaWAN device. Connect the device to a USB port on your PC, choose the board type as presented in [[exploring_lora|Exploring LoRa lab]] and select the corresponding port. Compile and upload!+Now you are ready to compile the sketch and upload it to the LoRaWAN device. Connect the device to a USB port on your PC, choose the board type (''TTGO LoRa32'' or ''T-Beam'' from the ''ESP32 Arduino'' category) and select the corresponding port. Compile and upload!
  
 Open the serial monitor in the Arduino IDE at 115200 baud and analyse the debug messages. Open the serial monitor in the Arduino IDE at 115200 baud and analyse the debug messages.
  
 Getting back to the backend, you can monitor some important information related to your device such as the activation status, frame counters, and live data. Getting back to the backend, you can monitor some important information related to your device such as the activation status, frame counters, and live data.
-===== -. Applications ===== +===== - Capturing Received Messages ===== 
-mqtt-spy is an open source utility intended to help you with monitoring activity on MQTT topics. It has been designed to deal with high volumes of messages, as well as occasional publications. mqtt-spy is a JavaFX application, so it should work on any operating system with an appropriate version of **Java 8 installed**. A very useful tutorial is available on [[https://github.com/eclipse/paho.mqtt-spy/wiki]]. The tool can be directly downloaded from this {{ :mqtt-spy-1.0.0.jar.zip |link}}.+mqtt.fx is utility intended to help you with monitoring activity on MQTT topics. It has been designed to deal with high volumes of messages, as well as occasional publications.
  
-You can use mqtt-spy to debug the messages received from the LoRaWAN devices. After starting the application, configure a new connection to the MQTT broker by simply adding the IP address of the broker in the ''Server URI'' field. Now you can subscribe to any MQTT topic. If you want to receive all messages arriving at the backend, you can use the generic topic ''#''. You can also limit to the topic including the messages of any specific device: ''application/APPLICATION_ID/node/DEVICE_EUI/rx''+You can use mqtt.fx to debug the messages received from the LoRaWAN devices. After starting the application, configure a new connection to the MQTT broker by simply adding the IP address of the broker and the user credentials. Now you can subscribe to any MQTT topic. If you want to receive all messages arriving at the backend, you can use the generic topic ''#''. You can also limit to the topic including the messages of any specific device: ''application/16/device/DEV_EUI/rx''
  
-<WRAP left round help 100%> +The payload received by the MQTT client is decrypted but encoded in Base64On the loraserver, we have activated script that decodes the message before delivery
-  * Summarize the concepts and functionalities of the MQTT protocol. +===== - Sending Downlink Data =====
-  * What are the possible strengths and weaknesses in terms of security of MQTT? +
-  * What are the different types of topics used by the backend? Explain. +
-  * Explain the different fields in captured MQTT message received from you device.  +
-</WRAP>+
  
-<WRAP left round tip 100%> +If you need to send data to your device, you should publish an encoded message in the corresponding topic ''application/16/device/DEV_EUI/tx'' as follows:
-The payload received by the MQTT client is decrypted but encoded in Base64. You should decode it to get the original message (using for instance [[https://www.base64encode.org]]).  +
-</WRAP> +
- +
-If you need to send data to your device, you should publish an encoded message in the corresponding topic ''application/APPLICATION_ID/node/DEVICE_EUI/tx'' as follows:+
  
 <code> <code>
-{ +{"confirmed": false,"fPort": 10,"data": "aGVsbG8gSW9U"}
-    "confirmed": false,                        // whether the payload must be sent as confirmed data down or not +
-    "fPort": 10,                              // FPort to use (must be > 0) +
-    "data": "....                           // base64 encoded data (plaintext, will be encrypted by LoRa Server) +
-}+
 </code> </code>
  
-<WRAP left round tip 100%> +Note that the payload data sent by the MQTT client must be encoded in Base64. For this purpose, you can use the online tool at [[https://www.base64encode.org]]): for example, ''aGVsbG8gSW9U'' is the Base64 encoding of ''Hello IoT''.
-The payload sent by the MQTT client must be encoded in Base64. +
-</WRAP>+
  
-You can also download a {{ :mqtt-emoncms-eguz-script.py.zip | python script}} that automates the data retrieval from the MQTT broker . 
-===== -. LoRaWAN Challenges ===== 
-Implement and provide technical documentation for each of the following challenges. 
- 
-==== -. The End-to-End Challenge ==== 
-I can send data from the device to the application. 
- 
-<WRAP center round tip 100%> 
-Note that the ''String'' function can be used to cast the message you want to send in a string format. 
-</WRAP> 
- 
-==== -. The Downlink Challenge ==== 
-I can send data from the application to the device. 
- 
-==== -. The Radio Challenge ==== 
-I can tune the LoRa radio parameters. 
- 
-These two commands can be helpful when used after the join event: 
- 
-<code c++> 
-LMIC_disableChannel(N); 
-LMIC_setDrTxpow(DR_SF12,14); 
-</code> 
  
-==== -. The Sensor Challenge ==== 
-I can use different sensors to send data from the device: PIR, moisture, temperature, light, etc.  
  
iot_leb_hackathon.1551196181.txt.gz · Last modified: 2019/02/26 16:49 by samer