{"slug": "full-stack-iot-activity-recognition-system-stm32-android", "title": "Full-Stack IoT Activity Recognition System (STM32 + Android)", "summary": "A developer built a full-stack IoT activity recognition system that classifies walking versus running in real time, combining STM32F407 (RT-Spark) firmware, a Python MQTT listener running a trained Random Forest model, an SQLite database behind a Flask Web API, and a Kotlin Android app that queries the API via the Volley HTTP library. Two hardware faults forced workarounds: the onboard LSM6DSL accelerometer/gyroscope returned persistent HAL_ERROR (NACK) responses across all I2C buses, so the developer added a FreeRTOS synthetic data generator mimicking walking and running waveforms, and the RW007 Wi-Fi module lacked native support for the ISM43362 driver, so a UART-to-MQTT bridge (serial_to_mqtt.py) forwards JSON from the STM32 over USB to a local Mosquitto broker. The full source code for the firmware, Python backend, and Android app is published on GitHub.", "body_md": "This project is a complete Full-Stack Internet of Things (IoT) system designed for real-time human activity recognition (Walking vs. Running). By combining embedded C programming, cloud infrastructure, Machine Learning, and Android mobile development, this system demonstrates a true end-to-end IoT pipeline.\n\nHow It Works\nThe architecture is divided into three main components:\n\n**Device Firmware:** The STM32F407 (RT-Spark) generates movement data and formats it into a JSON payload.\n\n**Cloud Backend:** A Python MQTT listener receives the data, passes it to a trained Random Forest Machine Learning model, stores the prediction in an SQLite database, and serves it via a Flask Web API.\n\n**Mobile App:** A Kotlin Android app queries the Flask API using the Volley HTTP library and displays the live prediction and historical data.\n\nDuring development, we encountered two major hardware limitations with the provided RT-Spark board that required creative engineering solutions:\n\n**Challenge 1: Sensor Unresponsiveness.** The onboard LSM6DSL accelerometer/gyroscope returned persistent `HAL_ERROR` (NACK) responses across all I2C buses.\n\n*Solution:* We verified the hardware fault using a custom bare-metal I2C diagnostic script. To ensure the pipeline could still be tested, we implemented a **synthetic data generator** in FreeRTOS that mimics realistic walking/running waveforms.\n\n- *Solution:* We verified the hardware fault using a custom bare-metal I2C diagnostic script. To ensure the pipeline could still be tested, we implemented a**synthetic data generator** in FreeRTOS that mimics realistic walking/running waveforms.\n- **Challenge 1: Sensor Unresponsiveness.** The onboard LSM6DSL accelerometer/gyroscope returned persistent`HAL_ERROR` (NACK) responses across all I2C buses.*Solution:* We verified the hardware fault using a custom bare-metal I2C diagnostic script. To ensure the pipeline could still be tested, we implemented a**synthetic data generator** in FreeRTOS that mimics realistic walking/running waveforms.\n\n**Challenge 2: Wi-Fi Incompatibility.** The board utilizes an RW007 Wi-Fi module, which lacks native support for the ISM43362 driver required by the lab.\n\n*Solution:* We developed a custom **UART-to-MQTT bridge**. The STM32 sends JSON data via USB, and a Python script (`serial_to_mqtt.py`) acts as a gateway, publishing the data to the local Mosquitto broker.\n\n- *Solution:* We developed a custom**UART-to-MQTT bridge** . The STM32 sends JSON data via USB, and a Python script (`serial_to_mqtt.py` ) acts as a gateway, publishing the data to the local Mosquitto broker.\n- **Challenge 2: Wi-Fi Incompatibility.** The board utilizes an RW007 Wi-Fi module, which lacks native support for the ISM43362 driver required by the lab.*Solution:* We developed a custom**UART-to-MQTT bridge** . The STM32 sends JSON data via USB, and a Python script (`serial_to_mqtt.py` ) acts as a gateway, publishing the data to the local Mosquitto broker.\n\nThe full source code, including the firmware, Python backend, and Android app, is available on GitHub.\n\n*(You can include the flowchart image we made here)*\n\n**Backend:** Run `app.py` (Flask API) and `mqtt_listener.py` (ML Classifier).\n\n**Bridge:** Flash the STM32 and run `serial_to_mqtt.py` to forward data.\n\n**App:** Build and run the Android app in an emulator to see the live predictions.\n\n[Read more](<javascript:void(0)>)", "url": "https://wpnews.pro/news/full-stack-iot-activity-recognition-system-stm32-android", "canonical_source": "https://www.hackster.io/the-moklors/full-stack-iot-activity-recognition-system-stm32-android-ac667e", "published_at": "2026-11-08 05:49:37+00:00", "updated_at": "2026-11-09 01:37:29.037871+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "ai-tools", "developer-tools"], "entities": ["STM32F407", "RT-Spark", "LSM6DSL", "RW007", "ISM43362", "Mosquitto", "Flask", "GitHub"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/full-stack-iot-activity-recognition-system-stm32-android", "markdown": "https://wpnews.pro/news/full-stack-iot-activity-recognition-system-stm32-android.md", "text": "https://wpnews.pro/news/full-stack-iot-activity-recognition-system-stm32-android.txt", "jsonld": "https://wpnews.pro/news/full-stack-iot-activity-recognition-system-stm32-android.jsonld"}}