Adding a weather cam image to my site


An evening shot from my Pi cam…

Ever since I launched my weather site, I have linked to the Kalbar webcam which is one of the many webcams published on the Brisbane Storm Chasers site. While this camera has excellent detail and gives a good indication of approaching storms, it is located about 10km from my place. This camera is pointed in the direction of Cunningham’s Gap on the Great Dividing Range from where we can get storms however it is more common for the storms to come from a slightly more southerly direction just out of camera shot.

I have always wanted to have my own webcam set up to keep an eye on the weather and as my place has a reasonable elevation, I always thought it was doable. Of course, as my son told me, I could just look out the window but where is the fun in that?

To put this into action, I’ve been toying with the idea of getting an IP security camera as the outdoor ones come in a weatherproof enclosure, are wireless and seem relatively easy to set up. Something like the Foscam F18905W which sells for about AUD$180 has all the features I would need.

But then I have also been interested in the Raspberry Pi camera module. This is a 5 MP 1080p camera which to my mind is much better than the 1.3 MP 960p Foscam. I’d need a dedicated Raspberry Pi (maybe an A+ model), a Wi-Fi dongle, a power supply, the camera module and an enclosure. I should be able to put this together for around AUD$100. One negative with the Raspberry Pi module is the field of view is only 54° compared to 70° on the Foscam.

So this is what I have done albeit on a trial basis. I already had a Raspberry Pi 2 Model B with a micro SD card, power supply and Wi-Fi dongle so I purchased a camera module to go with it for AUD$39.00. 

I put it all together without any enclosure and temporarily taped the camera module to the inside of a bedroom window that had a suitable view. This was the easy bit.


Actually it all ended up being reasonably easy. Here is the process I used to get the camera working and publishing a regular photo to my web site.

First up I loaded a fresh Raspbian image (the operating system) on a micro SD card, plugged it into the Pi and configured it so that the Pi ran headless (remote access over SSH without an attached keyboard or monitor) and used Wi-Fi over the attached dongle. I also went into raspi-config and enabled the camera.

I didn’t have too many false starts after this. After doing some research on the web, I got the camera to take some stills using the raspistill -o cam.jpg command. Easy as!

So I can take a photo but I also want to resize and overlay some text on the photo such as the time the photo was taken and what it shows. So after some research I installed ImageMagick.

sudo apt-get update
sudo apt-get install imagemagick

ImageMagick has a number of commands like convert -resize or convert -annotate that I then used to do what I wanted. To minimise the size of the images being uploaded to the web I also looked at stripping the exif data from the images. ImageMagick has a command to do this as well: mogrify -strip. It’s a powerful little program that I feel I’m only scratching the surface of.

Okay, I can produce images and overlay text on them by running commands at the command prompt but I want to automate this. So I put the commands together in this shell script that I called I wanted two images: one normal size image and a smaller thumbnail for inclusion on my main weather page. As the images are different sizes, the overlayed text also had to be a different font size to remain readable. So this is the script I came up with:


# Take image with camera
raspistill -vf -hf -w 1366 -h 844 -q 30 -th none -o /path to/camera/weathercam.jpg

# Create a smaller resolution copy for weather page
convert /path to/camera/weathercam.jpg -resize 550x340 \
    /path to/camera/weathercam-550x340.jpg

# Overlay text on original image
convert /path to/camera/weathercam.jpg -pointsize 18 -fill white \
    -gravity southwest -annotate 0 'WeatherCam' \
    -gravity south     -annotate 0 'Boonah - looking SSW' \
    -gravity southeast -annotate 0 %[exif:DateTimeOriginal] \
    /path to/camera/weathercam.jpg

# Overlay text on copy of image
convert /path to/camera/weathercam-550x340.jpg -pointsize 12 -fill white \
    -gravity southwest -annotate 0 'WeatherCam' \
    -gravity south     -annotate 0 'Boonah - looking SSW' \
    -gravity southeast -annotate 0 %[exif:DateTimeOriginal] \
    /path to/camera/weathercam-550x340.jpg

# Remove EXIF data to reduce filesize
mogrify -strip /path to/camera/weathercam.jpg
mogrify -strip /path to/camera/weathercam-550x340.jpg

The next hurdle is to upload the images to my web-server. I installed wput to do this. Wput is a command line ftp-client used to upload the files.

sudo apt-get install wput

Then after playing with it to see how it works, I created another shell script to automate uploading the images.


#Upload main image to web server
wput -B -u -nc /path to/camera/weathercam.jpg

#Upload smaller image to web server
wput -B -u -nc /path to/camera/weathercam-550x340.jpg

4th June 2018 Edit: I no longer use wput to upload the images. I now use sftp. See this post for details

Both shell scripts had to be made executable before they could be run. As I’d saved both files in a directory bin in my home directory, I was able to do this by running:

chmod +x ~/bin/
chmod +x ~/bin/

The final step is to set the timing of when the scripts are run. I did this by modifying the crontab file to automatically call the above files every fifteen minutes. This means that at every quarter of the hour, a photograph is taken, processed into two images and uploaded to the web. The last two lines of the following crontab script are the ones that do this.

crontab -e
# Edit this file to introduce tasks to be run by cron.
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# For more information see the manual pages of crontab(5) and cron(8)
# m h  dom mon dow   command
0,15,30,45 * * * * /path to/bin/
1,16,31,46 * * * * /path to/bin/

One concern I had is upsetting my neighbour if they saw the LED on the camera light up when it was taking a photo and thinking I’m recording their house. To avoid this, I disabled the LED by editing the config file.

sudo nano /boot/config.txt

and adding the following line to the end of the file before saving it.


So now I have my own weather cam image on my weather page.


Now I want to look at setting the camera up permanently and mounting it somewhere with a better view like on my roof. I’ve thought about getting one of the cheap dummy security cameras you see available and mounting the RPi and camera in that. This should be able to be hacked into a good weatherproof enclosure. I’ve also considered powering the camera from a battery pack and using a solar panel to charge the batteries. As long as the Wi-Fi signal can find its way back to my modem I should be laughing!

It would also be good to store the daily images and at a set time each day, merge them into a time lapse video for the day.

So these are the next steps. In the meantime, we can all enjoy the view of the weather from my son’s bedroom window.

23 thoughts on “Adding a weather cam image to my site

    1. Stevoz

      Hi Daz, unfortunately my wifi dongle on my Pi died on Friday so I'm waiting on a new one. It should be here today but until I get it, I am linking to someone else's webcam on my weather site. Mine should be back in a day or so.

  1. Stevoz

    "/path to/camera/weathercam.jpg" is the path and file name of the image you want to upload.
    "user:password" is your login name and password for your web host provider (separate with :).
    "" is your web server and path to your new uploaded image.

    1. Daz

      do u mind loging in to my pi and seting it up as i cant find out the way it dose it and have u got a live chat what i can get u on

      1. Stevoz

        Sorry but I can't do much right now as I'm about to go to work. I have your email address so I'll send you an email later.

  2. Peter

    G'Day Steve.
    Very impressed with your site.
    I was running wview for almost 10 years years, and then Weewx, until the laptop died.
    I ended up using a raspberry pi for maybe 2 years and the SD card spat the dummy.
    I have found some time and now have it back up, I tried using the camera, still inside, but the CPU seems to max out when taking pic's and running weewx, was grabbing an image every 5 minutes and was trying to make a animation, which works but it is rather large and the pi' hangs until it can get at least one job done.
    trying to change things from the default skins, finding the time at the moment is a challenge.

    Not far from you, on a mountain ridge east of Laidley.
    Peter VK4KHP

    1. Steve Post author

      Thanks Peter,
      I have two Pi's running – one for WeeWX and the other for the weathercam. I haven't tried both functions on the one device but maybe the newer Raspberry Pi 3 would handle it better. As you say, it is time consuming, I can waste hours tinkering with it.
      You wouldn't be very far away at all as the crow flies. I work in the Gatton, Laidley, Ipswich area so have probably been past your place several times.

  3. Peter

    G'Day Steve.
    I do the drive in and back to Brisbane each day.
    So the days can drag out, on those days when the traffic is bad.
    may have to pick you brains on some of the configurations at some stage
    I may change the reporting times and maybe drop the animation idea for a bit. and maybe do the same as you and grab an image once every 15 minutes and transfer it.
    How much do you save on an image by stripping the embeded info.

    Heading home.
    Will read your reply later.
    Cheers Peter.

    1. Peter

      That should read drive into Brisbane and Back to Laidley, I couldn't live in Brisbane, glad to see it in the rear view mirror each afternoon.
      Cheers, Peter.

    2. Steve Post author

      Yes, leaving the city is good.
      I couldn’t remember how much of a difference removing the EXIF data made to a photo so I just took a photo and made each modification as per the above file. This is what I got:

      # Take image with camera – 335833 bytes
      # Create a smaller resolution copy for weather page – 44464 bytes
      # Overlay text on original image – 348165 bytes
      # Overlay text on small copy of image – 49085 bytes
      # Remove EXIF data to reduce filesize original – 347381 bytes
      # Remove EXIF data to reduce filesize small copy – 48225 bytes

      So removing the EXIF data doesn’t make much difference after all.

  4. Peter

    G'Day Steve.
    my raspberry pi POE kit arrived at work today.
    lets me power the pi over cat5. the kit has 5volt at 2.3 amps with the power connector for the pi and the RJ45 connector for the ethernet connector.

    I was talking to the blokes in our CCTV section, they have a camera enclosure and mount for around $20.00, these are the ones used at many servos around the country. The pi should fit well and haven't decided the best way to mount the camera yet.
    hopefully i should have a weather camera up and running soon.
    I lost access to my old netspace webspace, so far iinet can't tell me why.
    Have had to reconfigure to use the iinet webspace.
    always something different each day to make life interesting.
    but the weather page is back up, and the new webspace seems more stable.

    1. Steve Post author

      That sounds good Peter. I’ll have to have a look at POE, would be much easier than getting a power point close by or running the Pi from a solar charged battery.

  5. Peter

    G'Day Steve.
    Finally have, what appears to be, at least at the moment a stable interface to the weather station.
    Now running Weewx on an Orange pi zero, appears more stable than the Raspberry pi 2.
    And the Pi 2 is now in the camera housing with the pi camera.
    I am running POE to the camera housing and it powers the pi and the comms run into a port of the router.
    I have reduced the update rate for reporting on weewx to five minutes, it was running every minute, which was causing a lot of issues.
    So far so good, it has been a few weeks with no problems.
    the site is
    the camera is pointing roughly 190 degrees, i will move it to change the view to be more a weather cam than an antenna cam. although most of our severe storms seem to come from the current view of the camera, it has been buffered by a few of the storms and needs to be leveled as it has rolled to the left a bit.
    The back antenna mast is vertical, not so in the picture. the glass in the camera housing is open to vent and i have not seen any moisture build up on the glass, even with all the rain and the 99% humidity.
    Will open the housing soon to see how well the camera and pi are doing with moisture ingress, if there is any.

    I had one webspace shut down on me, i was sending the pic's to another one and i had major issues with it rejecting FTP transfers, so it is all on another server.

    Now that it seems stable again, i can resume sending data to WU, has been maybe 10 months since the last bit of data went that way.
    Thanks for putting up your how to, pointed me in the right direction, went through a few problems , syntax and typing on my side, they took a while to sort out, annoyed a friend, who spotted the typos, in a few minutes.
    next will be animation.
    I receive the Russian Meteor M2 Satellite.
    And get some great pictures, these are digital transmitted as opposed to the American analog satellites and has a lot more resolution.
    I can't automatically receive and process them, I have to post process, but am thinking about putting the pics on the site, manual ftp each afternoon it get home from work.
    Received a good pic, that shows Cyclone Hola over Vanuatu yesterday.


    1. Steve

      Hi Peter, the weather cam on your site looks good. I've been reading up on POE since the last time you mentioned it and I have ordered some parts from China. This seems to be a good way to go – initially I was toying with the idea of a solar panel and battery with wifi comms but POE seems so much simpler.

      I was going to inject 12V instead of the standard 48V into the POE cable and have a DC-DC buck converter in the camera for the 5V Pi supply. Is this what you did or did you just inject 5V with no converter?

      Will also read up about the Russian Meteor M2 Satellite.


  6. Peter

    G'Day Steve.
    The item i bought from Ebay, has the plug pack for 48 volts which has two rj45 sockets for the cat cables one goes to your router and the other goes to your pi and camera via a length of cat cable.
    At the pi end, it has 5 volts with the connector to plug into the Pi and an RJ45 to plug into the ethernet connector on the pi.
    so the regulator is built in to the spliter, it runs cool and it it is so much cheaper and easier then building regulators .
    I haven't had any issues so far with it.

  7. Peter

    G'Day Steve.
    interesting weather the last few weeks.
    camera had a melt down on my site, well the mount moved and the flex cable connector detached from the camera board, that is the small connector on the front of the camera board.
    Made a new mount and it sits a bit back from the glass in the camera housing.
    no moisture found in the camera housing, very happy with that.
    one of the other techs at work was commenting about a pinkish area in the center of the picture, I thought the camera may have seen a bit too much sun.
    But after the new mount and seeing a few images at night, the penny dropped, the LED was on, quick change to the script ad the LED doesn't turn on.

    I am getting some great colour images from the Meteor wx satellite.
    Can you email me your email address and i will send you a few images.
    Peter VK4KHP..

    1. Steve

      Hi Peter, yes, I noticed the red glow from the LED in my photos until I disabled it. Bit of a design flaw in the camera module.
      I had a look at the current photo on your site, I can see the dust haze in the distance.
      I'll shoot you an email with my details.


Leave a Reply to Stevoz Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.