Skip to content

chathura-de-silva/Smart-Medibox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Technologies and Components

  • This project is developed to use
    • ADAFRUIT SSD 1306 OLED Monochrome Display (128x64)
    • ESP32 Devkit V1
    • DHT11 Temperature and Humidity Sensor. (Easily configurable for DHT22 aswell.)

out of the box. If the components change, you may have to change the parameters accordingly.

Visual Studio Code C++ 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
  • This was developed using Platform IO with Arduino Framework. (You can use the code in branch Wokwi, if you are looking forward for a simulation.)

Getting Started

Prerequisites

  • Git
  • Platform I/O with Arduino Framework Set up.
  • Relavant hardware for testing if you are not intended to do simulations.


  • Clone the repository.
    git clone https://github.com/chathura-de-silva/Smart-Medibox     

Important

If you are willing to simulate the project using Wokwi extension, then clone the relavant branch using this, instead. (Or you can switch branches later.)

 git clone -b Wokwi https://github.com/chathura-de-silva/Smart-Medibox     
  • Typically platform I/O will install required libraries itself. If not you have to install them referring the platform.ini file displayed above.

  • Compile and Upload/Simulate.

Configuration and Structure

  • Three seperate header files inside ./include directory :

    • Constants.h : Contains all constants.
    • Functions.h : Contains declarations of all global functions.
    • Globals.h : Contains declarations of all the global constants.
  • The initialisation and definitions of variables and functions are done in the relavant .cpp files.

  • main.cpp contains the arduino loop() and setup() functions.

  • The device code is developed in such a way that it's actively listening(polling) for user inputs and for collecting sensor data from the DHT sensor.

  • For an instance the three function calls in loop() function is responsible for,

    1. update_time_with_check_alarm() - Updates the the time on the display. Checks whether there are any alarms to be rung at the moment. Calls ring_alarm() inside it if there is any.

    2. go_to_menu() - Activelly listening for button presses and then keeps track of the selected mode by user via an abstract variable. When user confirms a menu item via pressing OK button, the run_mode(mode) is called. run_mode(mode) handles the rest via somr another nested function calls.

    3. check_temp() - Reads the data from the DHT11 sensor, prints a warning in the display if there is any parameter that is out of the specified limits. If there isn't any, plays an animation on the screen indicating it is actively monitoring those parameters.

Known issues

Current implementation doesn't retain the user data in the non-volatile memory of the MCU. This is because there is a issue/bug that makes accessing such saved data early after device boot up fail. Probably because when it comes to the built-in library: preferences.h, it needs some time to fetch data after initialising and opening a namespace. It seems to be running on a dedicated core, parallely.

Screenshot Gallery

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

About

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