0% found this document useful (0 votes)
17 views23 pages

Documentation Goup6

This document outlines a prototype system developed for monitoring vehicle heights before entering tunnels or underpasses to ensure safety. It details the components used, including a laser distance sensor, Arduino UNO, and LoRaWAN for data transmission, as well as the implementation and testing of the system. Additionally, it describes the cloud service for data collection and visualization to monitor vehicle safety in real-time.

Uploaded by

cuongvotuan1196
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views23 pages

Documentation Goup6

This document outlines a prototype system developed for monitoring vehicle heights before entering tunnels or underpasses to ensure safety. It details the components used, including a laser distance sensor, Arduino UNO, and LoRaWAN for data transmission, as well as the implementation and testing of the system. Additionally, it describes the cloud service for data collection and visualization to monitor vehicle safety in real-time.

Uploaded by

cuongvotuan1196
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Prototype Documentation

Bachelor’s Assignment
Degree Programme in Electrical and Automation Engineering
Spring 2025
Pavithra Ekanayake
Van Quyen
Tuan Vo
Table of Contents

1 Theory............................................................................................................................................. 1
1.1 What IIOT means? ................................................................................................................. 1
1.2 Description of used devices and services............................................................................... 1
1.2.1Laser Distance Sensor (CJMCU530) ............................................................................. 1
1.2.2The Arduino Uno ............................................................................................................ 2
1.2.3LoRaWAN (Long Range Wide Area Network) ................................................................ 2
1.2.4ThingSpeak .................................................................................................................... 3
2 An explanation of the use case ....................................................................................................... 3
3 Local system implementation description ........................................................................................ 4
3.1 Connections between different sensors and boards ............................................................... 4
3.1.1Laser Distance Sensor (CJMCU530) ............................................................................. 4
3.1.2Arduino UNO .................................................................................................................. 4
3.1.3LoRaWAN ...................................................................................................................... 4
3.2 System planning, used functions ............................................................................................ 5
3.2.1Planning ......................................................................................................................... 5
3.2.2Functions ....................................................................................................................... 6
3.3 Testing ................................................................................................................................... 6
4 Cloud service description ................................................................................................................ 7
4.1 Sent and collected data.......................................................................................................... 7
4.1.1Sent Data ....................................................................................................................... 7
4.1.2Collected Data................................................................................................................ 7
4.2 The visualization for the use case and why elements were selected ...................................... 7
4.2.1Height of Vehicle ............................................................................................................ 7
4.2.2Number of Safe Vehicles................................................................................................ 9
4.2.3Number of Warning Vehicles .......................................................................................... 9
4.2.4Number of Over height Vehicles ................................................................................... 10
4.2.5Warning Status............................................................................................................. 11
4.2.6Text Warning ................................................................................................................ 11
4.2.7Channel location .......................................................................................................... 12
5 A list of participants and contribution description ........................................................................... 13
6 What learned during the implementation ....................................................................................... 13
7 Expected improvements for the solution: ....................................................................................... 14
References .......................................................................................................................................... 15
Figures

Figure 1. Prototype of our system ........................................................................................................ 5


Figure 2. Visualization of Instantaneous Risky Heights ........................................................................ 8
Figure 3. Drawing the bar chart using MATLAB code ........................................................................... 8
Figure 4. Visualization of Number of Safe Vehicles entered ................................................................. 9
Figure 5. Visualization of Number of Warning Height Vehicles entered .............................................. 10
Figure 6. Visualization of Number of Dangerous Height Vehicles coming .......................................... 10
Figure 7. Green Indicator for Safety cases ......................................................................................... 11
Figure 8. Red Indicator for Dangerous cases .................................................................................... 11
Figure 9. Announcements of Safety cases ........................................................................................ 12
Figure 10. Announcement of Dangerous cases ................................................................................ 12
Figure 11. Providing the sensor's location where all measurements conducted ................................ 13

Tables

Table 1. Cross-connection between Laser Sensor and Arduino Board................................................. 4

Appendices

Appendix 1. Source Code “Sensor Initialization and LoRaWAN Setup”


Appendix 2. Source Code “Distance Measurement and Classification”
Appendix 3. Source Code “LoRaWAN Periodic Sending”
Appendix 4. Source Code “Changing LED Colors”
Appendix 5. Source Code “Sending LoRa Message for Over-Height Vehicles”
1 (15)

1 Theory

1.1 What IIOT means?

The Industrial Internet of Things (IIoT) refers to the integration of industrial equipment with
internet-connected sensors, devices, and advanced analytics platforms. It is a part of the
larger Internet of Things (IoT) that is specially used in industries like factories, transport,
energy, and construction.

In an IIoT system, devices collect and transmit data to a centralized platform (often cloud-
based), where the data is monitored, analysed, and used to drive automated decisions,
increase efficiency, ensure safety, and reduce operational costs.

Key components of IIoT include:

• Smart sensors to collect real-time data.


• Microcontrollers or gateways to process and transmit data.
• Wireless communication technologies (e.g., LoRaWAN, Wi-Fi).
• Cloud platforms for data storage, visualization, and analysis.

1.2 Description of used devices and services

1.2.1 Laser Distance Sensor (CJMCU530)

The CJMCU-530 is a compact laser distance sensor module based on the VL53L0X time-
of-flight (ToF) sensor developed by STMicroelectronics. It is commonly used for precise
distance measurement applications and is often integrated into Arduino and other
microcontroller projects (STMicroelectronics, n.d.).

Key Features of CJMCU-530 (VL53L0X-based):

• Technology: Time-of-Flight (ToF).


• Measurement Range: Up to ~2 meters (actual range varies based on lighting and
surface reflectivity).
2 (15)

• Accuracy: High precision within short distances (better than ultrasonic sensors for
close-range).
• Interface: I2C (used for communication with microcontrollers like Arduino,
Raspberry Pi).
• Resolution: ~1 mm.
• Operating Voltage: 2.6V to 3.5V (CJMCU board often includes onboard regulator
allowing 3.3V or 5V use).
• Laser Class: Class 1 (eye-safe).

1.2.2 The Arduino UNO Wifi Rev2

The Arduino Uno Wifi Rev2 is one of the most popular and beginner-friendly microcontroller
boards in the Arduino family. It is widely used for learning electronics, prototyping, and
building embedded systems (Docs.Arduino, n.d.).

1.2.3 LoRaWAN (Long Range Wide Area Network)

LoRaWAN is a low-power, wide-area networking protocol designed for wireless


communication between Internet of Things (IoT) devices over long distances with low
power consumption (Semtech, n.d.).

Key Points:

• Technology Base: Built on LoRa (Long Range), a radio modulation technique


developed by Semtech.
• Range: Up to 10–15 km in rural areas, 2–5 km in urban environments.
• Power Efficiency: Designed for ultra-low power usage, allowing battery-powered
sensors to run for years.
• Frequency Bands: Uses unlicensed ISM bands (e.g., 868 MHz in Europe, 915 MHz
in the US, 433 MHz in some regions).
• Security: Includes end-to-end encryption (AES-128) for data confidentiality and
integrity.
3 (15)

1.2.4 ThingSpeak

ThingSpeak is an open-source Internet of Things (IoT) platform that allows you to collect,
store, analyse, and visualize sensor data from devices like Arduino and Raspberry Pi over
the internet (IPCB, n.d.).

Key Features:

• Real-time data collection.


• Data visualization with customizable charts and graphs.
• MATLAB analytics integration for advanced data processing and algorithms.
• Cloud-based: Hosted by MathWorks (makers of MATLAB).
• Free tier available (suitable for small projects).

2 An explanation of the use case

The purpose of this system is to monitor and measure the height of vehicles before
entering tunnels or underpasses, such as bridges, to ensure safety.

Vehicles with excessive height could pose a risk by damaging these structures, potentially
causing traffic accidents or infrastructure damage. The system uses a laser distance
sensor integrated with an Arduino UNO microcontroller and LoRaWAN communication to
perform real-time monitoring.

By measuring the height at three different stages (safe height, warning height, and over
height), the system can compare the measured height against a predefined clearance
height. If the vehicle exceeds safe height, the system triggers appropriate warning
indicators (e.g., lights), giving drivers a chance to stop or take alternate routes, thereby
preventing accidents or damage to the infrastructure.
4 (15)

3 Local system implementation description

3.1 Connections between different sensors and boards

To connect the CJMCU-530 (based on the VL53L0X Time-of-Flight sensor) to an Arduino


Uno, use the I2C interface, which is simple and only requires two data lines: SDA and SCL,
along with VCC and GND for power.

Table 1. Cross-connection between Laser Sensor and Arduino Board

CJMCU-530 Pins Arduino Uno Pins

5V or 3.3V (check board specs, most CJMCU


VCC
boards tolerate 5V)

GND GND

SCL A5 (Uno I2C Clock)

SDA A4 (Uno I2C Data)

3.1.1 Laser Distance Sensor (CJMCU530)

The laser distance sensor is used to measure the vehicle height as it approaches the entry
point of the tunnel or structure. This sensor is typically connected to the Arduino UNO via
its digital output pins.

3.1.2 Arduino UNO Wifi Rev2

The Arduino acts as the central processing unit that receives data from the laser sensor
and processes them. It compares the measured vehicle height against predefined
thresholds: safe height, warning height, and over height. Based on this comparison, it
triggers outputs such as warning indicator lights (Red, Blue and Green).

3.1.3 LoRaWAN

LoRaWAN is used to transmit the data to a remote cloud server for logging, analysis, and
further action. This module connected to the Arduino UNO to enable wireless
5 (15)

communication. It allows data (height measurements, warning status and vehicle count) to
be transmitted over long distances, ideal for remote monitoring.

3.2 System planning, used functions

3.2.1 Planning

• Arduino reads the height data from the laser sensor using digital input.
• A comparison function checks if the height is below the safe threshold, within the
warning threshold, or over the clearance.
• Based on the comparison results, the system triggers a corresponding action, such
as illuminating different warning lights for each stage.
• The Arduino continuously loops through detection logic. When a vehicle enters the
sensor range:
1. The height is measured.
2. Height is compared to thresholds.
3. Appropriate counter (safe/warning/over height) is incremented.
4. The total vehicle count is updated.
5. All values are sent to the cloud.

Figure 1. Prototype of our system


6 (15)

3.2.2 Functions

Triggering Warning Indicators (Appendix 2 and Appendix 4):

• If the vehicle height is under the safe height, a green light is triggered.
• If the vehicle is in the warning height stage, a yellow light is triggered.
• If the vehicle exceeds the clearance height (over height), a red light is activated.

Count and log :

• Instantaneous vehicle height


• Number of safe-height vehicles
• Number of warning-height vehicles
• Number of over height vehicles

Wireless Communication (Appendix 1, Appendix 3, and Appendix 5): The LoRaWAN


communication is used for real-time data transmission of the vehicle height and warning
status to a cloud server. This allows remote monitoring and logging of the system’s
performance.

3.3 Testing

• Sensor Calibration: Ensuring that the laser distance sensor provides accurate
readings and calibration against known heights.
• Threshold Adjustment: Verifying that the system correctly triggers warnings at the
appropriate height thresholds (safe, warning, and over height).
• Counter Verification: Testing simulated vehicles to ensure accurate counting and
classification.
• Wireless Communication: Ensuring reliable data transmission via LoRaWAN,
checking for signal integrity and potential interference in the system.
• Real-World Scenarios: Testing with vehicles of varying heights to simulate real-
world conditions, ensuring the system’s robustness and accuracy in live conditions.
• System Response: Monitoring the response time of the system and ensuring that
indicator lights are triggered promptly based on vehicle height.
7 (15)

4 Cloud service description

4.1 Sent and collected data

4.1.1 Sent Data

The data is sent through the LoRaWAN network to the cloud for centralized monitoring.
The system sends key data, including:

• Instantaneous height of vehicle measured by the laser sensor.


• Status of height (safe, warning, over height).
• Number of vehicles in each height category.
• Timestamps of detection events.

4.1.2 Collected Data

The cloud service collects and stores data over time, such as the number of vehicles
detected, the frequency of over height occurrences, and the overall system performance.
These data can be visualized and analysed for trends, such as times when over height
vehicles are more common or patterns related to tunnels/structures.

4.2 The visualization for the use case and why elements were selected

4.2.1 Over Heights of Vehicles

This visualization element displays the real-time height measurements of the over height
vehicles compared to the tunnel clearance. It helps operators immediately see how much
clearance is available and whether the vehicle's height is within acceptable limits.

This visualization allows operators to monitor the exact heights of entering vehicles. If the
measurement is above the threshold for "safe" height, immediate corrective actions can be
taken, such as turning on RED light indicator and showing warning text ‘Do not enter!’.
It is particularly useful in showing how close the vehicle is to the clearance level.
8 (15)

Figure 2. Visualization of Instantaneous Risky Heights

Figure 3. Drawing the bar chart using MATLAB code

We also tried to create a chart with the same content using MATLAB code. This chart is
customized, but still low in display. So, we had to refresh the ThingSpeak page once to see
any updates
9 (15)

4.2.2 Number of Safe Vehicles

This element shows the total count of vehicles that have passed through the monitoring
point and have a height within the "safe" range, meaning their height is below the clearance
limit.

This allows operators to keep track of the number of vehicles that are safely entering the
tunnel or under the overhead structure without risk of damage. It can also provide an
indication of the normal flow of traffic.

Figure 4. Visualization of Number of Safe Vehicles entered

4.2.3 Number of Warning Vehicles

This element tracks the total number of vehicles that have heights within the warning
range, indicating they are approaching or slightly exceeding the safe clearance height.

This serves as an early warning for potential issues. If a significant number of warning
vehicles are detected, it may indicate a recurring problem or a need for further inspection of
the tunnel clearance.
10 (15)

Figure 5. Visualization of Number of Warning Height Vehicles entered

4.2.4 Number of Over height Vehicles

This element displays the total number of vehicles that exceed the clearance height limit
and fall into the "over height" category, posing a risk to the tunnel or overhead structure.

Tracking over height vehicles is critical for safety and helps operators determine when
immediate action is required. If over height vehicles are detected, the system can trigger
alarms or stop vehicles from entering the restricted area. This also helps identify patterns,
such as specific times or conditions when over height vehicles are more likely to occur.

Figure 6. Visualization of Number of Dangerous Height Vehicles coming


11 (15)

4.2.5 Warning Status

It shows a color-coded (green/red) indicator showing the current state of the system in real
time. It enables quick visual recognition of whether the current vehicle or situation is safe or
dangerous.

Figure 7. Green Indicator for Safety cases

Figure 8. Red Indicator for Dangerous cases

4.2.6 Text Warning

A real-time text message (e.g., “Welcome vehicle height = 13m”, “Warning – Do not enter
vehicle too high”) based on the vehicle's classification. This text provides clear, readable
feedback to operators or drivers. It is Ideal for display boards, alerts, or automated signage.
12 (15)

Figure 9. Announcements of Safety cases

Figure 10. Announcement of Dangerous cases

4.2.7 Channel location

The physical location where the detection occurred. This display is useful for systems with
multiple monitoring points, which helps identify where specific events (especially over
height detections) took place.
13 (15)

Figure 11. Providing the sensor's location where all measurements conducted

5 A list of participants and contribution description

Quyen contributed to the project such as:

• Assemble the prototype.


• Come up with the idea that if no object is detected, the LED will not light up.
• Participate in writing code in Arduino.

Pavithra Ekanayake:

• Participating in writing Arduino code (Appendix 4).


• Create PowerPoint for presentation.
• Write theory report.
• Test the system to make sure everything works correctly.

Tuan Vo:

• Act as an assignment planner.


• Participate in writing Arduino code and adjustment whole code.
• Make the visualisation on ThingSpeak.
• Complete the final report.
14 (15)

6 What learned during the implementation

• The important thing is that we have an opportunity to practice turning an idea to


reality. We started with initial ideas to planning, building a prototype, and
adjustment to improve our prototype model.
• We understand how laser sensors work, such as the ability to identify objects
continuously.
• We know how to create the LoRaWAN communication.
• We learn to use the ThinkSpeak platform to display the information obtained from
the sensor. More specifically, we know how to create channels, set the necessary
parameters to get information and display information.
• The second important thing we learned from this assignment is that we had a
chance to practice our presentation skills in front of teachers and classmates, to
communicate our ideas as if to potential customers.

7 Expected improvements for the solution:

We want to add the function of measuring the velocity of objects (vehicles). However, it
seems impossible because of the change in length of the objects. To solve this problem,
we need at least two laser sensors to measure the time interval between 2 object
detections of 2 sensors and from there we can calculate the velocity of the object.

The second expectation is to measure the height data of vehicles having multiple heights to
identify the highest one. We had an idea to store all measured readings into an array and
make the comparison between them.

The third point is that we want to transmit the locations of all sensors using add-on sensor
boards that can send real-time longitude and altitude data to ThingSpeak. Currently, we
have only entered fixed sample values for altitude and longitude in the channel settings on
the ThingSpeak website.
15 (15)

References

Docs.Arduino. (n.d.). Retrieved from UNO WiFi Rev2: https://docs.arduino.cc/hardware/uno-wifi-rev2/

IPCB. (n.d.). Retrieved from Pull Data From ThingSpeak And Custom Dashboard Look Better:
https://epcb.vn/blogs/news-1/esp8266-http-client-pull-data-from-thingspeak-and-custom-
dashboard-look-better?view=en

Semtech. (n.d.). Retrieved from What Is LoRa®?: https://www.semtech.com/lora/what-is-lora

STMicroelectronics. (n.d.). Retrieved from Time-of-Flight (ToF) ranging sensor:


https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html
Appendix 1
Appendix 1. Source Code “Sensor Initialization and LoRaWAN Setup”

void setup() {
Wire.begin(); // Start I2C communication
sensor.init(); // Initialize the VL53L0X sensor
sensor.setTimeout(100); // Set timeout for reading
sensor.setMeasurementTimingBudget(20000); // Sensor timing budget

// Set LED pins as OUTPUT


pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);

// Initialize LoRaWAN module


LoRaWAN.Init();
Serial.begin(115200);

// Ensure device is connected


while (!LoRaWAN.checkDeviceConnect());
LoRaWAN.writeCMD("AT+CRESTORE\r\n"); // Restore defaults
LoRaWAN.writeCMD("AT+ILOGLVL=0\r\n"); // Disable debug logs
LoRaWAN.writeCMD("AT+CSAVE\r\n"); // Save config
LoRaWAN.writeCMD("AT+IREBOOT=0\r\n"); // Reboot module

// Wait for reconnection


delay(1000);
while (!LoRaWAN.checkDeviceConnect());

// Configure OTAA credentials


LoRaWAN.configOTTA(DEVADDR, DEVEUI, APPKEY, APPSKEY, "2");
LoRaWAN.setClass("0"); // Class A
LoRaWAN.writeCMD("AT+CWORKMODE=2\r\n"); // Normal work mode
LoRaWAN.writeCMD("AT+CCONFIRM=0\r\n"); // Unconfirmed uplink
LoRaWAN.setRxWindow("869525000"); // RX2 window
LoRaWAN.setFreqMask("0001"); // Frequency mask
LoRaWAN.startJoin(); // Start joining the network
while (!LoRaWAN.checkJoinStatus()); // Wait for success

// Final GPIO setup


pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

// Reset counters and status


d = 0;
OH = WH = SH = 0;
}
Appendix 2

Appendix 2. Source Code “Distance Measurement and Classification”

void loop() {
currentMillis = millis(); //get the current time
d = sensor.readRangeSingleMillimeters(); // Measure distance
// Upadated to counter with delay to avoid misleading reading
if (currentMillis-startSensorMillis >= MeasureInterval){
if (d < Min_Distance) {
setColor(255, 0, 0); // Turn on Red light
if (!bRed)// to Ensure the message is sent only one time and the counter in-
crease one unit once if the object does not move away of sensor {
Serial.print("Don't enter - Height (mm): "); Serial.println(Tunnel-
Height-d);
OH++; // Counter variable increase only 1 unit
// Form and send a message
String message = "api_key:IY2PCVASDDXNEJJ6,channel_id:2901925";
String field1 = ",H:"+ String(TunnelHeight-d);
message.concat(field1);
String field2 = ",OH:"+ String(OH);
message.concat( field2);
String field3 = ",WH:"+ String(WH);
message.concat(field3);
String field4 = ",SH:"+ String(SH);
message.concat(field4);
LoRaWAN.sendMsg(message);
Serial.println(message);
// Reset status of 'flag' variables
bRed = true;
bBlue = false;
bGreen = false;
}
} else if (d >= Min_Distance && d < Max_Distance) {
setColor(0, 0, 255); // Turn on Blue Light
if (!bBlue) {
Serial.print("Be careful - Height (mm): "); Serial.println(TunnelHeight-
d);
WH++;
bBlue = true;
bRed = false;
bGreen = false;
}
} else if (d >= Max_Distance && d < TunnelHeight) {
setColor(0, 255, 0); // Turn on Green Light
if (!bGreen) {
Serial.print("Safety to enter - Height (mm): "); Serial.println(Tunnel-
Height-d);
SH++;
bGreen = true;
bRed = false;
bBlue = false;
}
} else {
setColor(0, 0, 0); // No light is turned
//Serial.println("No car detected! ");// No car enters
bRed = false;
bBlue = false;
bGreen = false;

}
startSensorMillis = currentMillis;}
Appendix 3

Appendix 3. Source Code “LoRaWAN Periodic Sending”

// send message each 10 seconds although no car enters


if (currentMillis-lastLoRaSendMillis >= SendInterval){
String message = "api_key:IY2PCVASDDXNEJJ6,channel_id:2901925";
message += ",OH:" + String(OH);
message += ",WH:" + String(WH);
message += ",SH:" + String(SH);
if ((d < TunnelHeight) && (d > Min_Distance)){
Serial.println("Safa cars detected, sending messages.");
} else {
// No car detected, no sending
Serial.println("No car detected, keep sending regular messages.");
}
LoRaWAN.sendMsg(message); // send via LoRaWan
Serial.println(message); // reset sending timer
lastLoRaSendMillis = currentMillis;

}
Appendix 4

Appendix 4. Source Code “Changing LED Colors”

void setColor(int redValue, int greenValue, int blueValue) {


analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);

}
Appendix 5

Appendix 5. Source Code “Sending LoRa Message for Over-Height Vehicles”

// Form and send a message


String message = "api_key:IY2PCVASDDXNEJJ6,channel_id:2901925";
String field1 = ",H:"+ String(TunnelHeight-d);
message.concat(field1);
String field2 = ",OH:"+ String(OH); // OH is Over Height
message.concat( field2);
String field3 = ",WH:"+ String(WH); // WH is Warning Height
message.concat(field3);
String field4 = ",SH:"+ String(SH); // SH is Safe Height
message.concat(field4);
LoRaWAN.sendMsg(message);
Serial.println(message);

You might also like