This is the repo for 2nd year Embedded System Programming’s project
Created by Group 2: Kamonnun Silarat, Kai Ebina, Phongwit Srikokcharoen
The full report can be found here
This study will show the development of a smart pill dispenser using a Raspberry Pi Pico board, C programming, and a user interface to have real-time tracking and alerts. The pill dispenser consists of a dispensed wheel and its base as a dispensing device; a digital display that allows for the schedule visualization, and a cloud surveillance service for caregivers. Generally, the dispenser has auditory and real-time data synchronization with a program demonstration
- When the dispenser wheel dispenses the medicine, it will rotate at a fixed time
- Piezoelectric sensor will confirm that pills were already dispensed
- The device’s state will continue over its restarts, kept in non-volatile memory
- The LoRaWAN module has its network to communicate with the server
- The time between dispensing pills reduces to 30 seconds
The software is designed to control a system which uses motors, reads sensor data, and saves information of the system to EEPROM memory for reliable use. It works in different states, allowing smooth changes and strong performance, even when the power goes on and off. The main parts of the system start up the hardware, manage states, control motors, read and write data in EEPROM. The software operating principle includes:
- Initialization: The hardware_init.c file initializes all hardware components, such as button switches, LEDs, motor pins, optical and piezoelectric sensor, and I2C interface for the interaction with EEPROM. Additionally, GPIO pins are set up to make sure that the hardware components work effectively before entering the main program.
- State Management: The system defines states using an enumeration like ProgState: STARTUP, CALIB, PAUSE, and DISPENSE. When the software starts, the last saved state is read from EEPROM by the state_init function, and then it proceeds to start the system. The calibration data and states are stored in the EEPROM. Additionally, the program modifies the states according to sensor readings and user input.
- Motor Control: The perform_motor_step function activates the motor pins as on state, progressively to make the motor turn. The motor runs in a half-stepping way.
- Pill Dispensing: The logic has a piezoelectric sensor for pill drops, logged dispensing steps, and the actual status that is saved in EEPROM to avoid repeating errors.
- UserInteraction: The system uses interaction switches, LEDs for visual signals, and a blink function to show the status. It ensures reliable data storage through EEPROM read or write functions and error handling. The
main.cfile keeps an infinite loop for smooth transitions, including condition checks, motor control, and user input handling. - Output display: The program demonstrates the software flow, involving a microcontroller, MQTT broker, and the network. The dispenser is calibrated until 3 rounds and runs each step, and the piezoelectric sensor serves as a cursor for pills. The program writes the states and receives Lora messages for each step. Figure 2 shows the serial output from CLion which ensures Lora messages to work with hardware implementation. Figure 3 shows how the program displays MQTT communication outputs on other platforms, such as terminal when running the
loraceceive.pyfile