Designed for the Raspberry Pi Zero W, takes pictures preiodically and uploads them via FTP. This will start firing shortly before the sunrise and stop firing shortly after the sunset based on your latitude, longitude and timezone.
Any Raspberry Pi with wifi should work. But I used this bundle from Amazon. Also any camera should work, either USB or one like the one I used this one
1. Download RASPBIAN STRETCH LITE
Create Boot Drive on your micro SD card with your preferred flasher. I used Etcher. Once your micro SD card has been flashed, remove it from your computer and plug it back in so your computer will recognize it.
Open up the drive that you created and add a file in the root of the boot drive named SSH. This will enable SSH into your Raspberry Pi since the latest builds do not enable SSH by default.
Since we're using a headless unit and will be doing most of the work on another computer, you'll need to add your wifi network to the device so it can connect automatically. To do this, Create a file in the root of the boot drive called wpa_supplicant.conf. This is commonly used by Linux devices. Here's a template of what to include in the wpa_supplicant.conf file. Once those two files in the boot drive, you can try it out in your raspberry pi zero w.
```
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
priority=1
ssid="preferred wifi's SSID"
psk="preferred wifi's password"
key_mgmt=WPA-PSK
}
network={
priority=2
ssid="secondary wifi's SSID"
psk="secondary wifi's password"
key_mgmt=WPA-PSK
}
```
Once the Raspberry Pi boots you should check to confirm that it connected to your network. I used Angry IP Scanner for this.
Open Putty and attempt to connect to the raspberry Pi via SSH with the IP address found from Angry IP Scanner. SSH uses port #22 by default.
Another tool that I like to use is PSCP (Also found on the Putty site). PSCP is a secure copy scripting tool used in copyFromPi and copyToPi. These scripts were mostly used for development purposes because it was easier to make code changes on my windows development machine and push the changes over rather than making coding changes in SSH on the Raspberry Pi. So in order to jumpstart the setup, edit copyToPi to include the proper IP address and username and password (if you changed them already) then push the files over to the Raspberry Pi.
Install pip on your raspberry pi. Through putty, run the commands:
sudo apt-get update sudo apt-get install python-pip
If you've copied over the requirements.txt file, you can run
pip install -r requirements.txt
Otherwise, you'll have to install the packages listed in the file individually.
You'll need to enable the camera before testing it out. Again with SSH on the Raspberry Pi, run:
sudo raspi-config
1. Select Interfacing Options,
2. Select Camera,
3. Then Yes for enabling the camera
4. Select Exit to finish
This Requires a reboot but will initialize the camera when it boots.
After rebooting, try to run camera_test.py to confirm that your Raspberry Pi's camera is functioning. If it creates the picture.jpg file then the camera is working as expected.
The last part of the app is sending the photo via ftp. In order to test this, I installed FileZilla Server. I ran FileZilla on 127.0.0.1 so that it could be accessed from the lan. One important note: Windows will not allow ftp by default. In order to accept the connection, I had to disable window's firewall.
If you want to run the python process in the background then run it using
sh run.sh
and kill it using
sh stop.sh
Otherwise, you can simply run it on the terminal's process with
python webcam.py
- Aaron Preston - Initial work - KidPresto
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- I would like to give a shout out to the SunriseSunsetCalculator for providing the sunset/sunrise time functionality
This module has only been tested on Python 2.7.13 on Jessie Raspbian