I have created a weather cam that runs on a Raspberry PI mini PC and a Logitech HD C270 webcam that is overlay’ed with the current observations via Cumulus running on another (windows) pc.
These are more like notes than instructions.
YOU NEED TO KNOW; How to use wheezy linux (debian), How to set up Cumulus. to understand my instructions. Don’t ask me, google everything as I did.
This project requires the following:
Windows pc running Cumulus.
A web host with FTP capabilities to host your image and files.
A Raspberry Pi mini computer.
A webcam that successfully operates with the Raspberry PI (the C270 is plug-n-play)
Here is how I did it;
On the PI I installed:
fswebcam
imagemagick
libav-tools
ncftp
On the windows pc in C:\Cumulus\web\ I created a file called “overlay.sh”. This file needs to be processed by cumulus (see: cumulus help) and FTP to your web host in realtime mode.
Here it the script:
Code: Select all
#!/bin/sh
sleep 05
cd /home/pi/weathercam/
#places the icons on the image
composite -geometry +4+260 gauges.png rear.jpg \
rear3.jpg
#adds the trend arrows for temp and barrowmeter.
composite -geometry +129+282 <#temptrendtext>.png rear3.jpg \
rear2.jpg
composite -geometry +140+400 <#presstrendenglish>.png rear2.jpg \
rear4.jpg
#add the current readings
convert -size 75x20 rear4.jpg -pointsize 25 \
-draw "text 47,302 '<#temp>°F'" -fill white \
-draw "text 45,300 '<#temp>°F'" -fill black \
-draw "text 47,332 '<#hum>%'" -fill white \
-draw "text 45,330 '<#hum>%'" -fill black \
-draw "text 47,362 '<#wspeed> mph'" -fill white \
-draw "text 45,360 '<#wspeed> mph'" -fill black \
-draw "text 47,392 '<#wdir>'" -fill white \
-draw "text 45,390 '<#wdir>'" -fill black \
-draw "text 47,422 '<#press> in'" -fill white \
-draw "text 45,420 '<#press> in'" -fill black \
rear.jpg
sleep 3
./upload.sh
Code: Select all
#runget.sh
#!/bin/sh
cd /home/pi/weathercam/
fswebcam -c /home/pi/weathercam/fswebcam.conf
wget http://host/path/to/your/overlay.sh
chmod +x overlay.sh
sleep 2
./overlay.sh
Code: Select all
#upload.sh
#!/bin/bash
rm overlay.sh*
ncftpput -t 30 -u username@yoursite.com -p password yoursite.com / /home/pi/weathercam/rear.jpg
cp /home/pi/weathercam/rear.jpg /home/pi/weathercam/image.jpg
#If you have a weather underground PWS FTP account, then remove # from below.
#sleep 2
#ncftpput -y -t 60 -u yourCAM1 -p password webcam.wunderground.com / /home/pi/weathercam/image.jpg
sleep 2
rm rear2.jpg
rm rear3.jpg
rm rear4.jpg
rm image.jpg
mv rear.jpg /home/pi/weathercam/images-today/0$(date +%H%M).jpg
Code: Select all
#mov.sh
#!/bin/bash
cd /home/pi/weathercam/images-yesteday
rm *.jpg
cd /home/pi/weathercam/images-today
cp -fr *.jpg /home/pi/weathercam/images-yesterday/
sleep 5
a=1
for i in *.jpg; do
new=$(printf "%04d.jpg" ${a}) #04 pad to length of 4
mv ${i} ${new}
let a=a+1
done
avconv -r 10 -i %04d.jpg rear.mp4
sleep 3
ncftpput -DD -t 30 -u username@yoursite.com -p password yoursite.com / /home/pi/weathercam/images-today/rear.mp4
rm *.jpg
Another file called “fswebcam.conf” needs to be created to drive the camera. Remove the ## to use other options:
Code: Select all
device /dev/video0
resolution 640x480
##set brightness=52%
##set contrast=15%
##set saturation=19%
font /usr/share/fonts/truetype/freefont/FreeSansBold.ttf:18
##overlay /home/pi/weathercam/your custom logo.jpg
title "Hometown, USA."
subtitle "Looking Northwest"
timestamp "%m-%d-%Y %H:%M (%Z)"
##info "additional info"
jpeg 90
save /home/pi/weathercam/rear.jpg
palette MJPEG
Save these images to your weathercam folder:
http://w2swr.com/downloads/index.php?fo ... FtLWZpbGVz
gauges.png Falling.png Rising.png Steady.png
Now create two subfolders in /home/pi/weathercam/
images-today
images-yesterday
Last thing you need to do is edit your PI’s crontab and add the following:
Code: Select all
# Builds and uploads an image every 5 mins on the fives.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/wundercam/runget.sh
#Builds and uploads a timelaps mp4 every night.
56 23 * * * /home/pi/wundercam/mov.sh
#dumps the trash each night
41 23 * * * rm /home/pi/.local/share/Trash/files/*
41 23 * * * rm /home/pi/.local/share/Trash/info/*
Mike, W2SWR