This project, ESP32 Medibox, is a smart medicine box designed to assist individuals in managing their medication schedules effectively. The system utilizes an ESP32 microcontroller to control various components, including sensors, actuators, and communication modules, to provide a comprehensive solution for medication management.
Developed with the software and tools below.
The complete circuit diagram and simulation can be found on Wokwi.
- WiFi Connectivity: Connects to WiFi for remote monitoring and control via MQTT.
- Temperature and Humidity Monitoring: Measures environmental conditions using the DHT22 sensor.
- Light Intensity Measurement: Uses LDRs to detect ambient light intensity and adjust the servo motor accordingly.
- Servo Motor Control: Adjusts the position of a shaded sliding window based on light intensity.
- Buzzer Notifications: Provides audio alerts for scheduled medication times.
- Button Interface: Includes buttons for user interaction, such as canceling alarms or confirming actions.
- Customizable Settings: Adjustable minimum angle and control factor for servo motor via MQTT.
- ESP32: The main microcontroller used in this project.
- DHT22: Temperature and humidity sensor.
- LDRs: Light-dependent resistors for measuring light intensity.
- Servo Motor: For adjusting the position of the shaded window.
- Buzzer: For audio notifications.
- Buttons: For user interaction.
The ESP32 Medibox is designed to help users manage their medication by providing various features:
- Monitoring: Continuously monitors temperature, humidity, and light intensity.
- Notifications: Provides scheduled notifications through a buzzer to remind the user to take their medication.
- Remote Control: Allows remote monitoring and adjustment of settings via MQTT.
The system is flexible, allowing for the customization of parameters such as the servo motor's minimum angle and controlling factor.
The Node-RED flow for this project is available in the node-red-flow.json
file. You can import this flow into your Node-RED instance to interact with the ESP32 Medibox via MQTT.
To visualize and control your ESP32 project using Node-RED, follow these steps:
-
Install Node-RED:
- If Node.js is not installed on your machine, install it first.
- Open a terminal and run the following command to install Node-RED:
npm install -g --unsafe-perm node-red
-
Start Node-RED:
- Run the following command in your terminal to start Node-RED:
node-red
- Node-RED will start and can be accessed via a web browser at http://localhost:1880.
- Run the following command in your terminal to start Node-RED:
-
Create and Deploy Flows:
- Use the Node-RED interface to create flows that interact with your ESP32.
- Deploy your flows and visualize data or control components from your web browser.
With Node-RED, you can create sophisticated dashboards and control mechanisms, enhancing the interactivity and functionality of your ESP32 project.
The following MQTT topics are used in this project:
- MQTT-ON-OFF: To control the buzzer (ON/OFF).
- MQTT-SCH-ON: To manage the schedule for buzzer notifications.
- MQTT-TEMP: To receive temperature readings.
- MQTT-LDR: To receive light intensity data.
- MQTT-MIN-ANG: To set the minimum angle of the servo motor.
- MQTT-CTRL-FAC: To set the controlling factor for the servo motor.
- MQTT-DROP-DOWN: To select predefined settings for the servo motor.
To get started with the ESP32 Medibox:
-
Clone the Repository: Clone this repository to your local machine using the following command:
git clone https://github.com/Gayanukaa/ESP32-Medibox.git
-
Open the Project: Navigate to the project directory:
cd ESP32-Medibox
-
Install Dependencies: Ensure you have the necessary libraries installed. If you are using the Arduino IDE, install the following libraries via the Library Manager:
- WiFi
- PubSubClient
- DHTesp
- ESP32Servo
- ArduinoJson
If you are using PlatformIO, the required libraries are specified in the
platformio.ini
file and will be installed automatically during the build process. -
Configure WiFi and MQTT: Modify the
setupWifi()
andsetupMqtt()
functions in the code to include your WiFi credentials and MQTT broker details. -
Upload the Code: Connect your ESP32 to your computer and upload the code using the Arduino IDE or PlatformIO.
This is a PlatformIO project. To build it, install PlatformIO, and then run the following command:
pio run
This command compiles the code and prepares it for uploading to the ESP32.
To simulate this project, install Wokwi for VS Code. Open the project directory in Visual Studio Code, then:
- Press F1 and select "Wokwi: Start Simulator".
- The simulation environment will launch within VS Code, and you can interact with the simulated components.
- To interact with the simulated HTTP server, open your web browser and navigate to http://localhost:8180.
Wokwi allows you to test the functionality of your project without needing the physical hardware, making it easier to debug and validate your code.
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature/your-feature-name
- Submit a pull request.
This project is licensed under the MIT License.
If you have any questions or suggestions, please feel free to reach out to us at gayanukaamarasuriya@gmail.com.