DEV Community

Taylor
Taylor

Posted on

QEMU Arduino emulator dedicated to help Elsie

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

My friend Elsie had a baby and she wants to go back to school. She started Udemy courses for programming. She is usually busy and once she sits, she forgets what she wants to do. I do not have a physical device to monitor her motion so I will emulate Arduino on QEMU. I want the device to monitor her movements in between active hours ( 8:00 am to 10:00 pm ) . Once she sits, the device will notify her to complete three tasks

  • learn current task on Udemy
  • update folder
  • ensure git is connected and automatically updates to repo

The end goal is to make her remember to learn once she has time (no movement/ inactivity) in her hands.

Demo

This is the front-end on Render : https://dev-week.onrender.com/.
It works well on local

Code

Here is my GitHub code

dev-week

Requirements

  1. Use Gemma locally

  2. Ensure code performs these tasks

    Sending a message between 8am to 10pm whenever there is no movement, user has no activity, it reminds user three things - learn current task on udemy - update folder - ensure git is connected and automatically updates to repo

  3. Use QEMU to emulate Arduino sensor

  4. Upload the code to Github

  5. Add to render




How I Built It

  1. I set up Ollama locally using this tutorial link and pulled Gemma. Ollama Gemma 1 Ollama Gemma 2
  2. I used Gemma within Ollama with prompts to help point it to what I wanted. I gave it this link to a tutorial and I told it to build my project similarly but with a different programming language.
  3. I set up my QEMU VM ( QEMU is an open source quick emulator)
  4. I used Gemma to edit a tutorial I found on Arduino and to ensure it ran my tasks
  5. I followed the instructions and used this to compile my sensor.c file shell cd ~/movement-reminder avr-gcc -mmcu=atmega328p -DF_CPU=16000000UL -Os \ -Wall -Wextra firmware/sensor.c -o firmware/sensor.elf shell
  6. I started QEMU using this

    cd ~/movement-reminder
    qemu-system-avr -M uno -bios firmware/sensor.elf \
    -nographic \
    -serial tcp:127.0.0.1:5678,server=on,wait=off
    
  7. I ran local using this so that it depends on my interaction

    QEMU_SERIAL=0 TEST_MODE=1 IDLE_SECONDS=10 REPEAT_SECONDS=20 \
    python -m uvicorn main:app --host 127.0.0.1 --port 8000
    


    local server
    QEMU

  8. I pushed code to Github and ran it on render using credits

  9. I also used Gemma to try to connect devrelay but failed

Why Does Open Innovation Matter?

Ollama runs locally but it needs a network to run a model. I chose Gemma but I can swap models at any time. Ollama data is not uploaded or does not get to a server that's why history refreshes after each session. I have to find a way to keep logs in order to update the logs / file to Devrelay. Gemma needs to be given specific commands for it not to hallucinate and to build it's memory. I am also learning how to preserve memory and fine tune. My model which is 3:1b needs a lot of fine tuning.
Open Innovation helps developers try out new ideas. The documentation is available and developers can help improve on the technology to fit in some recommendation or feedback. People create issues , bug reports of feature requests according to how they want the technology to work. Open technology is also the best way for development whereby your code and logic is sharpened and made more better.

My Agent Session

I copied my ollama history like this :
cp /home/user/.ollama/history ~/ollama-history.txt and pasted it to my code folder here :code

Prize Categories

Best Use of Render

Best Use of Gemma

Top comments (0)