Devhour

Taking time to write about development

Raspberry Pi and Motion (Weather App Pt 2)

Part 2 in this series is going to show you how to setup Raspberry Pi and Motion in order to snap a picture every 10 minutes or so.

If you haven’t already read Part 1 in this series to check out how to set up a Raspberry Pi temperature sensor with the DS18B20 sensor.

Having setup the temperature sensor and tested that it can read the temperature correctly, I can now move on to setting up our camera to capture an image of the weather every 10 minutes.

Fortunately I did have a spare web cam lying around but you could get away with spending a couple of dollars and getting a fairly cheap web camera that’ll do the trick.

Now to do this I am going to use a pretty cool piece of software called Motion. Motion is a piece of software which uses video4linux device to detect motion and can be used to take both videos and pictures. It also has a pretty powerful trigger action settings which allows you to run shell commands after/before a certain event in order to perform extra actions (eg Send an email or upload the video/picture). I will make use of these in the next part of this series in order to grab the current temperature after the image has been taken.

One of the cool things people have used Motion for is to make a basic home security system. Have a webcam pointed at the driveway or main entrance to your house and then have motion take a video or picture of anyone who approaches. Upload the video to a remote location and send you an email letting you know you have a visitor. Works quite well and for ~$50 is a cheap solution.

For now though I am going simpler. Tell Motion to take a picture of whatever the web camera is pointing at every 10 minutes and move the picture to our images folder (later used for the website I make). In my case I will be pointing my web cam out the window in order to see the weather.

Setup Raspberry Pi and Motion

Firstly, install and setup motion on the Raspberry Pi.

Then edit the config file.

The above changes made to the config are only a handful of the options you will see inside the file. The general idea of the changes I made are to turn off video recording and to tell motion to take a snapshot every 10 minutes and to then save the file to the images directory. Feel free to play around but these settings will get me doing what I need to do.

Start Motion on the Raspberry Pi

You probably want to start motion in debug mode the first time around just to make sure everything is as it should be.

This will display output to the screen and every 10 minutes you should see snapshots getting saved every 10 minutes.

Check the directory and download the images to make sure you are getting the desired output and if all is as expected you can now start the motion service.

That’s it! Raspberry Pi and Motion is now set up. Pretty easy and straight forward. Like I said though, this is one of the more basic uses of motion and it can be used to do a lot more. Have a play around and let me know what you come up with. I’m always interested!

The next part of this tutorial series I will be showing you how to write a python script which will be executed using the motion action trigger.

So stay tuned and as always you can follow me on twitter @JAGracie

 

 

, ,

2 thoughts on “Raspberry Pi and Motion (Weather App Pt 2)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">