{"id":537,"date":"2025-12-10T16:46:55","date_gmt":"2025-12-10T16:46:55","guid":{"rendered":"https:\/\/portfolio.wcu.edu\/asmamane1\/?p=537"},"modified":"2025-12-10T16:46:55","modified_gmt":"2025-12-10T16:46:55","slug":"building-the-web-a-gotchi-a-dual-microcontroller-digital-pet-system","status":"publish","type":"post","link":"https:\/\/portfolio.wcu.edu\/asmamane1\/2025\/12\/10\/building-the-web-a-gotchi-a-dual-microcontroller-digital-pet-system\/","title":{"rendered":"Building the Web-a-gotchi: A Dual-Microcontroller Digital Pet System"},"content":{"rendered":"<p data-start=\"258\" data-end=\"605\">For my final project, I created the Web-a-gotchi, an embedded digital pet system inspired by classic Tamagotchi devices but redesigned for modern hardware. The system uses an STM32 microcontroller to manage the core pet logic and an ESP32 to provide a wireless, browser-based interface that allows interaction from any phone or laptop.<\/p>\n<p data-start=\"607\" data-end=\"767\">This project allowed me to combine embedded systems, microcontroller communication, real-time design, and Wi-Fi user interfaces into a single cohesive platform.<\/p>\n<h2 data-start=\"774\" data-end=\"797\"><strong data-start=\"777\" data-end=\"797\">Project Overview<\/strong><\/h2>\n<p data-start=\"799\" data-end=\"870\">The Web-a-gotchi is powered by two tightly integrated microcontrollers:<\/p>\n<h3 data-start=\"872\" data-end=\"906\"><strong data-start=\"876\" data-end=\"906\">STM32 (Primary Controller)<\/strong><\/h3>\n<ul data-start=\"907\" data-end=\"1199\">\n<li data-start=\"907\" data-end=\"997\">\n<p data-start=\"909\" data-end=\"945\">Manages all pet state variables:<\/p>\n<ul data-start=\"948\" data-end=\"997\">\n<li data-start=\"948\" data-end=\"958\">\n<p data-start=\"950\" data-end=\"958\">Hunger<\/p>\n<\/li>\n<li data-start=\"961\" data-end=\"976\">\n<p data-start=\"963\" data-end=\"976\">Cleanliness<\/p>\n<\/li>\n<li data-start=\"979\" data-end=\"997\">\n<p data-start=\"981\" data-end=\"997\">Love\/Happiness<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li data-start=\"998\" data-end=\"1036\">\n<p data-start=\"1000\" data-end=\"1036\">Performs time-based stat decay<\/p>\n<\/li>\n<li data-start=\"1037\" data-end=\"1071\">\n<p data-start=\"1039\" data-end=\"1071\">Reacts to physical buttons<\/p>\n<\/li>\n<li data-start=\"1072\" data-end=\"1103\">\n<p data-start=\"1074\" data-end=\"1103\">Drives the OLED display<\/p>\n<\/li>\n<li data-start=\"1104\" data-end=\"1157\">\n<p data-start=\"1106\" data-end=\"1157\">Implements the pet\u2019s mood and lifecycle logic<\/p>\n<\/li>\n<li data-start=\"1158\" data-end=\"1199\">\n<p data-start=\"1160\" data-end=\"1199\">Sends stat data to the ESP32 via UART<\/p>\n<\/li>\n<\/ul>\n<h3 data-start=\"1201\" data-end=\"1238\"><strong data-start=\"1205\" data-end=\"1238\">ESP32 (Wi-Fi Server + Web UI)<\/strong><\/h3>\n<ul data-start=\"1239\" data-end=\"1536\">\n<li data-start=\"1239\" data-end=\"1298\">\n<p data-start=\"1241\" data-end=\"1298\">Runs in AP mode, broadcasting its own Wi-Fi network<\/p>\n<\/li>\n<li data-start=\"1299\" data-end=\"1475\">\n<p data-start=\"1301\" data-end=\"1342\">Hosts a live, responsive Web UI with:<\/p>\n<ul data-start=\"1345\" data-end=\"1475\">\n<li data-start=\"1345\" data-end=\"1374\">\n<p data-start=\"1347\" data-end=\"1374\">Animated SVG pet graphics<\/p>\n<\/li>\n<li data-start=\"1377\" data-end=\"1404\">\n<p data-start=\"1379\" data-end=\"1404\">Real-time progress bars<\/p>\n<\/li>\n<li data-start=\"1407\" data-end=\"1428\">\n<p data-start=\"1409\" data-end=\"1428\">Mood descriptions<\/p>\n<\/li>\n<li data-start=\"1431\" data-end=\"1475\">\n<p data-start=\"1433\" data-end=\"1475\">Buttons to feed, play, and clean the pet<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li data-start=\"1476\" data-end=\"1536\">\n<p data-start=\"1478\" data-end=\"1536\">Communicates with the STM32 using a simple UART protocol<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"1538\" data-end=\"1651\">This two-microcontroller system allows the Web-a-gotchi to be interactive both physically and wirelessly.<\/p>\n<h2 data-start=\"1658\" data-end=\"1684\"><strong data-start=\"1661\" data-end=\"1684\">System Architecture<\/strong><\/h2>\n<h3 data-start=\"1686\" data-end=\"1713\"><strong data-start=\"1690\" data-end=\"1713\">Hardware Components<\/strong><\/h3>\n<ul data-start=\"1714\" data-end=\"1903\">\n<li data-start=\"1714\" data-end=\"1736\">\n<p data-start=\"1716\" data-end=\"1736\">STM32 Nucleo board<\/p>\n<\/li>\n<li data-start=\"1737\" data-end=\"1757\">\n<p data-start=\"1739\" data-end=\"1757\">ESP32 Dev Module<\/p>\n<\/li>\n<li data-start=\"1758\" data-end=\"1787\">\n<p data-start=\"1760\" data-end=\"1787\">SSD1306 128\u00d764 OLED (I2C)<\/p>\n<\/li>\n<li data-start=\"1788\" data-end=\"1815\">\n<p data-start=\"1790\" data-end=\"1815\">Three momentary buttons<\/p>\n<\/li>\n<li data-start=\"1816\" data-end=\"1850\">\n<p data-start=\"1818\" data-end=\"1850\">USB power and serial debugging<\/p>\n<\/li>\n<li data-start=\"1851\" data-end=\"1903\">\n<p data-start=\"1853\" data-end=\"1903\">UART communication cable between STM32 and ESP32<\/p>\n<\/li>\n<\/ul>\n<h3><strong>Schematic Diagram<\/strong><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-538\" src=\"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-content\/uploads\/sites\/1875\/2025\/12\/Screenshot-2025-12-10-114115-300x225.png\" alt=\"\" width=\"300\" height=\"225\" \/><\/p>\n<h3 data-start=\"1905\" data-end=\"1940\"><strong data-start=\"1909\" data-end=\"1940\">UART Communication Protocol<\/strong><\/h3>\n<div class=\"TyagGW_tableContainer\">\n<div class=\"group TyagGW_tableWrapper flex w-fit flex-col-reverse\" tabindex=\"-1\">\n<table class=\"w-fit min-w-(--thread-content-width)\" data-start=\"1942\" data-end=\"2244\">\n<thead data-start=\"1942\" data-end=\"1983\">\n<tr data-start=\"1942\" data-end=\"1983\">\n<th data-start=\"1942\" data-end=\"1954\" data-col-size=\"sm\">Direction<\/th>\n<th data-start=\"1954\" data-end=\"1972\" data-col-size=\"sm\">Message Example<\/th>\n<th data-start=\"1972\" data-end=\"1983\" data-col-size=\"sm\">Meaning<\/th>\n<\/tr>\n<\/thead>\n<tbody data-start=\"2026\" data-end=\"2244\">\n<tr data-start=\"2026\" data-end=\"2085\">\n<td data-start=\"2026\" data-end=\"2042\" data-col-size=\"sm\">STM32 \u2192 ESP32<\/td>\n<td data-col-size=\"sm\" data-start=\"2042\" data-end=\"2055\"><code data-start=\"2044\" data-end=\"2054\">85,92,70<\/code><\/td>\n<td data-col-size=\"sm\" data-start=\"2055\" data-end=\"2085\">Hunger, Clean, Love values<\/td>\n<\/tr>\n<tr data-start=\"2086\" data-end=\"2127\">\n<td data-start=\"2086\" data-end=\"2102\" data-col-size=\"sm\">STM32 \u2192 ESP32<\/td>\n<td data-col-size=\"sm\" data-start=\"2102\" data-end=\"2111\"><code data-start=\"2104\" data-end=\"2110\">DEAD<\/code><\/td>\n<td data-col-size=\"sm\" data-start=\"2111\" data-end=\"2127\">Pet has died<\/td>\n<\/tr>\n<tr data-start=\"2128\" data-end=\"2164\">\n<td data-start=\"2128\" data-end=\"2144\" data-col-size=\"sm\">ESP32 \u2192 STM32<\/td>\n<td data-start=\"2144\" data-end=\"2152\" data-col-size=\"sm\"><code data-start=\"2146\" data-end=\"2151\">'F'<\/code><\/td>\n<td data-col-size=\"sm\" data-start=\"2152\" data-end=\"2164\">Feed pet<\/td>\n<\/tr>\n<tr data-start=\"2165\" data-end=\"2206\">\n<td data-start=\"2165\" data-end=\"2181\" data-col-size=\"sm\">ESP32 \u2192 STM32<\/td>\n<td data-col-size=\"sm\" data-start=\"2181\" data-end=\"2189\"><code data-start=\"2183\" data-end=\"2188\">'P'<\/code><\/td>\n<td data-col-size=\"sm\" data-start=\"2189\" data-end=\"2206\">Play with pet<\/td>\n<\/tr>\n<tr data-start=\"2207\" data-end=\"2244\">\n<td data-start=\"2207\" data-end=\"2223\" data-col-size=\"sm\">ESP32 \u2192 STM32<\/td>\n<td data-col-size=\"sm\" data-start=\"2223\" data-end=\"2231\"><code data-start=\"2225\" data-end=\"2230\">'C'<\/code><\/td>\n<td data-col-size=\"sm\" data-start=\"2231\" data-end=\"2244\">Clean pet<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2 data-start=\"2323\" data-end=\"2354\"><strong data-start=\"2326\" data-end=\"2354\">Embedded Software Design<\/strong><\/h2>\n<h3 data-start=\"2356\" data-end=\"2386\"><strong data-start=\"2360\" data-end=\"2386\">STM32 Responsibilities<\/strong><\/h3>\n<p data-start=\"2387\" data-end=\"2445\">The STM32 acts as the brain of the pet. Its tasks include:<\/p>\n<ul data-start=\"2447\" data-end=\"2791\">\n<li data-start=\"2447\" data-end=\"2497\">\n<p data-start=\"2449\" data-end=\"2497\">Tracking three pet vitals on a 0\u2013100 scale<\/p>\n<\/li>\n<li data-start=\"2498\" data-end=\"2542\">\n<p data-start=\"2500\" data-end=\"2542\">Reducing each vital every 30 seconds<\/p>\n<\/li>\n<li data-start=\"2543\" data-end=\"2596\">\n<p data-start=\"2545\" data-end=\"2596\">Updating the OLED with progress bars and messages<\/p>\n<\/li>\n<li data-start=\"2597\" data-end=\"2642\">\n<p data-start=\"2599\" data-end=\"2642\">Detecting button inputs (feed\/play\/clean)<\/p>\n<\/li>\n<li data-start=\"2643\" data-end=\"2741\">\n<p data-start=\"2645\" data-end=\"2673\">Determining whether the pet:<\/p>\n<ul data-start=\"2676\" data-end=\"2741\">\n<li data-start=\"2676\" data-end=\"2691\">\n<p data-start=\"2678\" data-end=\"2691\">is hatching<\/p>\n<\/li>\n<li data-start=\"2694\" data-end=\"2706\">\n<p data-start=\"2696\" data-end=\"2706\">is alive<\/p>\n<\/li>\n<li data-start=\"2709\" data-end=\"2726\">\n<p data-start=\"2711\" data-end=\"2726\">is distressed<\/p>\n<\/li>\n<li data-start=\"2729\" data-end=\"2741\">\n<p data-start=\"2731\" data-end=\"2741\">has died<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li data-start=\"2742\" data-end=\"2791\">\n<p data-start=\"2744\" data-end=\"2791\">Sending formatted status updates to the ESP32<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"2793\" data-end=\"2893\">All game logic runs on the STM32, ensuring responsiveness even if the web interface is disconnected.<\/p>\n<h3 data-start=\"2900\" data-end=\"2930\"><strong data-start=\"2904\" data-end=\"2930\">ESP32 Responsibilities<\/strong><\/h3>\n<p data-start=\"2931\" data-end=\"2993\">The ESP32 transforms the Web-a-gotchi into a networked device:<\/p>\n<ul data-start=\"2995\" data-end=\"3282\">\n<li data-start=\"2995\" data-end=\"3052\">\n<p data-start=\"2997\" data-end=\"3052\">Creates a Wi-Fi hotspot named \u201cSTM-a-gotchi-WIFI\u201d<\/p>\n<\/li>\n<li data-start=\"3053\" data-end=\"3098\">\n<p data-start=\"3055\" data-end=\"3098\">Serves a fully styled HTML\/CSS\/JS webpage<\/p>\n<\/li>\n<li data-start=\"3099\" data-end=\"3154\">\n<p data-start=\"3101\" data-end=\"3154\">Displays animated SVG graphics representing the pet<\/p>\n<\/li>\n<li data-start=\"3155\" data-end=\"3225\">\n<p data-start=\"3157\" data-end=\"3225\">Shows real-time stat bars using a continuous <code data-start=\"3202\" data-end=\"3209\">\/data<\/code> JSON endpoint<\/p>\n<\/li>\n<li data-start=\"3226\" data-end=\"3282\">\n<p data-start=\"3228\" data-end=\"3282\">Sends POST commands to the STM32 for feed\/play\/clean<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"3284\" data-end=\"3340\">The website is designed in a sci-fi HUD style, with:<\/p>\n<ul data-start=\"3341\" data-end=\"3466\">\n<li data-start=\"3341\" data-end=\"3364\">\n<p data-start=\"3343\" data-end=\"3364\">neon progress bars,<\/p>\n<\/li>\n<li data-start=\"3365\" data-end=\"3387\">\n<p data-start=\"3367\" data-end=\"3387\">fading animations,<\/p>\n<\/li>\n<li data-start=\"3388\" data-end=\"3415\">\n<p data-start=\"3390\" data-end=\"3415\">mood-based filters, and<\/p>\n<\/li>\n<li data-start=\"3416\" data-end=\"3466\">\n<p data-start=\"3418\" data-end=\"3466\">a responsive layout for both mobile and desktop.<\/p>\n<\/li>\n<\/ul>\n<h2 data-start=\"3473\" data-end=\"3492\"><strong data-start=\"3476\" data-end=\"3492\">Key Features<\/strong><\/h2>\n<h3 data-start=\"3494\" data-end=\"3535\"><strong data-start=\"3498\" data-end=\"3535\">1. Real-Time Dual-MCU Interaction<\/strong><\/h3>\n<p data-start=\"3536\" data-end=\"3565\">The Web-a-gotchi responds to:<\/p>\n<ul data-start=\"3566\" data-end=\"3643\">\n<li data-start=\"3566\" data-end=\"3603\">\n<p data-start=\"3568\" data-end=\"3603\">physical buttons on the STM32<\/p>\n<\/li>\n<li data-start=\"3604\" data-end=\"3643\">\n<p data-start=\"3606\" data-end=\"3643\">web-based commands on the ESP32<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"3645\" data-end=\"3697\">All updates propagate instantly across both systems.<\/p>\n<h3 data-start=\"3699\" data-end=\"3731\"><strong data-start=\"3703\" data-end=\"3731\">2. Dynamic Web Interface<\/strong><\/h3>\n<p data-start=\"3732\" data-end=\"3763\">The browser interface includes:<\/p>\n<ul data-start=\"3764\" data-end=\"3880\">\n<li data-start=\"3764\" data-end=\"3783\">\n<p data-start=\"3766\" data-end=\"3783\">mood statements<\/p>\n<\/li>\n<li data-start=\"3784\" data-end=\"3805\">\n<p data-start=\"3786\" data-end=\"3805\">pet SVG animation<\/p>\n<\/li>\n<li data-start=\"3806\" data-end=\"3824\">\n<p data-start=\"3808\" data-end=\"3824\">live stat bars<\/p>\n<\/li>\n<li data-start=\"3825\" data-end=\"3840\">\n<p data-start=\"3827\" data-end=\"3840\">hatch timer<\/p>\n<\/li>\n<li data-start=\"3841\" data-end=\"3860\">\n<p data-start=\"3843\" data-end=\"3860\">death detection<\/p>\n<\/li>\n<li data-start=\"3861\" data-end=\"3880\">\n<p data-start=\"3863\" data-end=\"3880\">command buttons<\/p>\n<\/li>\n<\/ul>\n<h3 data-start=\"3882\" data-end=\"3920\"><strong data-start=\"3886\" data-end=\"3920\">3. Clean OLED Display Graphics<\/strong><\/h3>\n<p data-start=\"3921\" data-end=\"3943\">The OLED screen shows:<\/p>\n<ul data-start=\"3944\" data-end=\"4028\">\n<li data-start=\"3944\" data-end=\"3975\">\n<p data-start=\"3946\" data-end=\"3975\">three labeled progress bars<\/p>\n<\/li>\n<li data-start=\"3976\" data-end=\"3996\">\n<p data-start=\"3978\" data-end=\"3996\">stat percentages<\/p>\n<\/li>\n<li data-start=\"3997\" data-end=\"4028\">\n<p data-start=\"3999\" data-end=\"4028\">death screen when triggered<\/p>\n<\/li>\n<\/ul>\n<h3 data-start=\"4030\" data-end=\"4072\"><strong data-start=\"4034\" data-end=\"4072\">4. Safe and Reliable UART Handling<\/strong><\/h3>\n<p data-start=\"4073\" data-end=\"4145\">The ESP32 uses a buffered line-reading approach to avoid corrupted data.<\/p>\n<h2 data-start=\"4677\" data-end=\"4706\"><strong data-start=\"4680\" data-end=\"4706\">Future Expansion Ideas<\/strong><\/h2>\n<ul data-start=\"4708\" data-end=\"4884\">\n<li data-start=\"4708\" data-end=\"4738\">\n<p data-start=\"4710\" data-end=\"4738\">Add pet animations on OLED<\/p>\n<\/li>\n<li data-start=\"4739\" data-end=\"4778\">\n<p data-start=\"4741\" data-end=\"4778\">Implement multiple evolution stages<\/p>\n<\/li>\n<li data-start=\"4779\" data-end=\"4813\">\n<p data-start=\"4781\" data-end=\"4813\">Integrate sounds in the web UI<\/p>\n<\/li>\n<li data-start=\"4814\" data-end=\"4847\">\n<p data-start=\"4816\" data-end=\"4847\">Save progress to Flash\/EEPROM<\/p>\n<\/li>\n<\/ul>\n<h2 data-start=\"4891\" data-end=\"4908\"><strong data-start=\"4894\" data-end=\"4908\">Conclusion<\/strong><\/h2>\n<p data-start=\"4910\" data-end=\"5223\">The Web-a-gotchi demonstrates a successful integration of modern embedded systems with wireless user interfaces. By combining two microcontrollers, one dedicated to real-time gameplay and one dedicated to web hosting, I was able to build an interactive digital pet that works both physically and over Wi-Fi.<\/p>\n<p data-start=\"5225\" data-end=\"5264\">This project strengthened my skills in:<\/p>\n<ul data-start=\"5266\" data-end=\"5436\">\n<li data-start=\"5266\" data-end=\"5292\">\n<p data-start=\"5268\" data-end=\"5292\">Embedded C programming<\/p>\n<\/li>\n<li data-start=\"5293\" data-end=\"5326\">\n<p data-start=\"5295\" data-end=\"5326\">Microcontroller communication<\/p>\n<\/li>\n<li data-start=\"5327\" data-end=\"5345\">\n<p data-start=\"5329\" data-end=\"5345\">UART protocols<\/p>\n<\/li>\n<li data-start=\"5346\" data-end=\"5376\">\n<p data-start=\"5348\" data-end=\"5376\">Web design for IoT devices<\/p>\n<\/li>\n<li data-start=\"5377\" data-end=\"5406\">\n<p data-start=\"5379\" data-end=\"5406\">System-level architecture<\/p>\n<\/li>\n<li data-start=\"5407\" data-end=\"5436\">\n<p data-start=\"5409\" data-end=\"5436\">Real-time software design<\/p>\n<\/li>\n<\/ul>\n<h3>Video Demonstration<\/h3>\n<p data-start=\"3647\" data-end=\"3711\">Web-a-gotchi Demonstration Video<\/p>\n<p><iframe loading=\"lazy\" title=\"Web-a-gotchi: A Dual-Microcontroller Digital Pet System\" width=\"1080\" height=\"810\" src=\"https:\/\/www.youtube.com\/embed\/bEslWO_0JZY?feature=oembed\"  allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p data-start=\"5438\" data-end=\"5597\">The Web-a-gotchi ultimately showcases how embedded hardware can be combined with modern web technologies to create engaging and innovative interactive systems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For my final project, I created the Web-a-gotchi, an embedded digital pet system inspired by classic Tamagotchi devices but redesigned for modern hardware. The system uses an STM32 microcontroller to manage the core pet logic and an ESP32 to provide a wireless, browser-based interface that allows interaction from any phone or laptop. This project allowed [&hellip;]<\/p>\n","protected":false},"author":2096,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-537","post","type-post","status-publish","format-standard","hentry","category-microprocessors"],"_links":{"self":[{"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/posts\/537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/users\/2096"}],"replies":[{"embeddable":true,"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/comments?post=537"}],"version-history":[{"count":1,"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/posts\/537\/revisions"}],"predecessor-version":[{"id":539,"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/posts\/537\/revisions\/539"}],"wp:attachment":[{"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/media?parent=537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/categories?post=537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/portfolio.wcu.edu\/asmamane1\/wp-json\/wp\/v2\/tags?post=537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}