chathura-de-silva / Smart-Medibox

A smart device that reminds the user to take medicine on time.
MIT License
23 stars 7 forks source link
adafruit arduino cpp dht11 embedded esp32 iot medibox medicine medicine-alarm medicine-box medicine-reminder nodered smart smart-medibox

Banner

Smart Medibox

Smart medibox is a smart device that,

  1. Remind the user to take medicine at time through alarms.
  2. Help to keep medicine in the required conditions via monitoring temperature and humidity continously and notifying the user if there is a bad condition.
  3. Controlling the light entering the Medibox through a motorized curtain.

Technologies and Components

If the components change, you may have to change some parameters accordingly.

Visual Studio Code C++ Node-Red Wokwi PlatformIO Arduino

platform.ini

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
    adafruit/Adafruit GFX Library@^1.11.9
    adafruit/Adafruit SSD1306@^2.5.9
    adafruit/DHT sensor library@^1.4.6
    roboticsbrno/ServoESP32@1.0.3
    knolleary/PubSubClient@^2.8
    bblanchon/ArduinoJson@^7.0.4

Getting Started

Prerequisites

Medibox Setup

Node-Red Dashboard

Configuration and Structure

Codebase

Configuration of Wireless Accesspoint and WiFi Credentials

Hardcoded values

Configuring your Internet Accesspoint credentials

The default credentials are as follows :

SSID : Smart Medibox
Password : abcdefgh

WifiConfig

Node-Red Dashboard Flow

Node-Red Flow

ESP32 Default Pin Map

Pin Constant Device
5 BUZZER Buzzer that rings on Alarms
15 LED_1 LED which lights up on Alarms
34 PB_CANCEL Push button input which used for cancellations and to go back
25 PB_OK Push button input which is used for confirmations and entering the menu
26 PB_UP Push Button input which is used to go up in menu
35 PB_DOWN Push Button input which is used to go down in menu
4 DHT_PIN DHT11 Temperature & Humidity Sensor input
36, 39 LDR_1, LDR_2 Input pins of the two LDRs.
33 SERVO PWM Output for the Servo motor

Calculating the Light Intensity

You may configure following values in ./include/constants.h. Defaults values are as follows.

#define LINEAR_MAPPING 0
#define FINITE_INFINITY 10000

Calculating the Motor Angle

$$θ = \min{\theta{\text{offset}} \cdot D + (180 - \theta{\text{offset}}) \cdot I \cdot \gamma, 180}$$

Symbol Description
$$θ$$ Represents the output angle. Motor rotates to this position.
$$\theta_{\text{offset}}$$ Represents the minimum angle that the morot will be in. This is a constant value that influences the output angle.
$$D$$ Coificient of effect of LDR which changes the angle of rotation according the fact that which LDR records higher reading.
$$I$$ Maximum light intensity of the two LDRs.
$$\gamma$$ Controlling factor. This value scales the influence of variable "I" on the output angle.

Known issues

A Minor shortcoming : If you accidently entered the wifi configuration menu via the device menu and you don't want to change the current Wifi credentials.

Screenshot Gallery

Device Display

Gallery Image Gallery Image Gallery Image
Gallery Image Gallery Image Gallery Image
Gallery Image Gallery Image Gallery Image

Node-Red Dashboard

Gallery Image Gallery Image

About

This project was first developed as the Semester 4 Project in the Module EN2853 - Embedded Systems & Applications, UoM, CSE.

go to the top