Posted on Leave a comment

RPi Zero Wireless – Video for Duet using MotionEYE OS

Prelude

Just the other day I wrote the post on setting up Video on the RPi Zero W to use on the Duet.

This post is ending up pretty much the same place, where we can access the video on our Duet Web Interface (and much more), but instead of using the full Raspbian install for it, we are going to use the much smaller and specialized MotionEYE OS.

For this project

For this project I’m going to use one of the tiny Raspberry Pi Zero Wireless controllers, 8GB SD card or larger and a Pi NoIR Camera V2. Using the NoIR as I wanted to try it out, and the NoIR makes it possible to record in the dark using IR lightning. I’ve found it’s also pretty nice just in my average dim room.

You also need one of the camera cables for the Zeros, as they are tapered in one end compared to the normal ones. They come in 15cm and 30cm lengths.

Index

Download MotionEYE OS

Go the the download page for Motion EYE OS and download the one for motioneyeos-raspberrypi-. If you look at the filezie, it’s obvious how it’s very lightweight and specialized at 68MB for complete OS  (225MB uncompressed) compared to the 4GB of our previous Rasbian installation!

Prepare SD

To make sure there are no unmarked bad areas on the SD drive, I strongly recommend getting a proper SD formatting tool, like SD Formatter, and do a format.

Make sure to pick the right drive, give it a name, choose OverWrite in Options and hit Format.

Unpack and write image to SD

Unpack the file and write image to SD using Etcher. Run Etcher as administrator if you run into problems.

Be patient.. it takes a while.

When it goes from writing data to the SD to Validating, Windows might throw some errors at you, but that’s normal, so don’t worry.

Setup WiFi

As opposed to our previous Raspian venture, we need to make a small file for our USB drive containing the necessary information about our Wireless LAN.

On windows I’m using the standard Notepad to create this file. I’ll not recommend using Notepad++ or some such as they are often more smart than they should be.

update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="MyWiFiNetwork"
psk="password123"
}

Replace MyWiFiNetwork with the SSID (name) of your Wi-Fi network, and password123 with your password, making sure to keep the quotes, as above.

If you copy paste the above into a notepad document, make sure to make the correct line breaks.

Now save that file with the filename wpa_supplicant.conf on the root/start of the SD drive

Make sure that your file doesn’t have any extensions on the end of the filename like .txt, it should just be called wpa_supplicant.conf

Hint: Save the file using Save As..  and change filetype drop-down from .txt to All filetypes

Source: https://learn.pimoroni.com/tutorial/sandyj/motioneye-os-on-your-octocam

Attach Camera

Now lets dig out our RPi camera and the special RPi zero camera cable.

Loosen the tabs on both devices and insert the ribbon cable as shown.

Do not put the devices on top of the antistatic bag. It works the opposite of putting the devices inside it, so don’t do that! I know many people are doing this all over the internet, but you really, really do not want to do that.

First Boot

Now insert SD card into your RPi Zero Wireless and power it up.. sit down and wait 5 minutes.

Use Angry IP Scanner to find the device

Unless you have configured IP manually, or have a screen connected, you need to figure out the IP of your device.

There are several ways to go about doing this, but the easiest way is to download and run the Angry IP Scanner. Some antimalware programs pops up warnings on this program, but it is due to its functionality to scan ports and such, and not because it contains malicios code.

So, start it up and just hit Start. It’ll scan a while. Then sort the results by clicking on the column named Ping.

Mine showed up like this, where the standard client devices like computers and printers are going to have a blue icon on the left hand side, so it’s easy to spot. Same with the Web detect on the right hand side, which isn’t normal for standard devices.

So right-click it -> Open -> Web Browser

Webinterface – Setup

Depending on the browser size you are going to see a small image in the corner, or a fullscreen view.

Click the icon looking like a person in the upper left corner, and switch Username to admin and leave Password blank.

Enable Advanced Settings

Turn on Advanced Settings in the General Settings section, and click Apply

Enable Streaming

Make sure Video Device and Video Streaming is turned on.

You might want to turn on Motion Detection as well instead of just having it on always.

Resolution and frame rate

As our last basic setup we are turning up our resolution a bit. Go into Video Device and select the Video Resoluton and Frame Rate fitting your requirments.

Streaming URL

Easiest way to find the URL (address) we need to use in our Duet Web Interface is to go to Video Steraming and cick on the Streaming URL link

This opens a small popup with an address, which you copy and then paste into the Optional URL to an external Webcam in the Duet Web Interface.

Note: Your url is not going to be exactly like mine

Duet Webcam Integration

In order to integrate the videostream into the Duet Web Interface, we need the direct url for our videostream.

My url, as copied above, is http://meye-f4a4e5e9:8081

I insert this into the Optional URL to an external Webcam box in Settings -> User Interface – Webcam Integration

Check it by going to Print Status tab

How it looks in Duet Web Interface when camera is enabled

Posted on Leave a comment

Raspberry Pi Zero Wireless – Video for Duet

For this project I’m going to use one of the tiny Raspberry Pi Zero Wireless controllers and a Pi NoIR Camera V2. Using the NoIR as I wanted to try it out, and the NoIR makes it possible to record in the dark using IR lightning.

You also need one of the camera cables for the Zeros, as they are tapered in one end compared to the normal ones. They come in 15cm and 30cm lengths.

Index

Download Raspian or Noobs

Grab newest Raspbian version. I’m using the full version. Maybe Lite is enough for our purpose?
If you downloaded Raspbian and imaged it using Etcher rather than NOOBS, then you will boot directly to the desktop environment of Raspbian and won't need to wait.
I ended up having to download using Torrent which took 8 hours less than the regular download!

You can get the Noobs version (instead of the above Raspbian) – and look at this nice guide:
NOOBS is an easy operating system installer which contains Raspbian. It also provides a selection of alternative operating systems which are then downloaded from the internet and installed.

Prepare SD

To make the SD last longer, I strongly recommend getting a proper SD formatting tool, like SD Formatter, and do a format.

Make sure to pick the right drive, give it a name and hit Format.

Unpack and write image to SD

Write image to SD using Etcher – it can open .zip files without extracting it.

Or you can get Win 32 Disk Imager for more options.

Note: For some reason it didn’t want to work with my normal SD card-reader, so had to dig up a different one!

Be patient.. it takes a while.
I had some issues, as mentioned above, so ended up unpacking it manually, which is why the source filename is different in the two images here.

When it goes from writing data to the SD to Validating, Windows might throw some errors at you, but that’s normal, so don’t worry.

Remote Access using VNC

I used usb keyboard and mouse, which I had to switch back and forth, since I couldn’t find my USB-hub, to connect the RPI to my WiFi and to activate VNC.

Windows key to open the menu. Go figure 🙂

Here’s a guide.

Next up I need to get myself a VNC viewer for my PC to connect to the RPI from my PC.

  • Do not use it on your RPi to connect to the RPi!
  • Just press Got It, on the first welcome screen. It looks like options with the icons above, but they aren’t.

Enter the IP and then use the default username pi and password raspberry  to connect.

You want to change these at some point.

I now have access from my PC and am ready for our Camera.

Attach Camera

Now lets dig out our RPi camera and the special RPi zero camera cable.

Loosen the tabs on both devices and insert the ribbon cable as shown.

Do not put the devices on top of the antistatic bag. It works the opposite of putting the devices inside it, so don’t do that! I know many people are doing this all over the internet, but you really, really do not want to do that.

We do not need to activate the camera using commands, since we enabled the Camera further up top alongside VNC.

Update

Now we need to update before continuing setting up the Camera.

Enter the Console/Sli and type:

Sudo apt-get update
and then
Sudo apt-get dist-upgrade

If you are used to use sudo apt-get upgrade instead of the dist- you might want to read about the differences.

Test Camera

Lets see if it works, by issuing this command:
raspistill -v -o test.jpg
You can find the test.jpg file using the File Explorer, where the photo should be placed at your home directory.

There is a larger guide here.

Install Camera software

I had planned to install the software Motion, as I had read a nice guide, but it turned out it just didn’t want to work with my Noir V2 camera, so I decided to look elsewhere. I also learned the project is no longer in the hands of the original author and has not been updated for a while.

RPI-Cam-Web-Interface

I decided on using RPI-Cam-Web-Interface instead although it is a webinterface, which isn’t strictly what I want for my Duet WiFi purposes. But I hoped it would make the raw videostream available, which it turned out to do.

The interface options also makes it easier to setup the different options as I’m not much of a linux console kind of guy.

Installing it:

There is a nice wiki guide, which I’m pretty much just following.

Since we allready updated our RPI, we can skip to step 4 to install the actual software via the Console:
1 command pr line. Wait for each to finish.

git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
chmod u+x *.sh
./install.sh

Short explanation: First it downloads the program, change to the folder, makes all .sh files executable and then installs  it.

A window is going to pop-up after a while. I just used default settings under installations.

Accessing RPI Interface

Open you browser and type in the IP of your RPI. If using default settings, you will be presented with a directory listing, where you can click on html link before you see something like this:

All done as we don’t need to do anything here really, but you might want to go into Camera Settings to setup resolution

Duet Webcam Integration

In order to integrate the videostream into the Duet Web Interface, we need the direct url for our videostream.

Lets say the IP is 192.168.1.26 like mine, the address you need to insert into the Duet Web Integration box is:
http://192.168.1.26/html/cam_pic_new.php
You put this into the Optional URL to an external Webcam box in Settings -> User InterfaceWebcam Integration

Note: I’m not entirely sure what the checkboxes are meant to do. I can find no differences if I check the Embed Webcam Stream or not?