Remote watching by USB Webcam

Setup USB Webcam to take photo periodically and send it to the MONITOR™ service with a "view_id" which you got at previous Sign up chapter. You can watch the latest picture by your Web Browser throug the MONITOR™.

What you need

No matter what kind of USB Webcam can be used. Even Berry old used Webcam or just 2$ inexpensive Webcam, it's OK.

A board computer, to control a Webcam and the network acess, is necessary. Raspberry Pi, BeagleBone and these similar product is good candidate. In addition to that, even PC is good if Linux is running, USB Port can be used, and Internet access is available.

For Internet access, both flat-rate fix network and 3G network are OK. In general, remote wathing by 3G network tend to be expensively. But MONITOR™ is still image base, so by adjusting a interval of posting image, it possible to keep montly fee about 10$.
For detail of how to use 3G network, this article might be informative.

The software running on the Linux, to take photo and send it, named "View" is available at here. After here, we will explain how to install and setting of "View". If you would implement your own application, Appendix of this document might be informative.


As mentioned above, prepare a board computer running Linux and connecting internet. Then open console and install "View".

Install of View

download from release


git clone

Setup of View

Go to installed directory, Install & setup prerequired software by command as follows:


Set view_id

Set your view_id to View by command. Let's say your view_id is axwdjqwy as above picture, set it by as

./ axwdjqwy


Plug your USB WebCam to your board computer. Then, take & send photo by command as follow:


You may see following sequence of log In case everything succeeded, expected response is consist of the log of taking photo, sending it, and {"ok":true} as follows:

--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Delaying 1 seconds.
--- Capturing frame...
Skipping 20 frames...
Capturing 1 frames...
Captured 21 frames in 0.67 seconds. (31 fps)
--- Processing captured image...
Writing JPEG image to '/tmp/20180823190339.jpg'.

At the last line, {"ok":true} indicate that take & send photo are successfully finished. By Web Browser, you can see the MONITOR™ display is updated by your taken & sent photo.

In case something wrong, response finished with {"ok":false,"reason":"XXX"}. For Example:

{"ok":false,"reason":"ViewID not valid"}

In this case, you should make sure if correct view_id was set by command.


In case your MONITOR™ display is NOT updated, try command with test option

./ test

With test option, doesn't use WebCam. Instead, send a Rainbow test bars. In case Rainbow bars are shown on your MONITOR™ display, at least network connection between your device and MONITOR™ server is working well. In case still NOT update, most posible cause is that the board computer doesn't connect to the internet.

In case Rainbow bar can be seen well, at next, try command again with keep option

./ keep

With keep option, doesn't remove a photo even after send and keep it on the folder "/tmp" with the filename consist of date & time like as /tmp/20181114201302.jpg. So, please check this .jpg file. If this file seems to be broken, also confirm your WebCam device is working well or not.

Auto start-up setting

You can set that is called repeatedly at 5 minute interval after device is turned on by command as follows:

# set autostart on
./ --on

Also turn off as follows:

# set autostart off
./ --off

Tecknically speaking, set timer service of systemctl for Incase you are familiar with crontab, it's OK to set on the cron yourself instead of using autostart command.

You can confirm current status with --status option:

./ --status

You may see following sequence:

pi@raspberrypi:~/view-v_1.1.1 $ sudo systemctl status view.service 
● view.service - Take photos & Post to the monitor
   Loaded: loaded (/home/pi/view/view.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) since Wed 2018-11-14 20:42:26 JST; 5s ago
  Process: 7057 ExecStart=/home/pi/view/ (code=exited, status=0/SUCCESS)
 Main PID: 7057 (code=exited, status=0/SUCCESS)
● view.timer - Take photos & Post to the monitor
   Loaded: loaded (/home/pi/view/view.timer; enabled; vendor preset: enabled)
   Active: active (waiting) since Wed 2018-11-14 18:38:51 JST; 2h 3min ago

Nov 14 18:38:51 raspberrypi systemd[1]: Started Take photos & Post to the monito

In case waiting key input, type "q" key.

In case afte service set as off, you can see followings:

Unit view.service could not be found.
Unit view.timer could not be found.

APPENDIX A. Interface of send picture

For implement your own application of sending picture, send picture to the following url.

In this case, add viewid parameter with your view_id value.
Let's say your view_id is axwdjqwy, and take a photo by fswebcam and send it by curl as above picture, an example implementation is as follows:


filepath=/tmp/`date +%Y%m%d%H%M%S`.jpg
fswebcam $filepath -d /dev/video0 -D 1 -S 20 -r 320x240
curl -F viewid=$your_view_id -F upfile=@$filepath

Set picture size as 320x240 as above example. The file size of the 320x240 picture is, depend on the environment, about 100KByte.

Have at leaset 1 minutes interval of send picture.

In case using 3G network, typically, 5$ - 10$ cost per 1GByte network traffic. To keep montly network traffic about 1GByte, keep to monthly sendings about 10,000 times, in other word, 330 times a day, 13 times an hours, that is, 5 minutes interval is appropriate.

Empirically, when using berry old webcam and so inexpensive webcam, this is good practice for getting a good quarity picture that to provide some delay and to throw first several pictres.

results matching ""

    No results matching ""