The Project assignment will be handed out on 26 April 2022
The project assignment requires you to design and implement a BLE-Based Sensor Network
. At the end of the project, you will submit a report and demonstrate your implementation.
Problem Description and Requirements
Bluetooth Low Energy (BLE) is becoming a dominant industry standard for short-range IoT communications. It is now emerging as a good alternative for providing wireless connectivity to low-power sensors. In this project, you will design and implement a BLE-based sensor network which consists of one or more sensor nodes and a gateway. To simplify the project, the sensor network uses a single-hop topology
wherein the sensor nodes are all within communication range from the gateway. The gateway also has a backhaul link, which is used for receiving queries via CoAP.
When the gateway receives a query via CoAP, it immediately initiates scanning to find the appropriate sensor. If an appropriate sensor is discovered, the gateway connects to the sensor, reads the data, and sends it back to the requestor. If no appropriate sensor is discovered, the gateway sends back an error message.
The requirements on the gateway and sensor nodes are divided into three types: Core
, and Challenge
. To be considered a reasonable attempt, you must design, implement and demonstrate the Core requirements on both the gateway and sensor nodes.
| Requirement Type
- The gateway node must always be switched on.
- The gateway node must be able to scan for sensors within its range via the BLE interface.
- The gateway node must be able to connect to a chosen sensor node and read the necessary data via the BLE interface.
- The gateway node must host a CoAP server which listens for requests via the WIFI interface.
- The gateway node must support the following methods and unique resource identifiers (URIs):
You are free to format the payload of the CoAP responses (this is part of your design), however, the response must include the following information: (1) Unix timestamp; (2) sensor reading value; and (3) sensor reading unit. For temperature, the unit must be Celsius whereas for humidity, it must be Percent.
You are also free to define and format the different kinds of error messages that the gateway can respond to a client.
- The sensor node must always be switched on.
- The sensor node must advertise its presence and the type of sensor data (e.g. temperature, humidity, etc.) it provides via the BLE interface, so that it can be discovered by the gateway node.
- The sensor node must allow the gateway node to establish connection so the latter can read the sensor data. Since the sensor node has no real attached sensor, you can generate random sensor data during your testing.
Discovery Latency Optimisation:
- The discovery latency must be optimised, to be less than 100 ms 50% of the time. You are free to change the BLE link layer parameters (e.g. scan window, scan interval, advertising interval). To satisfy this requirement, you must collect at least 100 discovery latency measurements, and 50 of those measurements should be less than 100 ms.
|| Sensor Power Consumption Optimisation:
- The sensor node must be duty-cycled, i.e., it must periodically switch on and switch off to reduce power consumption. You are free to design the duty cycling scheme, but you must thoroughly evaluate the performance trade-offs of your design.
- You should implement the duty-cycling functionality as an addition to the core sensor node functionality (specified in the core requirements) which can be easily enabled or disabled.
Hardware and Base Code
To facilitate the implementation and evaluation of your designs, two M5Stack devices will be loaned to you. M5Stack is a versatile device equipped with WiFi and BLE which can be easily programmed using Arduino Studio. One key advantage of M5Stack is that you can modify the BLE source code to easily implement your ideas. Of course, you are free to use other BLE devices that you can have access. You may also collaborate with your classmates during testing so you have more devices for testing. The hardware will be available for pickup in my office from 29 April 2022 10:00.
For more information about M5Stack Arduino IDE, visit this page
. For a tutorial on how to setup your computer, visit ArduinoM5StackTutorial
You can download the base code for the gateway here
. For the sensor, you can use the example here
as base code. You can use the given base codes for implementing your designs. Alternatively, you can write your implementation from scratch.
Report and Source Code
A report explaining your designs and presenting validation results is to be submitted at the end of the project. You should clearly explain the novel aspects of your designs, cite the relevant sources where you have taken codes, ideas, design, etc. from, and also provide explanation of why your designs work well or do not work well under the different scenarios. An important part of your report is the Evaluation section. You must perform experiments to measure the response time of your system. Response time is measured from the perspective of the CoAP client, and defined as the time delay between the sending of the CoAP request and the receipt of the CoAP response. You will need to think about other performance metrics that you want to measure, as well as the parameters that you will need to vary that will affect the performance metrics. You are encouraged to use the template at ReportTemplate
to structure your report.
You must submit a copy of your source code through the submission system; that will allow us to run your implementation and validate it. Ensure that your code is properly formatted and commented.
The deadline for the submission of the project report (and source code) is 30 May 2022
. A demonstration of your implementation will be carried out on 31 May-3 June 2022
. See Demo
for more information.
| Core Functionality
|| The gateway and sensor node implementation satisfies the core requirements specified in this handout. This item will be graded during the demo.
| Completion Functionality
|| The discovery latency satisfies the completion requirements specified in this handout. This item will be graded during the demo together with the report.
| Challenge Functionality
|| The sensor node implementation satisfies the additional challenge requirements specified in this handout. This item will be graded during the demo together with the report.
|| The report provides a comprehensive description of the project. See Report section above for more details. The report will be used to grade this item.
|| This item refers to the clarity and readability of the code you have written, i.e., whether your code uses consistent coding style and sufficient documentation. The source code will be used to grade this item.
M5Stack Github: https://github.com/m5stack/M5Stack
Sample BLE Server: https://github.com/naoki-sawada/m5stack-ble/tree/master/m5stack-ble
ESP32 BLE Arduino: https://www.arduino.cc/reference/en/libraries/esp32-ble-arduino/
Documentation for Arduino ESP32 BLE: https://github.com/nkolban/esp32-snippets/blob/master/Documentation/BLE%20C%2B%2B%20Guide.pdf
(see pages 3-12)
CoAP for Arduino: https://www.arduino.cc/reference/en/libraries/coap-simple-library/
CoAP Client Shell (Java Jar): https://github.com/tzolov/coap-shell
CoAP Command Line Interface Client: https://github.com/avency/coap-cli
CoAP Extension for Chrome Browser: https://github.com/mkovatsc/Copper4Cr
Useful Mobile Apps