Author: cheeto

  • cheetoPet

    cheetoPet

    an esp32 based feature rich tamagotchi

    things i’ve learnt making cheetoPet:

    • embedded C/C++ development
    • making modular, efficient code (efficient is debatable)
    • building compact electronics
    • designing PCBs

    tools i used:

    • arduino IDE (project ide and for uploading code)
    • 3D printer (ender 3 v2 neo)
    • soldering iron (pinecil v1 / ts101)
    • autodesk fusion (3D modelling)
    • kicad (pcb design)

    main features:

    • 128*128 pixel resolution monochrome OLED display
    • virtual pet with a customisable home, a variety of games and constantly updating needs
    • 2 axis accelerometer (linear, rotation)
    • 160mhz MCU with 4MB flash memory
    • external clock, drifting only 1-2 minutes a year
    • multiple week battery life with USB-C recharging
    • 5000 lines of C++! too many… its easily expandable!

    software demo

    captured using a custom python script i made to receive display data over serial and display it in a tkinter window. the actual device has a much faster framerate, but serial limits how fast it can be captured.

    raw gyro data demo

    framerate is slow because the way the display refreshes is a bit weird, its a good camera i swear!

    here you can see the bare board and the gyro data coming in from the MPU-6050. in the main software, rotation of the device while holding B moves the cursor, so rotate it left to move the cursor left. it takes a bit to get the hang of it but its pretty intuitive. you can see the X and Y values, which would represent the cursor, change in this demo.

    hardware in depth

    components of the prototype/dev board:

    • ESP32C3 super mini dev board
    • DS3231M clock module with CR2032 installed, keeps time even when main battery runs out
    • MPU6050 (accelerometer) module (it says its a mpu9250 but its actually a 6050…)
    • SH1107 128*128 monochrome OLED display
    • TP4056 battery charging board
    • 803040 1000mAh lipo battery with bms board so i don’t explode
    • generic piezo buzzer harvested from its plastic tomb
    • generic smd buttons and 3 pin switch
    • 6*4cm perfboard

    everything’s been crammed together on the perfboard, and it hasn’t had any catastrophic failures yet! (yet…)

    you may notice a piece of paper in between the display and the board, that’s to stop the back of the display shorting out on the rest of the components, especially since the accelerometer is right underneath it.

    the case was designed in fusion and printed in PLA, albeit not very well.

    next steps

    i’ve designed a pcb and ordered it from jlcpcb to make this a neater package that’s much more reliable and easy to make.

    i’m planning to make 5 of them, with the parts cost being around £17 each, and then i can finally use the wifi and bluetooth of the ESP32C3 to do some multiplayer stuff, potentially? maybe i’ll get bored by then. or maybe i’ll sell them! that sounds fun.

    other info

    if you want to build this, maybe even contribute to the software, everything is open source on my github. i would wait until i finish the pcb and build it on one of them.

    conclusion

    im most proud of the software. its one of the biggest coding projects i’ve done (not including scratch projects haha) with 5000 lines of code, i would NEVER of thought i could write that much myself.

    some of my favourite parts of it would probably be the behaviour tree (very modular, just good design) and the bitmap/item system which cleanly and easily maps items to their respective images and locations within large arrays. it is pretty messy, lacking comments, and some of it resulted from vibe coding (the death of creativity) but the way its all held together is all me.

    the hardware is cool… but will be improved. i cannot leave it like this! the pcb will fix this, but may take a month or two to minimise the jank. also, ive found documenting the whole project almost as difficult as the project itself, so i’m going to have to get used to that as well!

    see you next time, when i have a finished product that looks less like a bomb!