• Changing images on a weather site using an IP camera and a simple bat file

    Foscam FI8904 IP camera

    UPDATE: The latest version of the Foscam firmware, 11.25.2.44, allows you to name the file that is being uploaded to FTP. This process is no longer needed at that point, just upload to your web server directly.

    In the second installment here of my simple bat file series, I wanted to give a small instructable on how I set up "Grandpa's Denver weather page" using existing functionality of the Foscam IP camera and a simple bat file. When looking at this I understand that some may perceive it as more of a convoluted process than a simple one, but here goes.

    My retired father enjoys watching the weather. Living in Iowa, their weather can be vastly different than ours in Denver. When Foscam had a IP camera sale going on, I snagged one of their outdoor night vision cameras with the thought that I'd use it to watch wildlife attack our garden at night and to update a low bandwidth camera page where my father could see our backyard and weather.

    The first thing I did was have the Foscam FI8904 upload an image to a local FTP server every 5 minutes via the options in its built-in web server, which you can see in the picture below. I chose to upload it to a local FTP server as I wanted to be able to manipulate the files locally, before sending them up to my hosting account.



    Once on the local FTP server, I simply run a simple bat file via Scheduled Task on my low power home server, also every 5 min, to parse the directory, rename the picture, and upload it to my hosting account. It should be noted that my hosting provider does not accept PASV FTP, so I had to download WinSCP to use in the bat file vs. using the inherent Windows FTP program, your mileage may vary.

    Code:
    set home=\\diskstation\web\kickassmeals15\foscam\
    
    
    if exist C:\admintools\gardencamupdate\filelist.txt del C:\admintools\gardencamupdate\filelist.txt
    
    
    dir /b \\diskstation\web\kickassmeals15\foscam\*.jpg > C:\admintools\gardencamupdate\filelist.txt
    
    
    @for /f "tokens=1" %%a in (C:\admintools\gardencamupdate\filelist.txt) do if %%a NEQ gardenweather.jpg copy /Y %home%%%a %home%gardenweather.jpg & if %%a NEQ gardenweather.jpg del %home%%%a
    
    
    del C:\admintools\gardencamupdate\filelist.txt
    
    
    REM Next, let's do the FTP upload
    
    
    pushd %home%
    
    
    "C:\Program Files\WinSCP\winscp.com" /script=C:\admintools\gardencamupdate\ftp.txt
    The bat file seems self-explanatory to me, but if you need explanation simply leave a comment. You'll have to register an account to comment.

    Once you have the new image uploaded to your hosting provider (with the simple bat file), now all you do is simply reference it in the web page and force the page to refresh every 5 min.

    HTML Code:
    <head>
    <meta http-equiv="refresh" content="600">
    <title>Grandpa's Denver Weather Page</title>
    </head>
    
    <center>
    <p><a href="http://www.findlocalweather.com/forecast/co/denver.html" target="_blank"><img src="http://www.findlocalweather.net/forecast.php?forecast=hourly&pands=denver+co&config=png&alt=hwicbb" border="0"  alt="Click for the latest Denver weather forecast."></a></p>
    
    <p><img src="gardenweather.jpg" name="webcam" onload="InitialImage()" width="640" height="480"></p>
    
    <p><iframe src="http://free.timeanddate.com/clock/i2un5wme/n75/fcfff/tc009/bo2/tt0/tm1/ta1/tb4" frameborder="0" width="173" height="36"></iframe></p>
    
    <P><FONT FACE="Monotype Corsiva"><a href="http://www.gayerfamilyrecipes.com">Back to Grandma's recipe site</a></font></p>
    You can see that I just made it easy, and low maintenance, on myself by using a widget from findlocalweather.com to display temperature, humidity and wind conditions vs doing something crazy like pulling it from my ecobee wifi thermostat. I used a clock from timeanddate.com, and then included a link back to my mom's recipe site. You can see the finished product here.

    Comments 1 Comment
    1. Amy's Avatar
      Amy -
      Foscam Mall is the official shopping mall of foscam camera. It provides free shipping and 2 years warranty. It also have 7x24 hours online technical service. Now it has double discount for wholesale. When camera's qty >3, 5% off.Qty>5, 8% off. Qty > 10, 10% off.
      More information, please go to www.foscammall.com.
    + Post Comment