-
1Video
-
2Gathering 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.
-
3Setting 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:
network={ ssid=<"SSID"> psk=<"PASSWD"> }
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.
-
4Getting 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. -
5Installing 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 typesudo apt-get install cmake libjpeg8-dev
to install the needed libraries. Change your directory into the folder you downloaded and then typemake
followed bysudo make install
to compile the software. Finally enterexport 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 tohttp://<The Pi's Local IP>:8080/stream.html
to view the stream. -
6The 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.
-
7The 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.
-
8Using 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://<RaspberryPi_IP>:8080 and then click the stream button.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.