Main Content

IoT: Internet of Tunnel using RiotOS and ESP32

IoT project consisting in a smart tunnel prototype. The system uses an ESP32 board, RiotOS, AWS and various sensors and actuators

Brief description
Internet Of Tunnel project is a Monitoring System solution designed to monitor and maintain the air quality and lighting conditions inside a tunnel.With this project, we aim to improve the air quality and light levels inside the tunnel, in order to improve safety and healthiness for gallery users, both for pedestrians and vehicles, while also prioritizing energy efficiency.As part of our objectives, we are committed to reducing the overall system energy consumption, thereby promoting sustainability and minimizing environmental impact.

Existing approaches
Traditional car tunnels often use conventional lighting systems which is usually implemented by LED or light bulbs. These systems typically lack a built-in capability to detect failures, such as a broken LED or light bulb. This absence of detection poses a significant concern for tunnel operators and maintenance teams. Without a way to automatically identify faulty lights, it becomes challenging to address them promptly. A single broken light or LED might seem insignificant, but it can compromise safety and visibility for drivers, especially in long tunnels.

Moving on to air conditioning, tunnels face the challenge of maintaining a comfortable environment despite high emissions of harmful gases and limited ventilation. To address this problem, car tunnels utilize fans and air conditioning systems. However, in many cases, the air conditioning systems are designed to remain operational continuously, regardless of the air quality conditions within the tunnel so they often operate at a constant level without modulation based on air quality.

Hardware components
We came up with an IOT solution, developed using an ESP32 board for managing the sensors and actuators and RIOT os as the software operating system.

Our solution is a Monitoring and Controlling System composed by a ventilation and a lightening apparatus designed to automatically manage and monitor the air quality and lighting conditions in a car gallery. To use the system, an operator simply needs to install the IoT sensors in the car gallery and connect them to the system’s hub. Once the sensors are connected, they will begin collecting data on the air quality and lighting levels in the gallery. Based on the data collected, the system will automatically manage the air conditioning system to maintain optimal conditions inside the gallery. Moreover, it will be capable of promptly detect anomalies in the lightening apparatus and quickly inform the technicians.In addition, the data collected by the sensors will be tracked and transmitted to a remote server, where they will be accessible for remote monitoring.

We used some LEDs to create the lightning system and two DC motors on which we attached a fan to recreate the air conditioning system. We also used light and air quality sensors to monitor the current state of the air quality and light conditions.

Cardboard tunnel prototype
The proper functioning of the system depends on several complex technical aspects to be taken into account. In this section, we would like to address these issues in a real case scenario, describing the solutions and adaptations made to create the prototype.

We tried to design a prototype that reflects in a reasonable way a real case scenario, by making feasible estimations and assumptions in relation to the equipment at our disposal. The dimensions of the cardboard used to simulate the tunnel are 50cm x 40cm x 80cm, resulting in a total air volume of 0.18m³.

The cardboard prototype has been divided in two different section for demonstration purposes, the left side is completely dedicated to the illumination system while the right one to the air quality monitoring aspect.

The connections have been made on top of the tunnel, by making use of two different breadboards, one for the following components: four sensors, the esp32 board and the two motors to which we connected the fans. The other one is used only to power up the six different lights. The two breadboards are powered up by two 9V chargers which will be reduced to 3.3V by the power module connected to them. This has been done because the use of a simple 3.3 or 5V adapter wasn’t able to power everything at the desired voltage. The ESP32 board is powered up by a standard powerbank. Thanks to the use of two transistors we have been able to use the PWM in order to module the output voltage of the dc motors, in this way we were able to run the fans at three different speeds.

Illumination system (Left side)
The 6 light bulbs are inserted inside 6 equidistant holes made on the top left side of the tunnel in order to have a uniform illumination along the whole length of the gallery.

The two light sensor are strategically placed on the left side wall of the cardboard. This placement is due to the fact that a different position of the sensors such as on the bottom part may have had lots of problems regarding the passage of vehicles under the tunnel.

The vehicle lights in fact can led to a false measurement of the sensors which could have detected a high light level under the tunnel even if there was a fault in the light system. The optimal placement is resulted to be at 2/3 of the total height of the tunnel, in this way we can have a proper measurement of the illumination system value without the interference of the car lights.

Air quality monitoring system (Right side)
Based on the European standard mentioned earlier, the gases considered harmful to human health require a minimum exposure time of 15 minutes to pose a risk.We define 3 threshold of gas concentration as follows:

- No risk treshold: the gas concentrations are below the potentially harmful values for humans. Fan sistem is switched off.
- Min risk treshold: the gas concentrations are slightly above the potentially harmful values for humans. Fan sistem is switched on at 1/3 of maximum speed.
- Mid risk treshold: the gas concentrations are moderately above the potentially harmful values for humans. Fan sistem is switched on at 2/3 of maximum speed.
- High risk treshold: the gas concentrations are moderately above the potentially harmful values for humans. Fan sistem is switched on at maximum speed.

Network diagram
As shown in the diagram the connection consists essentially in two parts: one from the ESP32 board to AWS and one from AWS to the web dashboard of the project. The services used in this process are the following:

Mosquitto, IotCore, DynamoDB, Lambda, IAM, API Gateway and Amplify.

In particular we have the esp32 running RiotOS firmware connected via WiFi to Mosquitto, which is an MQTT broker, which will act as the publisher. Then the data published by the board on the topic will be forwarded from Mosquitto to the AWS cloud thanks to a python transparent bridge.

Thanks to AWS IoT core then the arriving data will be sent and split into different columns of a DynamoDB table. These data will be retrieved by two python Lambda functions which needs to be authorized by Identity Access Manager (IAM). One function will retrieve for us the last 30 values and the other one only the last inserted into the DB. Finally using API gateway we can have a connection which goes from AWS to the web dashboard that will be hosted using AWS amplify.”

Link to article