Things used in this project
I always wanted to build a wireless security camera with full control on its programmability / features and the possibility to hide it inside a very small, anonymous box.
Few weeks ago I started building it using the Arietta G25 board.The base elements of the project came from a sample application to stream video. I've built on top of that example using a specific HW configuration and different SW.
Please note: this is my first project publishing and I hopefully wrote enough detail. Also, it is the first delivery and I will later update it with some access control details and IoT integration steps. Please read it once before starting so that you are aware of the small issues and workarounds that I've found.
I will list first the HW instructions to assemble the device and then move to the SW configuration.
The board is based on a ARM 9 (Atmel AT91SAM9G25) at 400 MHz with 256MB of RAM and microSD for the OS (see picture below). You can add a WiFi module just on top to add network connectivity. It runs Debian Linux and has a good number of I/O ports.
I've used a Microsoft Lifecam webcam but you can use any USB based webcam that has drivers on Linux distributions and is compatible with Motion.
See the HW section for the components list.
Opening the webcam to grab the sensor board
The webcam is very simple and can be easily opened to grab its board and sensor without breaking the whole thing:
You start by unscrewing the two small screws on the back of the camera to get rid of the front side. It has a small plastic clip but it will come away easily with the help of a small screwdriver.
Once opened you will see two more little screws on the sides of the sensor board. Removing those will allow you to lift the board. Be slow and careful here. You will see this:
You will see that the USB cable is locked probably with glue to the center of the back. If you succeed in unlocking it from the case you can try and pull some more cable (10 cm) from the case before cutting it. Ever since I was not able to unlock the cable I decided to simply cut it at the level of the case just to extract the sensor. I then soldered the cable back to the proper board pins. The board will look like this:
There was some white and hard glue close to the wires, I didn't remove it completely to avoid the risk of stripping away components...
You will notice that there are two black wires soldered to the cable shield. One is for the metal shield for the microphone: you can cut it away. A second one is connected to the board on the pin marked C in this picture. Apparently, it is not needed by the webcam, so I just unsoldered that (you can just cut it away if you prefer).
Ever since I've cut the wires so short inside the case, I took a longer piece of shielded cable from the original USB cable and replaced the wires on the board one by one, soldering them to the corresponding pinout. Be patient and use a small soldering tip here.
There was also a small piece of scotch tape around the sensor: I actually removed that, but I think I will place something similar again when mounting the whole device in the final box.
So now you have the 4 USB wires to be connected to a USB port on the Arietta. First look at this picture for the webcam pinout:
Wiring the Arietta and webcam boards for USB and power
I decided to power the whole thing using a simple 5V - 700 mA cell phone charger. So the 2 wires (+5V and GND) coming from the charger will power both the Arietta and the webcam. This is the wiring diagram for USB and power:
Attaching the WiFi external antenna
Next thing to wire is the antenna coaxial cable, using its tiny plug. Be careful: I've used a magnifying glass in order to avoid destroying the whole thing with my BIG fingers... :-)
On the opposite side of the coax cable there's a small golden SMA female: you will attach the WiFi antenna to this plug. See following pictures:
How to attach to the serial debug port
In order to connect, work and debug in a easier way I decided to use a serial debug cable.
The Arietta has 6 pins available for a serial debug port and ACME Systems sells a complete debug port adapter. Ever since I already had a USB to TTL cable adapter with proper chip and voltage levels that I used for the Raspberry PI, I decided to reuse that soldering a 4 pins male header to the board.
It is really useful since you can follow the whole Linux boot sequence and also connect and work using a simple terminal client like Putty.
See the pictures below for the correct header placement:
Operating System setup
You can purchase a microSD with the OS ready to use
You can download an image file of the OS from the manufacturer website at http://www.acmesystems.it/binary_repository On that page you will find full instructions and links. But here is a quick recap:
- depending on your laptop OS, use the suggested SW to write the image file to your microSD
- depending on the microSD size you've chosen, follow the instructions to extend the partition and be able to leverage the space (I already had a 16 GB one so...). In the forums I've read suggestions to use fast and quality microSDs. I had a class 10 by Samsung and it worked very well.
About Arietta's USB ports, their speed and this project
The Arietta has 3 USB ports:
- 1 full-speed usb host (port C) (this is slower)
- 1 high-speed host/device (same port lines used for the microUSB port) (port A)
- 1 high-speed host (same lines used for the WiFi adpter) (port B)
This means that if one wants to use the webcam at full resolution (1280x720 in this case), he will need to use port A with this configuration that includes the WiFi module. Fortunately this conflict can be solved.
In order to use port A, we will need to avoid using the g_ether driver that is configured by default to get network connection via the microUSB connector. You will see how in the steps below.
Why I strongly suggest using the debug port
Arietta, just like the Arduino is accessible and programmable using a micro USB connector. Since we will disable the config to use the microUSB for networking, I strongly suggest to start and continue using the USB to TTL debug cable, connected as described in the HW steps, for the first 4 steps at least.
On this page http://www.acmesystems.it/tutorials you will find several ways to connect to the Arietta depending on your OS and the preferred channel (serial or network). Please refer to the links in this page for the suggested SW and methods.
1) connect to Arietta and open a terminal session
Plug the USB to TTL debug cable in a usb port of your laptop/PC a driver should be activated automatically.
Here I've found an issue: I'm using Windows 8.1 and the "Prolific" driver for my R-PI USB to TTL debug cable seems to be no longer supported. I tried some workarounds but with no success unfortunately. I also have an Ubuntu Virtual Machine running on VirtualBox, so I've run that VM and enabled the Ubuntu driver for the USB to TTL cable from the VirtualBox VM menu . This one worked immediately.
On the Ubuntu desktop, open a Terminal window and start a connection with Arietta using this command:
sudo screen /dev/ttyUSB0 115200
where /dev/ttyUSB0 is the device id assigned to the debug cable by default.
2) power-on the security camera
Double check all your wiring, prepare the cell phone charger and power-on the device you just wired. Hopefully, you will not see smoke and you will be very happy about this :-)
You will notice that a small red LED will start blinking on the Arietta board and you will see lots of Linux messages, boot related, appearing in the terminal connection window on your laptop.
Wait for the boot sequence to complete. A login prompt will appear.
3) login to Arietta and modify its network configuration
Enter the following default credentials:
You are now connected as the root user, so you will have all the permissions needed to perform the next steps. You will also have the permissions to create issues :-) so be careful.
I've published on github a set of configuration files copied from my Arietta. I kept the same folder structure so you will know where they have to be copied, replacing the existing ones.
Download the zip file on you drive and open it to your preferred folder.
4) edit your WiFi details
Using a text editor on you laptop open the file /etc/network/interfaces
You will notice a block of lines commented out with asterisks. I did this in order to disable usage of network through the microUSB port. This way the g_ether driver will not use the USB port A that we want free for the webcam.
Now you will have to customize some of the parameters in order to connect to your WiFi.
Ever since most of the home networks should have at least wpa security enabled, I've copied the configuration for my one, changing my real security and config details (IPs, wpa-ssid and wpa-psk).
I wanted to have a static address assigned to this device. I've chosen 192.168.0.24 (within my network address range) and specified this and my network gateway 192.168.0.1 in the file. You can/should customize these for your network and preferences.
Enter your WiFi network SSID (network name) in place of YourNetworkSSID
The value to be specified for wpa-psk has to be generated starting from your wpa pass phrase. Enter this command in your terminal session to be executed on the Arietta:
wpa_passphrase yourSSID yourPassPhrase
the program will answer with few lines similar to these ones:
copy your long exadecimal string and enter it in the editor on the laptop replacing the value for wpa-psk:
iface wlan1 inet static
address 192.168.0.24netmask 255.255.255.0
gateway 192.168.0.1wpa-driver wext
wpa-ssid YourNetworkSSIDwpa-psk keyGeneratedUsingWPA_PASSPHRASEonYourSSIDandPassphrase
Save the file on your laptop for backup and reference. Then select and copy its whole content to the clipboard.
Now inside the terminal session enter this command to edit the Arietta network configuration file:
the editor window will open, hit F9 (delete line) until you have deleted all the file content.
Now paste what you copied to the clipboard from the corresponding file (right-mouse button options, depending on the client you are using):
Hit CTRL-O to save overwriting the file
Hit CTRL-X to exit nano (the text editor)
5) reboot the Arietta to start WiFi usage
At this point you can power-off the Arietta. Wait few seconds and then power-up again.
Debian Linux will reboot and the WiFi network connection should be established. Depending on your overall network configuration the time taken by the Arietta to get a network link up will be shorter or longer. In my case it is usually up in less than 1 minute from boot. You will see a specific message about this at the end of the boot sequence messages coming through the debug cable:
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
I plan to investigate how to improve this timing, any suggestion is welcome :-)
6) open the Arietta default web page with your browser
Open your browser and enter a url based on the IP address you configured ( 192.168.0.24 in this example): http://192.168.0.24/
You will get the following page content:
7) Additional software installation
From now on, you have various connection options to work on the Arietta: keep using the debug cable+terminal session OR connect via network to the configured IP address using the PuTTY client on windows OR using the web based Linux shell.
Please note that, when using the web based shell, you will connect using the acme/acmesystems default credentials. In order to work with root permissions you will need to run this first command after the login:
and enter the acmesystems password when requested.
Once connected through a terminal session you will now perform some sw installations:
Install HTOP for easier management of processes and memory usage checks (if needed):
apt-get install htop
Install Motion , a powerful open source sw that allows the creation of this security camera
apt-get install motion
During my first tests I realized that, should the power go away you would lose the correct date/time unless you add a backup battery. I didn't want to add a battery to this project since I want to keep it small.
It's important to get the video frames stamped with correct date/time and also to have Motion creating the video folders with correct/current date.
So I decided to install the NTP daemon because it will set and keep synchronized the Arietta clock with network time servers:
apt-get install ntp
In a later step we will customize a bit the NTP configuration.
Motion will store images and videos in sub-folders named with the current date. During my tests I've seen that Motion was still creating some folders with OLD/WRONG dates.
That was happening because during the boot sequence Motion was starting his work before NTP had completed his own. In order to avoid this issue I did the following changes:
- disable the motion daemon
- launch Motion execution using a custom shell script
- in that script: check for internet connection availability in a loop for up to 25 times, if internet is available then set the date/time directly with the NTPDATE command and then launch Motion. Please note that, if no internet is available, then the script will launch Motion anyway so that you get it running and taking pictures (this has still some priority).
That script is ready for you between the files I placed on github. We will copy them at a later stage.
Please enter the following command to disable the Motion daemon:
update-rc.d -f motion remove
Please note that there could be other better approaches to solve this, but I did not get working suggestions during that time frame. If anyone has good advice about configuring a boot sequence... it's very welcome.
8) install WinSCP on windows
WinSCP is free utility to explore a remote Linux file systems using the SCP protocol.
You can download and install WinSCP from this link http://www.winscp.net
You will find more instructions here: http://www.acmesystems.it/winscp
The program is very easy to use and is based on two windows placed side by side, representing your laptop file system and the Arietta file system. You can easily copy files from one side to the other and create/delete/rename files and folders.
9) create some folders on the Arietta file system:
Using WinSCP go to this Arietta folder /var/www/ and create a new folder named motion
Please note that the the folder names are case sensitive, so do not change them.
After creating the folder, I've setup its permissions like you see in the following screenshot. You can open this Properties window using the right mouse button on the newly created folder. I will probably review the permissions at a later stage.
go to this folder /var/run/ and create a new folder named motion
11) customize your NTP preferred server
On your laptop open this file with a text editor:
and ensure you specify your preferred time server in place of the current one ( ntp1.inrim.it ).
I've selected that one because is the official Italian one. You can search on the web for your one and use its name here.
Save the file and exit the editor.
Always on your laptop open this file with a text editor:
do the same change also in this file from ntp1.inrim.it to your preferred server name.
Save the file and exit the editor.
12) copy the configuration files using WinSCP from the laptop to your Arietta
Copy the following files from the exisitng path on your PC to the corresponding path on the Arietta:
Within the Terminal session:
give the execution permissions to the script:
chmod 755 lanciamotion.sh
activate the motion startup script entering this command:
update-rc.d lanciamotion.sh defaults
13) reboot and test
Reboot again your Arietta powering off and on after some seconds.
Follow the boot sequence on the debug port Terminal session.
You will notice that at the end of the sequence the network connection will become available
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
the date/time will be set by the ntpdate command
18 Jul 11:56:36 ntpdate: adjust time server 220.127.116.11 offset 0.437896 sec
and Motion will be launched:
nohup: appending output to `nohup.out'
nohup is a command used to launch Motion detaching its process from the current shell session. This will hide all the Motion startup messages. If you need to debug, you will find all Motion messages stored in the file /etc/init.d/nohup.out
The webcam board blue LED will stay on signalling that Motion is using the webcam.
14) the web interfaces
At this point the Arietta will offer you two web interfaces interfaces, see screenshots below.
The motion web admin interface ( http://yourAriettaIPaddress:8080/ ) will allow you to change the configuration on the fly and control motion status:
To see the video and images captured by Motion, open your browser at http://yourAriettaIPaddress/motion this will show you a web folder with links to folders (one per day) and some .avi files (one per movement event detected by Motion).
Inside the daily folders you will see images related to movement detection events plus an .mpeg video condensing all the event frames for the whole day (sort of time lapse video).
15) streaming video
It is also possible to watch video frames flowing through Motion during its processing. You can open the stream using for example VLC or similar video player.
Please note that the framerate is low since Motion is using 1-2 frames per second to perform its processing and detect movement in the scene monitored by the webcam.
Point the video player to this URL: yourAriettaIPaddress:8081
Here is an example of the video showing the number of changed pixels (I placed a book in front of the webcam so it is very high), the rectangle highlighting the area with changes and the date/time stamped on the frames:
16) next steps
I think I wrote a lot, probably too much, Please let me know your feedbacks, really appreciated.
I already have a to-do list here for the next steps.
If you use these build notes and find issues, errors or missing info just let me know and I will be happy to do my best to support.
Please note that I'm based in Italy so GMT+1 ... consider this when waiting for an answer :-)
- integrate with IoT ecosystem
- change default credentials
- configure authorizations on web access to Arietta
- configure authorizations on web access to Motion
- find a proper enclosure to finish assembly
All the files used in this project
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!