Viewing the Hive

With infrared communication sorted out, I had all the ingredients to make the Hive: I could just dump the Tamaserver and a bunch of Tamagotchis on my server and run them. What was missing was a nice front-end to view them. Luckily, this could easily be amended. I already had the Tamaserver communicating to all the Tamagotchis: all that I would need to view them was some code to also pass the LCD contents to it. The Tamaserver could then store the LCD contents in a bit of shared memory, which could then be read by whatever process is interested in it. In this case, I wrote a bit of PHP code that could send out the current LCD state of the Tamagotchis using the HTTP protocol.

The most obvious way to make the information viewable was a simple AJAX/JSON website, which enables you to view the Tamagotchis in any modern browser. That is exactly what I did, and you can view the result at http://tamahive.spritesserver.nl/.

Only being able to view the Tamagotchis on a browser was a bit sad, though. I still had the physical Tamagotchi I bought years ago. Maybe I could convert it into a viewer? In theory, this is possible: Natalie found a way to run 6502 code on the Tama, and I could use that to push data to the little LCD.

The way Natalie does this is to re-program the flash in a flash-based Tama-Go figurine. She basically loads the video RAM with a bootstrap program by displaying a special image, then she uses a bad command to make the 6502 jump into VRAM. From here on, her own code gets executed, which can load some data into RAM and execute it. She actually has an entire toolset to make this easier.

Unfortunately, I didn't have a Tama-Go figurine: I got one with the Tamagotchi but that was an 'empty' one, which only jumpered two pins without containing ROM, enabling some built-in functionality in the main ROM. I also couldn't easily get one of the flash figurines quickly. After reading the datasheets, it looked like the protocol was mostly compatible with standard SPI flash. That was worth trying.

What you see here is a standard SPI flash chip (desoldered from an ESP12 module) flashed with the contents of an existing Tama-Go and connected to the Tama-Go port of the Tamagotchi. As you can see on the LCD, the Tamagotchi happily sees it as a figurine.

Now, using Natalies toolset, I could quickly whip up a little program that would make the LCD writable from outside the Tamagotchi. I wrote some assembly code that would treat the GPIOs the 3 buttons are connected to as a sort of SPI bus. By sending data over this bus, an external microcontroller could use the Tamagotchi as a dumb LCD now.

As the external microcontroller in question, I picked an ESP12 module. This is one of the many modules featuring the WiFi-enabled ESP8266 processor. It's wired to the three buttons of the Tamagotchi. On startup, it will emulate button presses to guide the Tamagotchi into executing the custom 6502 code, and as soon as that's done, it will connect to the Tamagotchi hive server and send the data of a selected Tamagotchi over to the LCD.

« Prev 5 Next »

© 2006-2021 Sprite_tm - Contact