Introduction: Weather Camera Raspberry Pi
A while back I wanted a project that combined the following:
- Raspberry Pi
- Python Code
- Live status
- Indications of activity
So I decided to build a Raspberry Pi box that would take photos of my backyard at scheduled intervals, indicate when the photos were being taken, and finally push that information out to Twitter for review.
List of electrical supplies:
- Raspberry Pi
- Raspberry Pi breakout board (for LED indication)
- 5 inch LCD for interactive display when needed
- Raspberry Pi Camera (5 megapixel)
- HDMI cable
- CAT 5 cable
- DC power pack for the Pi
- 24-26 gauge wire or jumpers
- 3 LEDs
- 3 10-100 Ohm resistors
- 2 position push button switch
List of case supplies:
- 1/4 pine panels cut to size of the project
- Top, Bottom, and Front and Back are made from the same type of wood in my example
- 1/4 by 1-inch wide pine boards were used to make the left and right sides of the case.
- Brace for window mount was made from scraps I had in the workshop.
- Screws for case
- Hot glue for mounting
- Solder and flux for resistor / LED connections
- Miter or table saw
- Jig Saw or Dremel
- Sander or oscillating tool with sanding head
- Soldering gun
- Wood burner
- Rasps, Files, Chisels as needed to make the smaller holes in the case
Software and accounts:
- Raspberry Pi OS of your choice
- Twitter account with free developer key
- Python 3 on the Raspberry Pi
Step 1: Recommended Purchases:
To make this build easier, I recommend one of the Canakit's available that come with the Raspberry Pi, LED's, Resistors, Breakout board, SD card, and case.
The camera that is currently in production is the 8 megapixel
- Older 5mp version is still available: https://www.canakit.com/raspberry-pi-camera.htm
Step 2: The Case Diagram (Outside)
This is the overall layout of the exterior of my case, and it is really dependant on if you decide to add all the components in your build. Also depending on where you plan to place your camera you may find that this size case doesn't work for you if so these plans are more of a suggestion rather than a formal build list.
Step 3: Inside Layout Diagram
Based on my goals for the project you can see that I added the camera to the basic Raspberry Pi system as well as the breakout board so that I could control LED's on the front of the case. I decided to add an LCD for times that I want to use the Pi interactively and not in headless mode.
The push button switch was added to reset the Pi if needed.
Step 4: Raspberry Pi OS, Python , CRON Setup
- Raspberry Pi OS:
If you purchase a kit you will normally get an SD card installed with NOOBS, if not many tutorials are out for installing RASPBIAN (my choice on this project). But here is the official guide for installing RASPBIAN from a NOOBS SD card- https://projects.raspberrypi.org/en/projects/noobs...
- Python 3:
From the shell if python 3 isn't installed :
- sudo apt-get install python3
The attached python code is set to do the following-
- Read values from the Raspberry Pi (Uptime and CPU temp)
- Build a tweet using the supplied developer tokens for posting to twitter (link below will take you to twitter to create a dev account or add it to your own account)
- Illuminate the yellow LED when building the post
- Illuminate the red LED when posting
I use a scheduled job (CRON) to run the script on a preselected interval:
- As seen below the script is running every five minutes from 7 a.m to 4 p.m
0,5,10,15,20,25,30,35,40,45,50,55 7-16 * * * sudo /usr/bin/python3 /home/pi/system_info.py\
To list a users CRON:
- sudo crontab -l -u pi
To edit a users CRON:
- sudo crontab -e -u pi
Step 5: Wiring of the Components (Switch and LEDs)
Breakout board from GPIOs to LEDs:
We can control output from the Raspberry Pi's GPIO connector using a breakout board like the one in the photo.
In this case, our python code will send an on signal to the pin on the GPIO (pictured is a connection to GPIO 26). We send the voltage through the wire on the breakout board and through a resistor to one of the Legs of the LED. The other sided of the LED is wired to the ground side of the breakout board to complete the circuit.
Note that the resistor is inline to prevent the burnout of the LED, the more current limit on the LED the dimmer it will be. The Canakit packages normally have LED's with 220 Ohm and 10k Ohm resistors as well as the breakout board. This helps to take some of the guesswork out of buying the right LED resistor setup.
Push button switch:
With the Raspberry Pi 2 and Raspberry Pi 3, a reset point is on the board. In the case of the Pi 2 the "P6" pin pair and on the Pi 3 the "RUN" pin pair allows us to send a "High" when we connect the two pins sending a "Halt" to the system.
This is NOT a shutdown switch, just a reset .....I recommend issuing the following as a power down from the shell:
- sudo shutdown -h now
Step 6: Front Panel Inside View
These two photos show the LCD, Power button, Breakout board, and LEDs attached to the front of the case.
One quick disclaimer the rightmost LED stopped working which is why the wires are terminated (until I replace the LED)
Step 7: Front Panel Outside View
As you can see this the finished front panel with the LCD, LEDs in place and the graphics wood burned into the pine case
Step 8: Inside View of Back of Case
I located the Raspberry Pi right next to the Raspberry Pi camera simply because the camera ribbon cable is very short.
Step 9: Back of Case Outside View
Not much to say about the back panel other than the camera is fixed in position so you will need to move the case to get the viewing angle that you want
Step 10: Outside View of Right Side of Case
The right side of my case has openings to allow for connecting to the pi (USB and CAT 5) as well as some room to route the USB cable from the LCD back up to the Pi as the cable was too rigid to make the bend without increasing the case width.
Step 11: Window Mount
Because this is a fixed camera position I had to build a support mount and brackets to get the correct angle of the camera for the backyard. Simple scraps of wood from the shop and some wood shims to create an angled platform. Used L-brackets to hold the front of the camera box in place (cats often move it around if nothing is in place to support the case)
Step 12: Sample Tweet:
Step 13: Final Thoughts-
This guide can be morphed into a lot of different builds, I just came up with a few goals and set out to build a device to execute the goals. Looking forward to your comments and builds!!