A Real-Time IoT Wellness Monitor

Emogotchi is a closed-loop system designed to combat student burnout. By fusing physiological data with environmental sensors, we utilize cloud-based LSTM neural networks to predict stress and actively improve the user's environment.

2 ESP32 Nodes
96% Uptime Target
<200ms Latency
💓

Physiology

BPM & Motion

🌡️

Environment

Noise, Light, Temp

🧠

AI Core

LSTM Model

🏠

Actuation

Automated Home

System Architecture: The Closed Loop

The system operates on a Publish/Subscribe model using MQTT. Data flows from the Edge (Sensors) to the Cloud (Processing) and back to the Edge (Feedback/Actuation), ensuring real-time responsiveness.

Node 1: Emogotchi

  • • ESP32 (Dual Core)
  • • Sensors: Pulse, DHT11, MPU6050, Sound, LDR
  • • Feedback: OLED, RGB LED
Topic: esp32/sensor_data

DigitalOcean Cloud

  • • Mosquitto MQTT Broker
  • • Python Flask Server
  • LSTM Model Inference
  • • Telegram Bot Integration
Process: Data → Score

Node 2: Smart Hub

  • • ESP32 Actuator
  • • Servos (Window/Door)
  • • Auto-Trigger on "Sad"
Topic: esp32/prediction

Firmware Engineering: FreeRTOS & Concurrency

A key technical achievement is the implementation of FreeRTOS. A traditional "Super Loop" would fail to handle the 50ms sampling rate of the pulse sensor alongside blocking Wi-Fi operations. We utilized Core Pinning and Mutexes to ensure stability.

Core 1: Sensor Logic

Dedicates high-priority processing to `Task_HeartRate` (50ms) and `Task_Sound`, ensuring no data loss during sampling.

Core 0: Networking

Offloads heavy `Task_UploadData` and `Task_MQTT_Loop` to the secondary core, preventing Wi-Fi lag from freezing the UI.

Mutex Synchronization

Solved critical race conditions on the shared ADC (Analog-to-Digital Converter) and I2C bus using `adcMutex` and `i2cMutex`.

CPU Core Utilization Strategy

Distribution of RTOS tasks across physical ESP32 cores.

Cloud Intelligence: LSTM Model

User stress is cumulative, not instantaneous. To capture this temporal dependency, we moved beyond simple Random Forest classifiers and implemented a Long Short-Term Memory (LSTM) neural network.

  • Input: Sequence of 10 timestamps (5-minute window).
  • Features: BPM, Noise, Temp, Humidity, Motion, Light.
  • Output: "Happiness Score" (0.0 - 100.0).
  • Action: Scores < 34 trigger "Sad" state and Telegram alerts.

Model Feature Importance

Experimental Evaluation & Results

Communication Latency

Transitioning from HTTP Polling to MQTT Push significantly reduced command latency.

Power Management

Using FreeRTOS `vTaskDelay` allows the CPU to sleep between sensor ticks.

~20 Hours
Estimated Runtime (2000mAh)
Based on average draw of 100mA (Active + Sleep blend).

Scenario: High Stress Detected

🔊
Noise > 80dB
Edge Sensor
📉
Score < 34
Cloud LSTM
🪟
Open Window
Smart Hub Actuation
📱
Alert User
Telegram Bot