Introduction: Frosty the SPyman
Frosty the SPyman is a snowman on a shelf that livestreams video and moves on his own! Santa can now be 100% sure that people are being nice.
Step 1: Video and Poem
"Twas the night before Christmas, and all through the house
Not a creature was stirring, not even a mouse.
The presents were set at their place near the tree,
And the lights were powered by a Teensy.
The top of the mantle was set like so,
There was a candle burning, emitting a glow.
On top of that place a snowman was sat,
Watching over the gifts like a housecat.
Then out of nowhere a thief did appear,
He took and unwrapped a present,
And then it became clear,
The snowman was watching,
So he began to repent.
Frosty the SPyman had stood guard so well,
The fears of the family finally quelled. "
Step 2: Gathering the Parts and Building the Enclosure
I went to Hobby Lobby and got several items. One was a snowman that was based off of an Elf on a Shelf, with dangling legs and a stuffed head. Second, I got some "snow" and filled up the snowman with it. Lastly, I collected a round cookie tin that was just large enough for a Raspberry Pi to fit inside. I punched 2 holes into the tin, one for the Raspberry Pi Camera Module and one for a power cord to fit through. I also put a hole in the lid so the servo could rotate the snowman.
Links to DFRobot's products:
Step 3: Setting Up the Pi
DFRobot reached out to me and sent their Raspberry Pi 3 and Raspberry Pi Camera Module. So after I opened up the boxes I got right to work by setting up the SD card. First I went to the Raspberry Pi Downloads page and downloaded the most recent version of Raspbian. I then extracted the file and put it into a convenient directory. You can't just copy/paste a .img file to an SD card, you have to "burn it" onto the card. You can download a burning utility like Etcher.io to easily transfer the OS image. After the .img file was on my SD card I inserted it into the Raspberry Pi and gave it power. After about 50 seconds I unplugged the cord and removed the SD card. Next I put the SD card back into my PC and went to the "boot" directory. I opened up notepad and saved it as a blank file named "ssh" with NO extension. There was also a file I added called "wpa_supplicant.conf" and put this text into it:
Then I saved and ejected the card and put it back into the Raspberry Pi 3. This should now allow for the usage of SSH and connecting to WiFi.
Step 4: Getting the Camera Ready
By default, the camera is disabled on the Pi, so you must open the terminal type sudo raspi-config to bring up the menu. Go to "interfacing options" and then enable the camera. Now just select "Finish" and insert the ribbon cable of the camera module into the correct area of the Pi.
Step 5: Installing Software
There are several different softwares that can stream video, such as vlc and motion, but I decided to use the mjpeg-streamer due to its low latency and easy installation. According to the instructions on the site, do a git clone https://github.com/jacksonliam/mjpg-streamer.git into a folder, then type sudo apt-get install cmake libjpeg8-dev to install the needed libraries. Change your directory into the folder you downloaded and then type make followed by sudo make install to compile the software. Finally enter export LD_LIBRARY_PATH=. and to run it type ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so" You can access the stream by heading to http:// <The Pi's IP>:8080/stream.html to view the stream.
Step 6: The Electronics
Using the PWM class from the GPIO library can be useful, but it can cause many issues when used with servos. Servo motors require precise timing, which a SoC simply can't provide. So I decided to use the Adafruit PCA9685, an I2C controlled, 16 channel PWM module. The library can be found here.
Step 7: The Code
The code is pretty simple. All it does is use the subprocess.Popen library to run the mjpg command and turns the servo. The PCA9685 library uses pulses to control servo, not degrees, so I found that using 150 for 0 degrees and 550-600 for 180 degrees. Every 30 seconds the snowman rotates to 0, 90, or 180 degrees.
Step 8: Using Frosty the SPyman
I set up my snowman in the livingroom of my house to keep guard of the tree and other decorations. To view the livestream simply go to http://:8080 and then click the stream button.