What is Project Curacao?
Project Curacao is designed to monitor the local environment unattended for six months. It operates on solar power cells and will communicate with the designer via an iPad App called RasPiConnect. All aspects of this project are designed to be monitored remotely. Below is a picture of the tower where it will be installed in March 2014.
Project Curacao consists of four subsystems. A Raspberry Pi Model A is the brains and the overall controller. The Power Subsystem was described in part 1 and the Environmental Sensor Subsystem was described in part 2. The Camera Subsystem consists of a Raspberry Pi Camera and a servo motor that opens and closes a “shutter” that is intended to keep salt spray and dirt from coating the plexiglass over the camera.
What hardware will be used?
1 Raspberry Pi Camera
1 Adafruit Analog Feedback Servo Motor
1 Adafruit ADS1015 12-Bit ADC – 4 Channel I2C
1 Tidy Cat plastic lid for shutter
Camera and Shutter Mount
We assembled the camera mount from soft plastic and superglue. It was designed to sit just under the plexiglass. Initially, we tried to mount it on top of the plexiglass, but had a very difficult time with the short fragile cable to the Raspberry Pi. The shutter and the servo motor completes the device.
The Pi Camera software turned out to be quite simple. The important part of the Python module to take a picture turned out to be only a few lines:
# take picture
print “taking picture”
output = subprocess.check_output (“raspistill ￼/home/pi/RasPiConnectServer/static/picameraraw.jpg-t 0”,shell=True, stderr=subprocess.STDOUT )
output = subprocess.check_output(“convert‘/home/pi/RasPiConnectServer/static/picameraraw.jpg‘ -pointsize 72 -fill white -gravity SouthWest -annotate +50+100 ‘ProjectCuracao %[exif:DateTimeOriginal]’‘ /home/pi/RasPiConnectServer/static/picamera.jpg'”,shell=True, stderr=subprocess.STDOUT)
pclogging.log(pclogging.INFO, __name__, source )
print “finished taking picture”
We started out using the picamera library (https://pypi.python.org/pypi/picamera) because it was pure Python and feature heavy. We removed it and went back to raspistill (as above) because of a GPIO line conflict with the RPIO GPIO library. We wanted to use the RPIO library because it supports DMA (Direct Memory Address – this means it works with no intervention from the CPU, thus multitasking has no effect) driven PWM (Pulse Width Modulation) for the servo motor, but it is NOT compatible with picamera.
We uninstalled the RPIO library and put the latest RPi.GPIO library back in and used their software based PWM. While it is jittery (because of the multi-tasking Linux on the Raspberry Pi), we are using a servo with a feedback potentiometer for position feedback. We check the shutter position after using the RPi.GPIO PWM library by performing an A/D conversion of the pot voltage using the ADS105. We can then see the position of the servo and run the PWM again until it is within the bounds of the shutter being open or closed. With this feedback, we can accurately position the shutter even with the jittery response due to multi-tasking.
Currently, the Project Curacao main software (described in the next article), takes a picture every hour and on demand from the control program RasPiConnect. We can even email pictures on demand using our control panel. A crontab entry transfers the latest picture to a server in the US using scp so we have a prototype external webpage showing the current status of Project Curacao. The webpage is being hosted by our good friends at MiloCreek (developer of RasPiConnect) and the address is:
We are planning to add three additional features to the Camera Subsystem. These are time lapse photography, a short video on demand and a streaming video interface. A big unknown for the streaming video interface is the amount of bandwidth available for uploading data in Curacao. We know that it is an ADSL modem, but we don’t know the parameters on the upload speeds.
Camera Shutter Cover Servomotor
The camera shutter cover is designed to keep the majority of dirt and sea spray off the plexiglass in front of the Pi Camera. It uses an analog feedback servo motor so we always know where the shutter is regardless of multitasking or unexpected power downs.
The RasPiConnect control panel shows the current luminosity and the analog position of the servo motor. It also allows you to take pictures, open and close the shutter and email the current picture. The graph shows the status of the Raspberry Pi OS and of the Project Curacao and RasPiConnectServer software.
Updates on previous articles
The fan relay and the Raspberry Pi relay have been replaced with latching relays that consume no power after they have been switched. This saves 60ma. We used http://shop.ciseco.co.uk/3v-to-5v-bistable-latching-relay-kit/. Thank you to Paul Carpenter for the excellent suggestion.
We are adding a pitot tube with sensor to measure airspeed, using the Airspeed Sensor Kit
from robotshop.com. Alternatively, we are looking at using the open loop voltage of the wind turbine to approximate the windspeed (see switchdoc.blogspot.com for details). It looks like it will work up to wind speeds of about 50 MPH.
Battery Watchdog System
The Battery Watch Arduino software has expanded to about 3000 lines of code. There are certainly bugs in this software. One of the unresolved issues about the architecture of Project Curacao is that the software on the Raspberry Pi can be easily updated remotely across the Internet while the software on the Battery Watchdog Arduino can not be updated. This is because there is no current way of updating the Arduino without plugging in a USB serial port. While we are investigating options (different boot loader, figuring out a way of using the USB port on the Raspberry Pi for programming) we are looking at connecting the Raspberry Pi to make our system just a bit more resilient than it currently is.
To partially address this problem we are going to build what is called a “Dead Man Switch” in software. If the Raspberry Pi has been off for two days, then the Battery Watchdog will turn it on. This helps us recover from many types of errors in the Battery Watchdog software.
We also ran into a very subtle bug using the Serial library in the Arduino. We are using two serial ports (the main USB port and a second UART talking to the Raspberry Pi). If both ports aren’t set to the same baud rate, then they stop working after a while. With the baud rates matched, everything is very solid.
Power System Update
We have found an inexpensive 15 Watt wind turbine to add to the system. This could very well charge our system enough to not have to shutdown at night. More on how we are hooking up the turbine into and controlling it via the Raspberry Pi next month.
What is coming Up?
Part 6 of this article describes the software system used for Project Curacao. Part 7 will describe the process of installing the unit in Curacao and show the first weeks of results. All of the code used in this article is posted on GitHub at github.com/projectcuracao.