This project aims to implement IoT to condition a container used for transporting medicines. It seeks to incorporate 5 sensors and 5 actuators that will monitor the container in real-time. These sensors and actuators are controlled using Node MCU 8266 modules. The monitoring data collected is sent to a MySQL-hosted database through an API developed with Node.js.
The data stored in the SQL database is then visualized in a Power BI dashboard. This dashboard integrates AI-driven features for consulting statistical insights, enabling a deeper understanding of the monitored data and enhancing decision-making processes.
- CO2 Sensor (MQ135)
- Humidity Sensor (DHT11)
- Temperature Sensor (DHT11)
- Motion Sensor (PIR)
- Distance Sensor (HC-SR04)
- Solenoid Valve (110 V AC)
- Dual-Channel Relay
- 4 LEDs
The actuators are programmed to perform specific actions when irregular readings are detected.
With this implementation, the project aims to expand transportation options for pharmaceutical and other high-value product supply chains that require specific travel conditions. This solution can help reduce costs by avoiding the need to transport products by air, enabling the transportation of conditioned containers in cargo ship freight.
- Install MySQL
- Have Node.js and npm installed
- Clone this repository using the following command:
git clone https://github.com/HumbertoBM2/IoT-Medicine-Container-Optimization
-
Once the repository is cloned, navigate to the created directory using your terminal and go inside
API_codes
. Please note that thenode_modules
directory will be empty and will be populated automatically once the project is initialized with Node.js and the necessary dependencies are added. -
Initialize the project with the following command:
npm init
Configure the options according to your needs. For casual use, you can skip the configuration by pressing "Enter."
- Install the necessary dependencies with the following commands:
npm install express
npm install cors
npm install mysql2
npm install body-parser
npm install -g nodemon
-
After following the above steps, the
node_modules
directory should be populated with the necessary content. -
Before starting the API, you need to create the database where the readings will be stored. To do this, run the SQL script from the repository called
SQL_Script_For_The_DB.sql
using MySQL Workbench or DBeaver. -
Once the database is ready, return to the project directory using the terminal and start the API with the following command:
node app.js
- The API should start without any issues. You can now verify its functionality by accessing any of the 33 available endpoints using Postman or a web browser (Firefox is recommended).
- Have a minimum of 1 NodeMCU8266 module (preferably 5).
- Acquire the sensors and actuators mentioned earlier.
- Install Arduino IDE.
- Install the NodeMCU8266 board driver.
- Install the necessary libraries:
ArduinoJson.h
,MQ135.h
,DHT.h
, and the internet connection libraries that come with the NodeMCU8266 driver (ESP8266WiFi.h
andESP8266HTTPClient.h
). - Ensure access to a Wi-Fi network that your computer hosting the API and the NodeMCU8266 modules can connect to.
- Set up the necessary circuits to connect the NodeMCU8266 module(s), sensors, and actuators. Document the pins used for each component.
- Open the 5
.ino
files from the repository and adjust the pin configurations in each code according to your setup. - In each
.ino
file, specify the SSID and password of the Wi-Fi network that the modules will connect to (it should be the same network as the one your computer hosting the API is connected to). - Obtain the IPv4 address of your computer by running the following command in the terminal:
ipconfig
- Replace the IP address in all the endpoints within the 5 code files.
- Ensure that the IDs to which each reading will be sent are appropriate for your needs, although you can leave the default values if they suffice.
- Upload the code to the NodeMCU8266 modules.
- Open the serial monitor and observe how POST requests are generated as the environment is read.
- Confirm that the data is being loaded into the database by using one of the GET endpoints.
You are now ready to set up and use the NodeMCU8266 modules in conjunction with the IoT solution.