Posts

Week14

Image
Week 14 Progress: Data Analysis and Final Testing Improvements Objective: The primary goal of Week 14 was to complete a comprehensive round of performance tests on the ankle monitoring system and to conduct a thorough analysis of the collected sensor data. Emphasis was placed on evaluating the system’s ability to detect swelling through trend analysis, as well as verifying the accuracy of filtering techniques in eliminating short-term noise. Alongside empirical testing, the effectiveness of the core embedded logic written in C++ was further validated. Implementation: A key element of the test was real-time monitoring of ADC (Analog-to-Digital Converter) output values from the flex sensor under simulated swelling conditions. The image below shows the plotted  sampled ADC values  and their corresponding  filtered values  (exponentially smoothed): From this graph, we can observe two trends: The  blue line  shows raw sampled data, which fluctuates significantly...

Week13

Image
Week 13 Progress: Testing Strategy Design and Simulation Objective: This week’s objective was to investigate the physiological significance of ankle swelling as a symptom of heart failure and to design a testing methodology that simulates this condition using available tools. The aim was to assess whether the current smart sock prototype could reliably detect early signs of edema through the flex sensor readings and trend detection algorithm implemented in previous weeks. Implementation: To begin with, a thorough background study was conducted on the clinical causes and relevance of ankle swelling, or  peripheral edema , especially in heart failure patients: According to the UK’s NHS website,  oedema  occurs when excess fluid builds up in body tissues, often affecting the ankles and feet. It’s particularly common among elderly or sedentary individuals and can be a sign of more serious conditions like  heart failure  or kidney problems【NHS†source】. HeartFailureMa...

Week12

Image
Week 12 Progress: BLE Control, Reset Commands, and Exporting Graphs Objective: To finalize app interaction logic by adding BLE-based command sending (RESET), exporting chart visuals to the gallery, and refining the feedback interface. Implementation: This week focused on expanding interactivity, BLE write operations, and implementing advanced features such as exporting graph images. These additions greatly enhanced the app’s practicality and user-friendliness. Reset Command via BLE Write: The reset function allows users to instruct the microcontroller to restart all monitoring. The code sends a  "RESET"  string to a writable BLE characteristic ( 19B10003... ) using: commandCharacteristic.value = "RESET".toByteArray() gatt.writeCharacteristic(commandCharacteristic) dataList.clear() This command clears chart history and resets backend data processing, with confirmation shown via a  Toast . Image Export of Chart View: A bitmap of the chart is captured from the Compose ...

Week11

Image
Week 11 Progress: Building the App Interface and State Management Objective: To design and implement the primary interface for the smart sock Android application using Jetpack Compose. This included setting up the BLE device list screen, live data display components, and the infrastructure for real-time state management. Implementation: During this week, focus was placed on two major components: the connection logic in  MainActivity.kt  and the UI construction within  ConnectedDeviceScreen.kt . The goal was to build a responsive, functional layout that could reflect live BLE data and display relevant health status indicators. Connection Flow and UI Switching: A reactive architecture was adopted using  mutableStateOf  variables such as  isConnected ,  connectedDeviceData , and  alarmStatusState . These were used to dynamically swap between the scanning screen and the connected device screen: setContent {     if (isConnected) {   ...

Week10

Image
Week 10 Progress: Exponential Moving Average and Trend Detection Objective To apply signal processing techniques to smooth ADC data and detect abnormal trends that may suggest ankle swelling. The techniques include: Short-term smoothing using EMA (Exponential Moving Average) Long-term trend detection by evaluating the slope of consecutive filtered values What is EMA? The Exponential Moving Average is a recursive smoothing filter calculated by: E M A t = α ⋅ X t + ( 1 − α ) ⋅ E M A t − 1​ Where: X t X_{t} X t ​ is the current data point α \alpha α is the smoothing constant (0 < α < 1) A lower α means stronger smoothing but slower response. Implementation Details 1. Short-Term EMA (Real-Time Filtering) Applied on 200 averaged samples every 2 seconds. Removes noise from breathing, minor twitches, or slight sensor jitter. 2. Long-Term EMA (Trend Filter) Samples are further passed through another EMA with a lower alpha (0.1) for trend detection . Trend D...

Week9

Image
Week 9 Progress: State Machine Design and System Modularity Objective To modularize the ankle monitoring code by implementing a two-state state machine (MOVING / STATIONARY) to detect whether the user is currently in motion or in a stable position for trend detection. The goal is to trigger alarm conditions only when reliable stationary measurements are available. Implementation: State Machine Architecture The firmware now uses a simple finite state machine (FSM) with two primary states: MOVING : The user is moving, sensor data fluctuates significantly, and trend evaluation is temporarily disabled. STATIONARY : The user is still. Trend data is collected to determine if ankle swelling is occurring. 📌 Transition Logic: Transition from MOVING → STATIONARY happens when sensor variation over a defined window is small (low deviation). Transition from STATIONARY → MOVING happens when at least 3 significantly different readings appear within the window (indicating movement or p...

Week8

Image
Week 8 Progress: BLE Android App Development and Testing Objective: To implement and test the BLE (Bluetooth Low Energy) communication feature on the Android mobile application, enabling real-time reception of status, alarm, and ADC data from the ankle-worn hardware device. BLE Communication Principle (Android BLE Overview): BLE is a wireless protocol designed for short-range, low-power communication. It works via a client-server model, where: Peripheral (Server) : The ankle-worn device (XIAO nRF52840), advertises services and characteristics. Central (Client) : The Android phone scans for nearby BLE devices, connects to a chosen peripheral, and subscribes to its characteristics. On Android, the workflow is as follows: Scan for nearby devices using BluetoothLeScanner . Connect to a selected device using connectGatt() . Discover Services to identify the available UUIDs. Enable Notifications for a given characteristic via descriptor 0x2902 . Receive Upd...