Surveillance Cameras

A problem is that nearly all new IP Cameras try to sell a cloud service to get the bought functionality.

My old foscam outdoor is nearly inaccessible from a web browser after the latest update.

I now use motioneyeos on a raspi and/or the synology surv.station to manage the cameras instead of the expensive cloud or instead of multiple apps on my phone.

I had some trouble to send e-mails via smtp.

smtp.gmail.com

SSL Port 465 TLS Port 25 or 587

The solution is to go to your google account, security and allow not so secure apps. Done.

Pico_ducky „bad usb“

A fast and convenient way to automate some tasks is to create an „bad usb“ working as a HID (human interface device), typing in commands for you. eg. doing a backup or starting apps you need.

I did this on an rapberry pico.

Step 1:

  • Download CircuitPython
  • Plug your raspberry pi pico in
  • Copy & paste the downloaded .uf2 in the raspberry pi pico.
  • Unplug and plug your raspberry pi pico

Now your Raspberry pi pico will be the CircuitPython.

Step 2:

Step 3:

  • Delete the code.py file from raspberry pi pico.
  • Download the python file which will convert our payload. File Download Link ⇒ pico-ducky
  • Open the folder and copy & paste the duckyinpython.py file to the raspi pico.
  • Rename the duckyinpython.py file to the code.py.

OK, now load a payload on the raspi and watch.

But: it works as an englisah (US) HID, on a german language PC it will not work.

So I did this:

Go to the latest release page, look if your language is in the list.

Download the py zip, named circuitpython-keyboard-layouts-py-XXXXXXXX.zip

Find your language/layout in the lib directory

For a language de, copy the following files from the zip’s lib folder to the lib directory of the board.
DO NOT modify the adafruit_hid directory. Your files go directly in lib.
DO NOT change the names or extensions of the files. Just pick the right ones.
Replace LANG with the letters for your language of choice.

  • keyboard_layout.py
  • keyboard_layout_win_de.py
  • keycode_win_de.py

Modify the pico-ducky.py (later) code.py on the pi to use your language file:

At the start of the code.py replace these lines:

from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

With this lines:

from keyboard_layout_win_de import KeyboardLayout
from keycode_win_de import Keycode

And also replace this line:

layout = KeyboardLayoutUS(kbd)

With this line:

layout = KeyboardLayout(kbd)

Now — you have a ducky for a german pc…

Raspberry Pi Camera Surveillance

My goal was to use the raspi as a surveillance camera. It should send me pics if movement is detected. Here my tips and tricks…

(remember : this is just my logbook, not a tutorial with all details…)

The difficult way — Motion

Using Raspberry Pi Imager to burn the sd card. First surprise:

CTRL+SHIFT+X gives you an advanced menu and you can configure you ssh and wlan before even burning. Sweet!

Install motion software.

sudo apt-get install motion

sudo motion start

cd /etc/motion/

sudo nano motion.conf

stream_localhost – set it to off

Install sendmail

$ sudo apt-get remove postfix
$ sudo apt-get purge postfix

$ sudo su

apt-get install sendmail sendmail-bin mailutils

Later I found (long search) I had to install this, too

# sudo apt-get install libsasl2-modules

#  mkdir -m 700 /etc/mail/authinfo

create a file named gmail-smtp-raspi (or else) and input your gmail account here

#  nano /etc/mail/authinfo/gmail-smtp-raspi
Fill in : 
AuthInfo: "U:root" "I:USER@gmail.com" "P:GMAIL_USER_PASSWORD"


We have to create a database map from gmail-smtp-raspi (or else) file using makemap utility as below command.

# makemap hash /etc/mail/authinfo/gmail-smtp-raspi < /etc/mail/authinfo/gmail-smtp-raspi 

# nano /etc/mail/sendmail.mc

Next, Copy and Paste below lines in /etc/mail/sendmail.mc file above MAILER_DEFINITIONS as shown below,

dnl #
dnl # Defining Gmail Smarthost for sendmail
define(`SMART_HOST',`[smtp.gmail.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail-smtp-raspi.db')dnl

dnl #
dnl # Default Mailer setup
MAILER_DEFINITIONS
MAILER(`local')dnl
MAILER(`smtp')dnl

# make -C /etc/mail

# /etc/init.d/sendmail reload

Test it:

# echo „test mail for sendmail gmail relay“ | mail -s „Sendmail Test“ fosstechnix@gmail.com

You may have to switch the settings in your google account to allow unsecure apps.

The easy way — Motioneye

Download the latest MotionEyeOS software release

Install the image on the sd card

Now we install the wlan access

sudo nano /media/<user>/rootfs/etc/wpa_supplicant/wpa_supplicant.conf

and put this in the above created file:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE
network={
    ssid="<network id>"
    scan_ssid=1
    psk="<network key>"
    key_mgmt=WPA-PSK
}

Now ssh enable if you want:

cd /media/<user>/boot/

touch ssh

Strg C

Now the sd card in the raspi,



OK, get the raspi IP with a ip scanner,

than login with your browser to this IP.



    Username: admin
    Password: [No password, leave blank]


You can configure pretty much everything in your web user interface. We recommend taking a look at the following configurations when configuring the MotionEyeOS for the first time.

    Go to the three bars menu, and open the General Settings;
    Enable Advanced Settings;
    You can set the admin username and set a password;
    You can also set a name for a surveillance user, and its password;
    Set your timezone and a hostname.

Click the orange button at the top right “Apply”  – this will require a reboot.


Ready to go