Feb 22, 2018

Auto-starting mjpg-streamer on Octopi

The normal command for me to start my mjpg-streamer (from its directory) is:
    ./mjpg_streamer -i "./input_uvc.so -n" -o "./output_http.so -w ./www"

The problem arises, when you want this to start automatically when your Raspberry Pi reboots (or even run in the background). You can't just simply add an & and even the built-in -b(ackground) option doesn't seem to work amazingly well.

So, here's what I've been able to sort out:
Copy all of the files to:
Test execution from any folder use the following full path:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "input_uvc.so -n" -o "output_http.so -w ./www"

If you get the message "ERROR: could not find input plugin", use the following command:
    export LD_LIBRARY_PATH=/usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/

If you want it to run & stay running (background mode), use the -b switch:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "input_uvc.so -n" -b -o "output_http.so -w ./www"

To stop the background mjpg-streamer daemon, use the following command:
    kill -9 `pidof mjpg_streamer`

To make the camera start-up automatically, add the following lines to /etc/rc.local:
    /usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "input_uvc.so -n" -o "output_http.so -w ./www" export LD_LIBRARY_PATH=/usr/local/sbin/mjpg-streamer/mjpg-streamer-experimental/
Also, make sure that /etc/rc.local is set to execute:
    sudo chmod 755 /etc/rc.local

For clarity, the actual binary is mjpg_streamer but it is usually referred to in conversation as mjpg-streamer. If you're searching, search for both!

Flashing arduino mega2560 firmware from OctoPi

I have a clone Arduino Mega2560 that I keep having to make changes to the firmware for my 3D printer.  Most of the steps are straight forward:

  1. Make changes to firmware in Arduino software.
  2. Save as hex
  3. sftp/scp the file to the Raspberry Pi
The last step was the one that gave me so much grief.  For my particular setup, here's the command that works:
avrdude -p m2560 -c stk500v2 -P /dev/ttyUSB0 -D -U flash:w:Marlin.ino.mega.hex:i