The Sony Spresense Development System with integrated GPS and 5M pixel camera seemed well suited to implement a portable surveillance system. My idea was to build a solar powered pan/tilt camera unit that could capture images with location information. It would have a small color LCD display to help initial setup by previewing the camera image and overlaying the GPS status and location information. It would also include a PIR motion sensor to trigger image acquisition. The one feature that the Sony system lacks is a means of radio communication (BLE or WiFi). To solve that problem I'm adding an ESP8266-01 WiFi module.
I want the camera to be a standalone unit so I used a 2 foot long 6 inch diameter PVC pipe as a pedestal and a 3D-printed endcap as the baseplate. I decided to stack the system components vertically on the baseplate as horizontal slices using plastic standoffs to connect the slices. The power supply is on the bottom, the circuit boards are in the middle and the pan/tilt unit with the camera is on the top. The LCD is at the rear and the PIR sensor is in the front. For outdoor use I got an acrylic vase to use as a canopy and printed a collar to attach it to the baseplate.
1 / 3 • Camera on Pedestal Mount
The solar power supply is split into two sections. The actual power supply uses a micro USB input, so I've created a solar module front end to convert the solar panel output to a USB voltage output. The 3.5W solar panel is rated at 18V @ 190 mA at its maximum power point (mpp). I am using a USB output step down converter that is rated up to 24V input and 5V @ 3A output. I expect that in full sunlight I should be able to get 500mA of charge current.
1 / 3 • 18V 3.5W Solar Panel with Buck Converter
Portable Power Supply
I used an RPi UPS Supply from MakerFocus. It is designed to pass the input 5V from the micro USB input to 2 standard USB A female connectors and also a 2 pin header. It has a battery interface to charge the battery when there is excess current available from the micro USB connector and to provide a UPS function which supplies 5V to the outputs when the micro USB input power is not available. I am using a short USB to right angle micro USB cable to supply power to the Spresense boards. I use the 3.3V from the Spresense Extension board to power the ESP8266. I use the 5V from the 2 pin header on the UPS board to power the servos and the PIR detector. One of the challenges is to figure out if power can be managed to make the 3800 mAh battery last during periods of no sunlight.
1 / 2 • UPS with 3800mAh LiPo Battery
Just a couple of pictures showing the piece that I printed to mount the boards and LCD and then the one to mount the pan/tilt servo assembly with the camera. I don't have an intermediate picture of the assembly of the parts on the proto board but you can see the rats nest of wiring in the completed assemblies.
1 / 2 • Spresense boards, LCD, and proto PCB
GPS Location and Camera Preview on LCD
The camera library has a "viewfinder" mode that allows the streaming of camera images using a callback function. I am using a 160x128 resolution LCD that uses a ST7735 controller. I used the modified Arduino Adafruit TFT library that was tweaked for the Spresence by Karl Komierowski. The preview mode only uses a 320x240 YUV format for images but the image library has a function to convert YUV to RGB 565 that the LCD uses. To fit the LCD resolution I am only displaying every other column and row of the image. I am overlaying the GPS status and position data on the image.
The following is a short video that shows the progression after power up. The GPS initially has no position or time. Next as satellites are acquired time information is obtained from a satellite. And finally the latitude and longitude are determined.
Pan/Tilt Servo Test
I am using the Servo library and two PWM pins from the Extension board to drive the pan/tilt servos. Here is a short video of the assembly moving through a patrol sequence.
Internet Connectivity using ESP8266
The Spresense has 2 hardware serial ports. The first port, Serial, is used for the USB interface for programming and debug. I used the second port, Serial2, to interface with the ESP8266. The interface is straightforward -- the ESP8266 is used as a modem using the AT command set. For a quick demonstration of functionality I connected to the ThingSpeak API and logged the GPS Latitude and Longitude data to a private channel. In the plots below you can see the values converge as the GPS obtains its position fix. And the debug data sent over the USB interface is also shown.
1 / 2 • ThingSpeak Channel
PIR Sensor Test
I am using the PIR sensor to trigger an interrupt and an interrupt service routine (ISR) to control the interrupt response. My initial thought was that the camera would take a high resolution picture when an object was detected. Unfortunately, Sony support verified that the takePicture function will not work in an ISR (I was getting kernel panics). I am still thinking about a workaround but to demonstrate PIR functionality I decided to send a notification to the Pushbullet app on my iPad using the IFTTT Maker Service in response to a detection. One issue that I ran into is that the Spresense Extension board has a 1K pullup to VCC (3.3V) on the inputs. The HCSR501 sensor that I'm using has a 1K series resistor on the signal output so this has to be shorted out to allow the pin to switch to a low state.
Due to time constraints and some hardware and software issues I was not able to complete the unit with the functionality that I wanted.
From a hardware perspective, I completed all of the elements that I had planned. I wanted pan capability of +/-90 degrees and tilt capability of +/-45 degrees. With the setup that I am using (a 6" FFC cable for the camera) I need to restrict the pan to +/-45 degrees so that I don't damage the cable. I did have a hardware failure -- the UPS unit failed after a couple of weeks so I wasn't able to perform any power tests. It appears that the boost IC died and the battery voltage is just being passed through. I am waiting on a replacement unit.
From a software perspective, I was less successful. I had wanted to have more interactive capability, i.e. being able to control the unit remotely over WiFi. I need to change the ESP8266 functionality to being a web server rather than just a modem. I'll do this as a future software upgrade as the hardware already supports it. Plus I also wanted to send snapshots to the mobile device. In addition to not being able to take pictures in an ISR, I also have to figure out how to send image data over serial (this is just formatting that I haven't had time to sort out).