Let’s start from the beginning.
There will be some repetitions in this post. I have already written about Geremia, and this post summarizes the project itself.
The origins
I am an avid reader and love Marco Vichi as an author. The main character of Vichi’s books is a policeman named Franco Bordelli. In one of the novels, Bordelli receives a skull as a gift from the forensic pathologist he works with. The novel takes place in the 60s, and, at that time, it was not illegal to have a real human skull. Bordelli places the skull on one of the kitchen shelves, and in all subsequent novels, it is common to find him talking to the skull.
I found it an exciting idea, but I wanted to twist it. Let’s give some life back to the skull using modern technology.
Sourcing the skull
In 2023 it would be ridiculous to look for a real skull (I’m kidding if you ask yourself if I’m insane.) Amazon could help. I wanted an actual size skull with a moving jaw and enough space in the cranium to hold the electronics I was thinking of. It also had to be realistic. After some research, I bought an anatomic model of a skull (https://www.amazon.it/gp/product/B007S9ZES4/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1) When the skull arrived, it looked perfect. It looked real, had enough space for the electronic circuits, and had a movable jaw.
What should it do?
My idea was to build a notification device connected to my personal computer. The skull would play a choreography each time a notification should arrive. I was thinking about a basic choreography: open and close the jaw, blink two LEDs representing the eyes, and play a notification sentence with a creepy voice.
How could I accomplish that?
As soon as I started thinking about the idea, I realized an Arduino board would be perfect for this project. I could easily connect two LEDs to two ports of the Arduino board to drive the two LEDs, use another port to drive a servo motor and connect an MP3 player to play pre-recorded sentences.
I had an Arduino Leonardo and a servo motor I could try using.
I put together a breadboard circuit to test the basic idea.
In the first place, I wanted to test each segment of the choreography alone. Test the two LEDs, move to the test of the servo motor, and finally, test the MP3 player.
The first problems started to reach the surface:
- The skull jaw is tied to the cranium with a strong spring. When I tested the servo motor on the breadboard and simulated the spring tension, I quickly noticed that my servo motor was not enough. I had to buy another servo motor with high torque to be sure to be able to move the skull jaw. (https://www.amazon.it/gp/product/B09KZ8VTNB/ref=ppx_yo_dt_b_asin_title_o05_s01?ie=UTF8&psc=1)
- The new servo motor introduced a new problem. When the servo motor moved with a load attached to simulate the spring tension, the Arduino board randomly resets itself for no apparent reason. I understood that in electronics, there is never “no apparent reason.” The Arduino board was resetting because the servo motor was drawing too much current from the board that I was powering through the USB port. A quick search on the Arduino board instructed me to use an external power supply with a voltage regulator to transform voltage from 12V DC to 5V DC. Please note that I did not know electronics at all, apart from some basic notions from the past. I just copied a circuit from the internet and tested it on another breadboard with a multimeter.
- The Arduino board I used was not powerful enough to stream content from my PC, so I used an MP3 player instead. I found an extremely cheap MP3 player from China. The first component I received was refusing to work, and I could not understand why. I wired it as the manufacturer explained and used some Arduino test code from the manufacturer. No way, it always refused to work. I searched for the answer to the problem on Google and found out that there are non-working clones of these cheap devices, and I just got one of those. I bought an original DFPlayer Mini, and all the problems went away. (https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299)
The picture below will show the very first working breadboard.
On the back, you will notice an oscilloscope. During these months, I got intrigued with electronics and hardware hacking. I borrowed the oscilloscope from a friend who was not using it anymore for another project, but that’s another story.
Building the Arduino shield
I planned to build an Arduino shield to snap on top of the Arduino Leonardo. The
The shield had to have LED connectors, the servo motor, and the MP3 player speakers. Again, this was the first time I had built something like this. I did not know how to solder, and I did not know anything about board routing. I bought some Arduino proto shield empty boards (https://www.amazon.it/gp/product/B093ZB5M1B/ref=ppx_yo_dt_b_asin_title_o02_s01?ie=UTF8&psc=1) and started the design. I confess I used Affinity Designer to draw the circuits. I know every electronic engineer out there will already be laughing loud.
I also gave a try to Kicad, but I failed miserably. The only thing I was able to accomplish was to draw the schematic of the circuit. Again, something I never did before. It may not be correct.
Ok, I will make you laugh again at me. Here is a picture of the schematic:
The idea was to draw the schematic on Kicad, design a proto-shield PCB and then get it printed by a service like PCBway or similar. Too much complicated for my brain. I confess I gave up on day two.
It took me four different iterations to get a working proto shield, but I was extremely satisfied when I saw that everything was working as expected.
Below is a picture of the proto-shield with all the devices connected and ready for testing:
The software
This was something I felt much more comfortable with.
The idea was simple. One application running on my PC polling services for potential notifications and communication with Geremia over a serial port connection. A simple machine state to take care of everything.
These were the basic requirements:
- I wanted to use Python as a programming language. Perfect for a quick and dirty project.
- Finally, I wanted a self-contained application that should not run from the command line. I did not wish to have a terminal window on my desktop. The perfect place would be an application sitting in the taskbar. The rumps Python library was up to the task (https://rumps.readthedocs.io/en/latest/). It also offers the option to create a standalone application, which I wanted.
The software on Arduino was a different story. As you may know, Arduino is not multi-tasking or multi-thread. This was a huge problem to deal with because I wanted all of the choreography parts to play at the same time.
We do not have multi-tasking or multi-threading, but we can simulate it. The protothreads Arduino library solved the problem (http://dunkels.com/adam/pt/).
The Arduino application is made of a few threads: - One thread will monitor the serial port and respond to commands from the PC.
- The servo motor thread will make the servo motor move when needed.
- The left LED and right LED threads will make the LEDs blink.
- The MP3 player thread will make the board play a sound when there is a notification.
- The DFPlayer thread will monitor the MP3 Player status to change the status to idle when an MP3 file has finished playing.
In principle, it looked easy, but it needed a lot of tweaks since the protothreads library imposes many limitations.
It took more time than expected.
The final result is acceptable even if you have to pay the price regarding fluidity in the choreography.
Assembling
I had the proto-shield and the software ready. It was about time for the brain implant to Geremia.
The first issue is insufficient space for the new servo motor to fit in Geremia’s cranium. The original servo motor I planned to use was much smaller than the new one.
The only option I found was to place the servo moto on the base holding Geremia. Sounds good, but I need to find a way to keep it in place and ensure the servo motor torque will not move when there is action. I designed it and printed it on my FLSun Q5 3d printer. I never modeled anything in 3d. I installed Fusion 360 on my PC to do it. It is free for personal use.
I looked at a few tutorials on YouTube, and finally, I could print the servo motor base and holder. I was surprised by the power of technology. I could create something from scratch and have it on my desk in minutes with a few cheap things. Unbelievable.
Here are a few pictures of what I designed and a picture of the finished item.
I spent the following thirty minutes assembling everything in Geremia:
Final result
Here is a video of Geremia playing a notification for new mail.
What’s missing?
- I still need to fine-tune the software on Arduino and my PC.
- I need to place a heat sink on the LM7805 voltage regulator since running the servo motor tends to become quite hot.
- Hide the servo mounting base and bracket.
Final considerations
I started the project thinking it would be simple, but that was different. I had to solve various problems along the journey, which sometimes was difficult.
The great thing is that I have learned a lot during the process.
Finally, I made it, which is a great thing.