Dedicated SBC Camera Monitor

From ZoneMinder Wiki
Jump to: navigation, search

A guide to setup an SBC (Beaglebone black) or Desktop that will monitor a video feed from ZM. Simply add power, and the video feed will appear on boot.

OS will be Devuan Jessie, WM will be dwm, terminal st, and browser will be surf. It will be a minimal installation. Leaner than LXDE, the default DE for beaglebone.

I'll include optional steps to setup Device Trees and the I2C peripheral (Beaglebone specific) and read a sensor. Combine with ZMTrigger.

This is noticeably more difficult than connecting a coaxial cable to a CRT such that an analog, older setup would have. But is more flexible. A desktop is generally recommended here, but SBC's can be used as well.

After you setup this OS once, it's advisable to copy to an img and then deploy on as many machines as necessary. A good size for the single OS root partition might be 4GB.

Tested in 03/2017 on a Desktop and Beaglebone with Devuan Jessie

Note that in the end, due to faulty video display, I ended up using an old laptop instead. A BBB is able to handle one stream, but seemed to have a bug in the final deployment.

Update: 08/2018 Tested with Rpi3 and Debian Stretch migrated to Devuan Ascii here Dedicated_RPI_Camera_Monitor

Another companion to this guide is the Desktop_SBC_Camera_Monitor

11/2018: See also Zoneminder Blogspot - ODroid XU4 Zoneminder Client guide.




  • At least 4GB SD
  • SBC / Desktop / Laptop
  • Internet connection
  • Computer monitor
  • HDMI cable for BBB (I use a HDMI to DVI adaptor)

Install Beaglebone Black Debian Jessie using's BeagleBoardDebian page.

Use the direct image (under Demo, below NetInstall). Not the netinstall, which is slower, unless you know what you are doing.

After booting from the SD card, make sure the network interface is set to load in:

nano /etc/network/interfaces

Next, migrate to Devuan using Dev1fanboy Upgrade-Install-Devuan wiki guide. Skip most of the part about the display environment. Reboot after apt-get dist-upgrade. Try the purge of libsystemd0 in DE section, if you like. May not work. RCN repo seems to want it.

Complete the following commands

 su root

Remove non-free from /etc/apt/sources

 nano /etc/apt/sources.list
 apt-get install xorg libx11-dev libxft-dev libxinerama-dev gcc make htop sudo tcpdump git

For Surf

 apt-get install libwebkitgtk-dev libgtk2.0-dev linux-headers-$(uname -r)

Download simple programs

 git clone && git clone git:// && git clone git://

Edit the config for dwm

 nano dwm/config.def.h
  • Later Disable the bar
  • Later Remove all workspaces except for 1 (*tags)
  • Set Mod4Mask as modkey (redmond key)
  • Set MODKEY|Shiftmask to 0 and XK_c to XK_F12 for killclient (personal preference)
  • Later disable spawm of dmenucmd and termcmd, but for now leave enabled.
cd dwm
make install
cd ../st
nano config.def.h
  • Set termname[] to xterm (resolves some issues with programs that don't understand default termname).
make install
cd ../surf
nano config.def.h
  • Review options
  • Later set runinfullscreen to TRUE
  • Later set kioskmode to TRUE once debugging is over
make install


apt-get remove nfs-common rpcbind wpasupplicant avahi-daemon ofono apache2

Leave wpasupplicant if you use wifi. Net installer may want to install acpid. Beware of removing cron. Just disable the service. Remove Exim4 if you want.

At this point maybe 40MB RAM, and <5% CPU. Compare to LXDE.


Only needed if you are keeping time.

# apt-get install ntpdate

Set cron to run ntpdate periodically

nano /etc/crontab 
*/5 * * * * root /usr/sbin/ntpdate

This is leaner than running ntpd 24/7

Auto Start

Edit .xinitrc, /etc/rc.local, /etc/inittab, and .bash_profile to auto startx without requiring a login, load surf with the path of the zm server monitor feed, and disable the screensaver.

Added to /etc/inittab (comment out existing, and add this below. Replace username with your new user):

1:2345:respawn:/bin/login -f USERNAME tty1 </dev/tty1 >/dev/tty1 2>&1

Copy /etc/profile to user that will be auto logging in:

cp /etc/profile /home/USERNAME/.bash_profile

Appended to /home/USERNAME/.bash_profile :

exec startx

When startx loads, it will pull settings from ~/.xinitrc for USERNAME so edit that (note that .xinitrc requires & after all commands that are not the final wm).

/usr/local/bin/surf "localhost/zm/cgi-bin/nph-zms??mode=jpeg&monitor=1&scale=100&maxfps=5&buffer=1000&user=user&pass=pass" &
exec dwm

Add an additional user beside the one used for the auto login, otherwise ssh will fail. ssh will try to startx when it loads, and it won't be able to. Add USERNAME2 permissions to sudoers.

# adduser USERNAME2
nano /etc/sudoers

Disable screensaver for the first USERNAME per Arch Wiki: Display Power Management SIgnaling

nano /home/USERNAME/.xinitrc

export DISPLAY=:0 &
xset s off &
xset -dpms &

These go before the other commands in .xinitrc, as they have the & symbol. The total .xinitrc will be something like:

export DISPLAY=:0 &
xset s off &
xset -dpms &
/usr/local/bin/surf "localhost/zm/cgi-bin/nph-zms??mode=jpeg&monitor=1&scale=100&maxfps=5&buffer=1000&user=user&pass=pass" &
exec dwm

Note: When troubleshooting xset. You must be the same user that is running X (ssh in as different user, then su to user). And, you must export DISPLAY to :0 or similar. Finally xset q should query the current settings.

Fine Tuning

At this point, you should be able to boot the SBC or desktop and receive a video feed without user interaction. However there are two problems (Beagle). One, it is not full screen. Two, video may be flickering.

Flickering Video

This is a known issue with Beaglebone. The simple solution is: install devmem2 or some other memory editing program, change an address. For details of why this is occuring see: [1] and [2] or search online.


git clone
cd devmem2
make install

Append the memory adjustment to rc.local

nano /etc/rc.local
devmem2 0x4c000054 w 0x00FFFFF10

Watch syslog and FIFO errors should immediately stop upon entering write command on memory.

Install steps source: Scivision: Devmem2 on the beaglebone black The author of devmem2 (Jan-Derk Bakker, website and code found at, his website is down at the moment. You can view the root domain at internet archive, but the page for devmem2 is not available. Others like VCTLabs above have copied his code to various spots.

Full Screen Video Feed

Two options come to mind:

  • Point browser to a local html page with the link to the monitor embedded in an img tag


  • have a local web server run and point surf to a hosted html page.

First Is easiest. Make an html file. Be sure to include http prefix.

<img width="###px" height=###px" src="http://serverip/zm/cgi-bin/nph-zms?mode=jpeg&monitor=####&scale=100&maxfps=5&user=username&pass=password" />

Call it on .xinitrc before dwm

surf file:///home/username/file.html &

Customize the width and height of the img tag to fit your monitor. In my case I put st in the .xinitrc of my beagle instead of surf, restarted, and from the terminal ran xrandr to see what display it was using. I had 1440x900 but the width and height I could get out of surf without borders causing trouble was 1415 and 875. Multiple img tags can be embedded into an html file however you like. See also Example Camera View HTML

Refresh Screen Periodically

You will want to have the web browser refresh every few minutes. Otherwise, if the feed drops out, it will not return unless you reboot. The way I accomplished this was:

Install xdotool

# apt-get install xdotool

Edit surf config.h and add the following to the keybindings section, then make and make install.

{ 0, GDK_F5,  reload, { .b = FALSE } },

Add to /etc/crontab

*/5 * * * * username /usr/bin/xdotool key F5

To make sure this works, with the browser watching a camera stream, restart apache2 on the ZM server, and the browser feed will freeze. A successful F5 from xdotool will refresh the screen, as long as surf has a keybinding for it.

Using the Breakout Headers

Device Trees and Pin Initialization

Here are some notes, from my own setup of I2C. It can be confusing if you are new to the Beagle. This guide is also helpful for configuring other peripherals such as GPIO, UART, and SPI.

Follow this link for developers. Ignore the part about pre built kernels if you used the RCN based installer or image from's BeagleBoardDebian. You already have cape manager support.

If you don't have DTC where is asks for it in the 2nd step for dtc -version, ignore that step. The ./ script will install the latest compatible device tree compiler.


And use this to configure the pins.

There are also preset modes with the pins configured in various states, but I found it more satisfying to customize them to my needs.

cd ..
git clone
cd beaglebone-universal-io

No installation is required for config-pin.

Test it now:

 ./config-pin overlay cape-universal

This will allow a lot of pins to be edited. This must be done first. Then you can configure pins. There are other modes as well, see github. Cape-universal exports all pins except for HDMI and EMMC pins.

#:~/beaglebone-universal-io# cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 7: P-O-L-  0 Override Board Name, 00A0,Override Manuf, cape-universal

Now you can run something like this:

./config-pin p8_07 hi

To set Pin 07 on header 8 to GPIO HI

To see more options

./config-pin -h


./config-pin -l 9_11
default gpio gpio_pu gpio_pd uart

Showing us we can set the pin to UART or one of the GPIO modes.

 ./config-pin -a 9_11 uart

Then we can access the UART through either the direct memory registers, or the linux file system access (search online for more details).

The config-pin overlay cape-universal can be set in /etc/rc.local as well as individual pin settings.

I2C Usage

# apt-get install i2c-tools


# i2cdetect -l

The i2c peripheral, after being connected to the BBB, will be on one of the three i2c buses. Either 0,1, or 2.

# i2cdetect -r 0

Here we search on 0.

I used a BMP180 barometer and mine showed up at 77.

Unfortunately, the sensor can't be read from without a driver. What you will need to do is recompile the kernel with that driver included, as linux has a driver for the BMP085, but not by default.

References: (from [3] [4]

Recompile Kernel With Sensor Driver

I built the kernel natively on the Beagle, but this failed. It easiest to cross compile from a Debian based distro. I received an error trying to cross compile on Gentoo.

is a good guide that doesn't require javascript (as RCN's docs do). I installed via the SD card, not through sshfs. Latter did not work. When searching for the driver, in the kernel compile menu, easiest is to hit "/" key and search. In my case "/" then BMP returns the place of the barometer driver.

Finally, with the kernel built with support for your i2c device:

su root
echo bmp085 0x77 > /sys/class/i2c-adapter/i2c-1/new_device

0x77 Can be found from i2c-detect. See references.

These steps are only valid for the bmp pressure sensor, and when it's on i2c-1. Review dmesg to see if kernel recognized device.

$ dmesg -T

Navigate to /sys/bus/i2c/drivers/bmp085/1-0077/ and review what the file system provides access to from the sensor using the newly installed driver.

Instantiate BMP on boot

Two quick user space options:

echo bmp085 0x77 > /sys/class/i2c-adapter/i2c-2/new_device

in /etc/rc.local. Or add an init.d service (same idea).

  • Create in /etc/init.d/ with #!/bin/sh
  • Add commands
logger "starting init of BMP"
echo bmp085 0x77 > /sys/class/i2c-adapter/i2c-2/new_device
logger "BMP init complete"
  • chmod +x /etc/init.d/
  • update-rc.d defaults

References: - BMP on Beaglebone Black Raspberry Pi S.Exchange Cannot Perform Echo command to load driver for rtc module [5] [6]


  • Make a guide similar to the above, but using stali, sabotage, or a similar static binary distro (would be faster / leaner).
  • This link here [7] goes a step further into optimizing video processing for the beaglebone black. While the kernel is probably already optimized for bbb hardware, there is room on the software side to compile for optimizations.
  • Also, consider the RPi3 and its Hardware encoding capabilities, roughly documented here in the forums. It may be advisable for future SBC users to pursue a device with hardware encoding.

Notes / Errata

  • The above install requires about 2GB (make partition 3GB or 4GB to be safe). dd or clonezilla the partition to an img to reuse later.
  • With a beaglebone you can not use firefox to watch video. Too slow.
  • Surf works OK, at 720x1280 with 3-4FPS. EDIT: I've found some issues with what I believe to be the problem: streaming over long cable drops. Flickering video is possible, even after the devmem2 fix. Lowering the FPS (I set it to 1FPS) and or putting a switch before the BBB helps, but does not completely remove flicker. It flickers maybe 1 time every 12 seconds. I did not see these issues with small cable lengths during testing. Desktops and laptops do not have this issue. I recall being able to get it working without dropouts previously...
  • I've noticed inconsistent monitor resolutions from X upon boot. When I leave my hdmi -> dvi adaptor plugged in to dvi, without tightening the screws, it boots as 1280x720 or so. When I screw it in, it boots as 1080x720 or so. It's probably the poorly made adaptor and cable I am using.
  • EDIT 09/2017: Referring to note 3 again, This tested OK, through a VPN over the internet, but when put into production on a LAN the 2nd time, it caused blackouts on the screen every so often (how often depended on framerate). The first time this was put into production it worked, iirc. There was a long drop of cable to the beagle (<50 feet). I tried putting a switch before the beagle as a buffer, and it still dropped out, though less often. Lowering FPS also helped. In the end, I used an old laptop, and it works without any dropouts. The beagle was retired temporarily. I may try to get it working again later. It should be able to work, but something was causing the video monitor screen to go flash black periodically.


Installing and updating is slow!

On an SBC a counterfeit SD card could be the cause. A counterfeit or non name brand SD may take one day, what takes 2 hours to do with a name brand card.

Video monitor flickers, syslog says FIFO underflow!

See install steps regarding adjusting memory addresses with devmem2.

How do I disable keypresses for kiosk mode?

I don't have the need, but it's possible to do further lockdown. Look online.

Video is still flickering after devmem2 changes!

See my note. More research is needed. I was able to see the BBB running a ~3FPS 720p stream without error at one point, but at a later point, it began to drop out occasionally. It may be best to either run the viewing feed at a lower resolution, or to use a more powerful ARM based board (or a desktop if you don't need low power).

See Also