Hi everyone,
I was wondering if someone could give me some tips/help to see if I can fix a problem. I am using a raspberry pi camera to upload webcam pictures to the wunderground ftp site. I did the programming in Python myself (I'm a beginner), and everything was working as it should for the first 2 days. Now, it seems to upload the first photo and then I receive error messages and the program stops running. I have included my code, along with an error message. I was wondering if it is a wunderground problem, since everything worked fine for the first two days, not it is not working.
Thanks,
Todd
The code:
from picamera import PiCamera,Color
from time import sleep
from datetime import datetime
# set counter to 0
counter = 0
# define the camera
camera = PiCamera()
# set the camera parameters
# resolution to be set such that picture is no more than 150kb as this is required by weatherunderground.com
camera.resolution = (492,328)
camera.framerate = 15
camera.brightness = 50
camera.contrast = 0
camera.vflip = False
camera.hflip = False
import ftplib
# turn on the camera and take the picture and capture the current time
camera.start_preview()
# set counter up to work for about 2 months - 18,000 counts
while counter < 18000:
camera.annotate_text_size = 18
camera.annotate_background = Color('blue')
camera.annotate_foreground = Color('yellow')
camera.annotate_text = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
camera.capture('/home/pi/Desktop/image.jpg')
sleep(5)
# upload the picture to the www.wunderground.com ftp site
session = ftplib.FTP('webcam.wunderground.com','cameraname','password')
file = open('/home/pi/Desktop/image.jpg','rb') # file to send
session.storbinary('STOR image.jpg', file) # send the file
file.close() # close file and FTP
session.quit()
# Pause for 5 minutes (300 s) before taking the next photo
sleep(300)
counter = counter + 1
camera.stop_preview()The error message:
======================== RESTART: /home/pi/camera4.py ========================
Traceback (most recent call last):
File "/home/pi/camera4.py", line 31, in <module>
session = ftplib.FTP('webcam.wunderground.com','TJinPGCAM1','yd401$icom')
File "/usr/lib/python3.5/ftplib.py", line 118, in __init__
self.connect(host)
File "/usr/lib/python3.5/ftplib.py", line 156, in connect
self.welcome = self.getresp()
File "/usr/lib/python3.5/ftplib.py", line 243, in getresp
raise error_temp(resp)
ftplib.error_temp: 421 50 users (the maximum) are already logged in, sorry