Abhinav Dhakal

change to light
← Back to Home
$ cat ~/projects/smart-cane/README.md

Smart Cane with Warnings and Weather Alerts

Smart cane project thumbnail
Smart cane main system thumbnail
GPIO WiFi I²S HC-SR04 ultrasonic 0.8 m Weather API WiFi · REST ESP32 · FreeRTOS core 1 · sensing loop flags shared state mutex core 0 · network task Speaker TTS · I²S

Class group project for an intelligent cane system that combines ultrasonic sensing, weather alerts, and audio feedback. My work covered WiFi connectivity, API integration, text-to-speech playback, and the full FreeRTOS restructure that made the integrated system actually stable.

My Contribution

The Integration Problem

Each module worked fine in isolation. Once we integrated everything: sensor reads, API polling, TTS playback: the system became unreliable. Sensor updates were delayed, alerts misfired, and behavior was inconsistent under any real processing load. The single-loop architecture meant every operation was blocking everything else.

I isolated the timing of each component to figure out where delays were accumulating. The issue wasn't in any individual module: it was the architecture. Putting everything sequentially in loop() meant a slow API call would starve the sensor, and a TTS output would block the whole system.

FreeRTOS Restructure

I split the work by how long each part can block, and gave each half its own core:

The two sides share a mutex-protected weather struct and a few flags (button press, speaking, warning active), and spoken phrases wait in a FreeRTOS queue until the player is free. After the split, sensor readings stayed consistent while the cane was fetching or speaking, and the system ran stably through extended testing. A new feature now just means deciding which side it belongs on.

Process Diagrams

Full smart cane team process diagram
Full team process diagram
Smart cane subsystem process diagram
My subsystem process diagram

Source Code

View the firmware source (.ino)

Tech Stack

ESP32, FreeRTOS, C, WiFi, Ultrasonic Sensing, Google Translate API, Weather API, Text-to-Speech