Remote watching by USB Webcam

Set USB Webcam up for taking photos periodically and sending it to the MONITOR™ service. You can watch the latest photo with your Web Browser through the MONITOR™.


Prepare follows:

  • A board computer with an internet connection and USB port, for example, Raspberry Pi, Beaglebone and so on.
  • USB Webcam connecting the USB port.

Then open a console and install "View2".

Install of View2

download from release


git clone

Setup of View2

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


Confirm your view_id of the MONITOR™

With your Web Browser, make sure your view_id MONITOR™.

Set view_id

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

./ axwdjqwy


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


You may see the following sequence of log In case everything succeeded, expected response is consist of the log of taking a 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 a 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 the correct view_id was set by command.


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

./ test

With the 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, the most possible 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 minutes interval after the device is turned on by command as follows:

# set autostart on
./ --on

Also, turn off as follows:

# set autostart off
./ --off

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

You can confirm the current status with --status option:

./ --status

You may see the 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 for key input, type "q" key.

In case of 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 implementing your own application of sending a photo 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 the 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 least a 1-minute interval of sending a photo.

In case using the 3G network, typically, 5$ - 10$ cost per 1GByte network traffic. To keep monthly network traffic about 1GByte, keep to monthly sendings about 10,000 times, in other words, 330 times a day, 13 times an hour, 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 quality picture that to provide some delay and to throw first several photo.

results matching ""

    No results matching ""