Flyport FTP Webcam

From openPicus Wiki
Jump to: navigation, search


Project Summary

This is an extension to the Project Flyport WEBCAM which contain the details about driving the camera module and setting up the FTP communication. This extension is about the camera set-up over web page, it also includes new features like a light detector and a PIR (IR motion sensor) function (Openpicus Grove sensor module). A “web-based debugging window” was also added to allow to monitor the UART output when the Flyport is not connected to a PC. The current code was tested with Flyport Wi-Fi 802.11G using the IDE 2.4 which includes a couple of key improvements and bug fixes to run the webcam non-stop!

Web page structure

The web page structure is divided into 3 pages, “Home” is the main page showing the last picture taken in the centre, a status window on the left hand side and 3 buttons on the top right to switch to configuration pages. “Config1“ links to the standard Wi-Fi set-up page, and “Config2” menu links to the FTP set-up and to the camera features. The starting point of set-up pages was (OP-AN-009). The html and JavaScript was modified to create this solution.


On the left hand side, You can identify the LED type display from the standard template:
1. Manual trigger
2. Timer trigger status
3. Motion trigger
4. Sending data
5. FTP connected
Only the 1st button takes an action, all other LED's are status display only. Also a click on the picture will initiate a new picture to be taken and sent to the FTP server + displayed on the flyport window.
On the bottom of the status column, you can see a status bar showing the Light level in case you add a LDR sensor to the board (more about this under «Hardware configuration» in this document). A copy progress bar maybe added in a future version.

The picture display area shows the last picture taken and sent to the FTP server. It allows to check that the pictures are send properly to your FTP server. The fix part of the path can be set in “config2” screen. The variable part (picture name) is added dynamically to the web page. Both public web and local FTP (NAS) server have been tested.
The current version does not allow to display older pictures on the ftp-server.

Hardware configuration

Zc2.jpg The above Fritzing drawing shows the components and cabling of the various web-cam elements as they are programmed within the Flyport Webcam.

Bill of materials

- Openpicus USB Nest or Grove Nest (Grove module can be used as well)
- Flyport Wi-Fi 802.11G G have been tested
- VC0706 based Serial camera module, Adafruit/Sparkfun, both running at 38400 baud - Grove PIR Sensor, delivers «1» signal when motion is detected (optional)
- FTP/Cam parameter memory 24C08 DIP8 or SO8
- LDR + 10kOhm resistor to measure light (stop camera during night)

Notes on BOM

-Memory: As the Flyport does not include any EEPROM, a I2C 8kbit memory chip was added. This component will store all FTP data + the camera options shown on «Config2». The component will store all data and keep them during reset or power-down of the webcam.
-PIR Module: The interface to the Flyport board is very simple, but the adjustment of the two potentiometers gave me some hassle as very sensible. You may use the Grove sample that displays the status on the Flyport to calibrate the board, then load the web-cam code.
- LDR: As picture get very bad at low light, I added an LDR to switch of taking pictures during night time. The light level is shown on the main page and the level of light that switches off the camera function is also adjustable via WEB page on «Config2» menu. A simple 10k resistor pulls- down the LDR that is connected to IN2 and to VDD (3.3V) on the other side. This results in ADC value is proportional to the light, the measured value varies from 0-1023 inside the Flyport.
-Power: You will need to power the board from a separate connector if you do not connect the Flyport USB connector to a PC. I tried to use a USB power adapter that does not work with the Flyport FTDI232 set-up! A direct connection of a 5V external power supply works fine.

Wi-Fi Set-up «Config1»

This configuration page copied from «OP-AN-009» allows to configure the Flyport connection to the local WIFI Server. As a minimum, you may need to use DHCP, an SSID and a Security set-up. Using IP address was not tested yet!


You can notice on the above picture that the DHCP status, SSID and Security type are shown after saving the set-up. The original OP-AN-009 code was modified in order to display this data (was not done in the original code). !! Once started, you can set-up the Flyport using this configuration page. It is important to move from one to the other field using the TAB key. DO NOT USE the “Save Settings” button until all data are entered. If you did this by mistake, you will need to reset the Flyport. The Flyport will keep for 1min30secs in configuration mode. During this time you can change the default configuration and customize it to your local set-up. One connected to your local network, you will be able to set- up the FTP server configuration.

FTP/Webcam «Config2»

This page is divided into two parts.
The first part allows you to connect to your favourite FTP server that should have enough space to store thousands of pictures.
The «FTP Address, FTP User and FTP Password» are straight forward, can be tested with Filezilla before setting up the WEBCAM. The «Remote Dir» indicates on which directory the pictures will be stored on the FTP server, the directory needs to be created before connecting the WEBCAM. Once running, the WEBCAM will send a specific FTP command each time a picture is sent. Multiple directories should be defined in case you want to set-up multiple WEBCAM.
File Name: The WEBCAM will time-stamp each picture sent to the FTP Server using the SNTP mechanism and the RTCC real time function of the Flyport. The «Time-Zone» menu entry will adjust the time to your local time zone. A letter will follow the time-stamp indicating the trigger reason of the picture.
The menu «Picture WEB location» allows to indicate to the Flyport where the pictures are available over an URL. This URL will be included into the main page to locate the last picture. Indicating both, “Remote Dir” and “URL” was chosen as the FTP directory may be different from the WEB path. We tested the connection to a local server using “ftp://ip/path...” and the connection to a remote ftp server using “”.


WEBCAM parameters

This menu allows to modify your webcam set-up according to hardware you installed.
- PIR/CAM/Off enables the PIR sensor on IN5 of the Flyport or the Camera motion function.
- Repeat will make multiple pictures for example after a sensor detected motion.
- Auto-shoot allows to make automatic pictures every 1min/10min/1hour/1day. Timing is directly linked to the available RTCC delays, so no other delays are yet possible.
- Daylight sensor ON will disable the camera automatic function in low-light conditions. The valid light level can be set from1 to 1023. In general I used value from 1-100 to get only usable pictures.
! The Daylight sensor has no influence if a PIR/Camera motion sensor is used. PIR/CAM motion will always trigger a new picture to be sent to the FTP server.

Debugging window

As taking pictures was hanging over time with the camera installed outside, a debug window was added to the flyport web-page.
The black terminal style window gets the text normally sent to the UART port. This allows to follow what is going on inside the camera even when not connected to a PC.
In the current implementation, the debug window appears when you click on the light-sensor bar, so it is hidden when not required. Technically a simple window was added to display text, adding text was done inside Java-script.

<div id="console">
<span style type="text/css";>
WEBCAM output<br> </span>
...javascript part ...
var txt=getXMLValue(xmlData,'con0');
if(getXMLValue(xmlData,'con0')!= null)document.getElementById('console').innerHTML += '<br>'+txt; ...

How does it work?? Inside the code, I replaced UARTWrite(..) with UARTWriteX() this routine sends a message to the UART and copies the same text to “ConsoleString”, sets a flag “Newstring” to indicate to the HTTP interface that a new string was sent. Inside HTTPapp.c, HTTPrint_con() checks this flag and sends the string to the web page each time a new string is available. With this set-up, the OPENPICUS libraries where not touches, means it can easily be migrated to other applications.


Final remarks

1. Set-up the WIFI parameters and reboot before setting the FTP parameters.
2. Every change of the WIFI parameters stored will reset the FTP parameters
3. The FTP parameters can be modified at any time and will be activated immediately.
3. If you mistyped the WIFI parameter, reboot the Flyport and define the new parameters within 1 minute 30 seconds configure time.
4. The WEBCAM will continue to work even if you do not have a WEB-Page open.
5. There is currently no protected mode for the set-up as the camera is intended to be connected mainly on your local LAN!
Enjoy using the code, send your comments if any to

Source code

You can download the entire project here (for IDE 2.4 or newer)

Personal tools