Homunculus - the Mechanical Mystical Oracle Fortune Teller
by r570sv in Circuits > Raspberry Pi
5209 Views, 76 Favorites, 0 Comments
Homunculus - the Mechanical Mystical Oracle Fortune Teller
Ok - so what is this supposed to be… the back story on this I tell people is that the skull is from a 19th century mystic who’s grave was robbed and that his skull that ended up in some carnival side show back in the early 1900s. I found it in a basement of some run down Victorian house and re-constructed the prop into a 21st century fortune teller – ‘who can reach out into the ether of the internet, tell you your fortune, who your friends and enemies are, tell a joke and read my email and calendar for the day’.
What is it really is - Well it’s the amazing Jasper software running on a Raspberry pi and I’ve made a 2 channel talking Linburg skull that is doing the talking along with a lot of bells and whistles (and a tambourine) to add to it.
This was a super ambitious project. Lots of different medias to work with – multiple pies, wood working, painting, lots of wiring, lots of coding in python, ardunio coding, lots of small wiring, 120v wiring, pi ‘hats’ external boards, relay drivers and relays, 24v power supplies, making things move – a skull with 2 axis and the tambourine banging.
I’m not going into super detail on piece by piece basis for of each part, especially the python coding but I’ll try to describe each component briefly and include pictures.
Also, on the Python examples – yes I could have been much more object-orientated on the coding but my Python experience when I started the project was pretty basic and of course its easier to cut and paste when you’re in a hurry vs. stopping what you’re doing, re-write it correctly then continue.
Major Components – Things I Had to Find/get/buy
Raspberry Pi
Two of them
https://www.adafruit.com/products/1914?gclid=CjwKE...
Jasper
“Jasper is an open source platform for developing always-on, voice-controlled applications”
https://jasperproject.github.io/
Adafruit ‘eyes’
https://learn.adafruit.com/adafruit-1-44-color-tft...
Teensy – Brain for the eyes
https://www.adafruit.com/product/2756
How to create the ‘eyes using teensy and the 1-44 color tft displays
https://learn.adafruit.com/animated-electronic-eye...
16 channel Serveo hat
https://learn.adafruit.com/adafruit-16-channel-pwm...
The Classic Lindberg Skull
https://www.amazon.com/Lindberg-scale-Pirate-skull...
4 channel relay board that will work with a Raspberry Pi
https://www.amazon.com/Sizet-Channel-Module-Arduin...
Push Solenoid
(This is available from many different places)
https://www.aliexpress.com/item/High-quality-DC-12...
USB Microphone
This is available from many different places
http://www.samsontech.com/samson/products/micropho...
Miscellaneous
Two Servos I had laying around, servo horns I found in the $1 basket at the hobby shop. Servo extension cables, USB/Bluetooth speaker, nuts bolts, MDF, Hot Glue, old vacuum tubes, various lamp pieces & bits, an old Samsung S5 cell phone, sheet steel, copper wire, copper tape, nails, regular glue, etc. etc.
Why Two Raspberry Pies?
Originally I had wanted to sync the skulls talking with the speech but after installing Jasper and determining all I wanted to do, all the things moving around, I thought it may be better to break up all of the work into two Pies. I had a deadline on having this done and I didn’t want to have to backtrack if I had some type of performance issue. Now that the work is done, I believe I could of did it with a single Pi, at the time I thought it best to let one pi manage Jasper and a 2nd pi drive the servos and relays so I could have a clear demarcation between the work. It was also easier for development. I could get everything correct in Jasper not having to worry about servos and relays. On the other pi I could focus on driving the servos, timing of things – turning lights on, moving servos, etc. and not have to worry about any voice/speaker/microphone related issues.
The down side to this is that I lost the ability to have the skull sync moving its jaw with the speech, but after looking at Grant Imahara’s work for the The Late Late Show creating ‘Geoff’ I figured things would look good enough.
How Do the Two Pies Communicate?
There are a few different ways you can do this. I went old school and decided to go with a serial connection. It only needs three wires between the two Pies (Tx, Rx & gnd) and a small amount of code to open a serial connection From Pi#1 to Pi#2 and send something over to it. Pi#2 open a serial connection to read data and sets in a tight loop reading from its serial connection. When it receives some text, it sees if it matches a command (Talk, lights on, lights off, talk off, etc.) and do what it needs to do. The down side of the serial connection is there is a slight delay from when the command is sent and the process of the command. Pi#2 is in a loop with a small delay on the read. So I had to kind of pace things. Also for future multi-pi projects it’s good to know I can have two Pies communicate and NOT need the internet to do it.
Python Threads
To add some additional complexity to everything I ended up having to use Python threads on Pi#2 so I could handle multiple requests and process them at the same time. For example, I needed to be able to start talking – moving the skulls head to the left/right while the jaw goes up and down, but what if Pi#1 has an error for some reason and not be able to tell Pi#2 to stop talking, the skull would be talking forever. So I needed to have the skull tell itself to shutoff after some amount of time. To do this it was easiest to spin off a thread. Inside of the thread routine for talking there is some code that after some max time, stop talking, reset the head and jaw and exit. Same for the tambourine, I needed it to kick off just before the skull stopped talking so I spin another thread for the tambourine and everything works together and the code for the head movement is totally separate from the tambourine banging – same for powering up the lights and the eyes all the threads can all running simultaneously.
The amount of code needed in Python to use threads is pretty small but it’s obtuse and took some time to get my head around it, but as it turns out, works very well. Ability to use threads is a good tool to have in the toolbox if you’re a Raspberry Pi developer.
Jasper & Jasper Modifications
The Jasper site is THE resource for getting it installed on a pi, what voice reco’s to use, how to configure, write new modules, everything – and its free! It isn’t a simple install though. Lots of steps, lots of packages to install then configure. I do this kind of work for a living and it was still something I would consider a challenge. By the time I was done with this project I got pretty deep into Japer and made a lot of modifications to accommodate what I was trying to do.
Some changes I made:
Removed passive listening and used a GPIO port to kick off active listening off with a homemade cut switch. This made for more of an ‘arcade’ kind of thing vs. using the passive listening.
Changed the parameters as necessary to work with my microphone – I had to go through three different USB microphones until I found one that would work correctly for me. I also had to adjust some of the threshold values in the code. This was the most painful part of using Jasper for me personally.
Added the serial connection code in all of the modules to open up a serial connection, tell the slave pi what to do ‘eyes on’, ‘talk’, ‘bang tambourine’
Added a ‘who are my friends’, ‘tell me a joke’, ‘read my schedule from my CRM calendar’, ‘tell me my fortune’ modules. Some of which required making REST calls out to cloud based software to obtain data. There are a lot of the out of box modules that I leveraged as examples along with documentation on the site to help me get what I needed done.
Adding Two Axis’s to the Skull
I started with the basic Lindberg skull. I had originally thought about a 4/5 axis skull but the time it would take to write the python code to coordinate the movements along with building out the hardware for the movement would exceed the time I had to finish off the rest of the project. (I don’t know if it already exists but a piece of software on a Pi or Ardunio to drive a multi-axis skull that would be a pretty cool project in itself.) So one axis – the jaw moving was too lame, so I added the head movement and with the LCD eyes working, I’m happy with the results.
So from looking at work others have done with talking skulls I figured out what I needed to do, two servos & servo horns, a piece of MDF, hot glue, zip ties, trial and error - I had the physical part of this in place. Basic Pi programming of the movement actually took longer. I had to figure out the values for the PWM for both servos. I started with the basic all the way open/shut turn head all the way to the left/right. But it didn’t look good. So I made intermediate movements, jaw full open, delay .1, jaw partially closed, no delay, jar partially open, delay, .etc, etc. Same for the head movement, slamming back and forth looked crappy so intermediate movements and delays make it look better.
One unfortunate thing that I didn’t have time to work through is that all of the material I put on the skull cap – the metal strip, spikes, copper crown and wiring made the overall skull heavier and gives the servo inside a hard time so it’s moving slower and not as far. A higher torque servo probably would help here but I was out of time and funds…
Adaifruit Hat Servo Driver
Adafruit has great examples of how to use their products. What was challenging was figuring out what exactly the values were for each of the servos – center, far left and right. It’s not 0,90,180 like you would think. It was only a couple of lines long python program but it took some hours of tweaking to get through this for both of the servos.
Relay Board
I picked this up on Amazon. Lots of web sites sell what appears to be the exact same unit. It took some experimenting here but flipping the relays only takes a couple of lines of code and you have a NC and NO connections on the relays making it even easier. Another challenge here is a GPIO port/pin isn’t a 1:1 match with the pin out on the Pi. It took a little bit of work to get my head around that.
Teensy and the Eyes
I took this 100% from the Adafruit site. Originally I had some lame LED lit ping pong balls I was going to use but once I saw this on their site I had to have it. I had zero Ardunio experience prior to this but I blindly followed the examples on their site and had these working in about ½ of a day. Also – since I flashed the program on to the teensy it retains it and when you power it up. The Ardunio starts up in about 3 seconds and lights up the eyes. So, all I had to do to get the eyes to work was to hook up 12v to one of the relays and power up the teensy & eyes and magic happens!
Mounting the LCD screens in the skull was SUPER painful. 7 small wires on each LCD so 14 wires total and trying to grind out the skull and get them mounted straight and not break a wire –which happens a lot was very painful. So programming moderate difficulty – mounting hard. Just the opposite of what I expected. The Teensy set in back of the eyes below the MDF plate that holds the two servos.
Tambourine
Well I always remember the head in the crystal ball in the Haunted Mansion and the tambourine floating around banging as she was contacting the spirits so I had to have something like that for this project. Since the skull was from a former mind reader/seer the spirits need to let people know when they are present J. I found the biggest most powerful push pull relay I could find. Then over volted it from its 12v to 24v with a spare laptop charger I had. I had to make a couple of different versions of the mechanism but my third iteration worked the best. I had to mess with lever length, alignment, etc. My big mistake was doing all of this with wood/MDF. When I first put this together running at 24v the solenoid would bang the tambourine so hard it was tearing itself apart. (At 12v it wasn’t strong enough) Over time having a wood shaft mounted in MDF and painting things the whole thing became harder / more difficult to move which meant that the solenoid had a harder time pushing out when enegerized AND a harder time returning. So I had to add an additional return spring – which requires the solenoid to waste energy when it’s energized. So it ended up banging the tambourine on the slow-ish side. Next time I build that part of it in metal – bronze bushing, metal shaft, etc and avoid this problem.
Plasma Lamp
Since I wasn’t going to build a Jacobs ladder or some other wicked mad scientist energy source for the project I needed some type of ‘energy’ to drive the skull. I took my old Samsung Galaxy S5, did a factory reset and loaded up an energy ball app on it. I had to load another app that wouldn’t let the phone go into screen saver mode to keep it active on the app.
How to Make the 120v Light Flicker
WARNING –
This is messing with 120v AC plug in the wall power here. If don’t know what you are doing, don’t do it.
WARNING -
https://halloweenpropmaster.com/u-build-it3.htm
This site gives the best explanation of how to do this. The cost of the starter is super cheap and I gutted a spare extension cord I had. I have a couple of these built and have been using them during Halloween time and they’ve work very well, no fuses blown, no overheating, etc. I’ve ran them for hours at a time without issue. So for this project I took one of the extension cords with the starter inline and wired it to one of the four relays on the board. A couple of lines of GPIO code will turn it off and on. It also starts working immediately, no warm up time.
The Platform/Table
I’ve seen quite a few ‘skull on a table’, ‘Frankenstein’s head on a table’ mad scientist kind of props and I decided I wanted to go that route. It would give me a chance to try out more than just the talking skull. I figured out the basic table size and built it out of ¼ MDF. Using a table saw makes doing that pretty easy. My projects are typically metal things so building with wood was somewhat new to me. I cut the basic pieces out and had my 4 sides of the box and a top made pretty quickly. Where I learned a hard lesson with is I used a glue gun to assemble them. What I found out is that – this isn’t the way to do it. All of the pieces came apart as soon as I picked the damn thing up! So I cut some extra pieces of 1” square to reinforce the corners and wood glued/nailed it together. Lesson learned. I laid some trim between the top and sides of the platform, glued and nailed it into place. Spot puttied to fill the gaps and it was ready to have the rest of the components mounted on it.
For the rest I got inspiration from images I’ve seen on the web. To ‘antique’ the skull I tried to use a dark stain. It didn’t work; it didn’t stick to the plastic. So I tried painting the skull with an off white and then laid the stain on. It worked much better. I know there are a lot of techniques for doing this and I’m happy with the way it turned out. Copper tape I had laying around from another project I used for the skull cap and around the cheek bones. I painted on the stain on the rest of the non-black painted items to give it that antiqued/old look.
The rest of the pieces and bobbles I had laying around from other projects. All of the brass pieces are from a lamp store. I made the cut switch out of some scrap materials and the knob on the end is another lamp piece. The tubes I found at an electronic surplus place along with the insulators. Punk rocker spikes I had from another post-apocalyptic project. Sheet steel and copper wire from the hardware store and some PVC pipe for his vertebrae.
For the poster, I found and old magician’s poster picture on the web and with some Photo Shop magic changed the name.
The Rest
I got inspiration from images I’ve seen on the web. To ‘antique’ the skull I tried to use a dark stain. It didn’t work; it didn’t stick to the plastic. So I tried painting the skull with an off white and then laid the stain on. It worked much better. I know there are a lot of techniques for doing this and I’m happy with the way it turned out. Copper tape I had laying around from another project I used for the skull cap and around the cheek bones. I painted on the stain on the rest of the non-black painted items to give it that antiqued/old look.
The rest of the pieces and bobbles I had laying around from other projects. All of the brass pieces are from a lamp store. I made the cut switch out of some scrap materials and the knob on the end is another lamp piece. The tubes I found at an electronic surplus place along with the insulators. Punk rocker spikes I had from another post-apocalyptic project. Sheet steel and copper wire from the hardware store and some PVC pipe for his vertebrae.
Assembly/Tuning/Tweaking
So here was my build process:
#1 Install Jasper on a Pi and get it working.
#2 Purchased multiple microphones and tweak until I have some success.
#3 On the 2nd Pi, install the Adafruit hat and understand how to move the servos. Get the servos into the skull and understand the values I needed to use to move them.
#4 Build a test base for the skull so I can work on it in my office. Tweak, re-tweak, tweak some more.
#5 Mount all of the electrical components on a Plexiglas board. Pies, relay board, USB power supplies & related wires.
#6 Build the Adafruit eyes. Prove to myself they just need voltage applied to have everything work. I didn’t know this when started this part.
#7 Do a proof of concept of sending and receiving serial data between the two Pies. Write a loop routine for the 2nd Pi with the commands I needed – talk on/off, etc. Test it with some sample code on Pi#1. No Jasper yet.
#8 Add the serial code to the Jasper code – prove I can get basic movement when Jasper is talking.
#9 Start messing with the relay board. Add the code to turn on the Eyes.
#10 Add code to turn on the 120v. Build the solenoid and tambourine on a separate platform to figure out how it should work.
#11 Get the eyes mounted in the skull.
#12 Build the platform that everything will be assembled on. Assemble all of the pieces onto the platform, make the steel base of the skull to hold it, add the tambourine components.
#13 Try to get the pies & board from in the house into the garage and figure out how to get it inside of the platform.
#14 Start tuning. More tuning, continue to tune. Realize that I need to make the Python code multi-threaded so all of the actions can work together.
#15 Decide to add the energy ball below the vacuum tubes. Figure out I can do this with an old cellular phone. Made that work in less than a day.
#16 Continue to add detail. Spikes, copper wire, tubes, antique the skull. Keep tuning & testing. Paint, touch up, and fix things that keep coming loose, re-engineer/reinforce things that are falling apart.
#17 Test & tweak Get ready to show it to other people.