Internet Connection to Raspberry pi 3 (Raspbian Stretch) with a 4G Huawei Mobile Broadband LTE USB Stick (HUAWEI E3372) using wvdial

This post describes how to use    the linux package “wvdial”   for configuring the USB dongle to obtain internet access  to pi3 .

First connect the 4G Huawei E3372  dongle is connected to a USB port of  the Raspberry pi 3

Required Linux Software

wvdial

usb-modeswitch

ppp

Install above packages using the terminal

sudo apt install ppp usb-modeswitch wvdial

Plug the USB 4G dongle to the Raspberry pi 3

Open the terminal

lsusb

Screenshot from 2018-09-01 00-00-41

Figure 1:- From the above figure it can be seen that USBMODEM=’12d1:1506′

Now you will be able to see the details of the USB dongle on the terminal

Creating a default wvdial.conf file on /etc

wvdialconf /wvdial.conf

Open wvdial.conf using gedit

sudo gedit /etc/wvdial.conf

Then modify the wvdial.conf file as shown below

Screenshot from 2018-09-04 22-31-58

Figure 2:-wvdial.conf file at /etc

As I have used a sim card of Mobitel Sri Lanka at the end of the line no 5 of above file is written as ‘mobitel’

Line no 10 depends on how the dongle is connected in your system.

ttyUSB* is found and automatically written in generated wvdial.conf when you use

“wvdialconf /wvdial.conf” command on the terminal.

ttyUSB* corresponds to USB dongle can also be found using “ls -l /dev/serial/by-id” on the terminal.

Screenshot from 2018-09-05 11-05-52

Figure 3:-

 

Test the connection

sudo wvdial

Now you can see that internet is activated in Raspberry pi 3

 

Making the internet connection automatic during the boot time.

For this purpose we have to make a script file and add an executing command in /etc/rc.local

sudo gedit 4GModam.sh

write following lines in the file and save

#!/bin/bash

wvdial

sudo chmod +x 4GModam.sh

Screenshot from 2018-09-04 22-32-58

Figure 4:- 4GModam.sh script file at /home/pi

Including executive command in /etc/rc.local to activate 4GModam.sh during the boot time

sudo gedit /etc/rc.local

Add the following command above “ext0” command in /etc/rc.local and save

sh ‘/home/pi/4GModam.sh’

Screenshot from 2018-09-04 22-34-03

Figure 5:- Editing  /etc/rc.local

Reboot the Raspberry pi 3

Now you can observe that the internet connection is activated in Raspberry pi 3


 

Advertisements

Internet Connection to Raspberry pi 3 (Raspbian Stretch) with a 4G Huawei Mobile Broadband LTE USB Stick (HUAWEI E3372) using sakis3g

Getting an internet  connection to Raspberry pi (with Raspbian Stretch)using a USB dongle is not that straightforward .

We know that 4G Huawei E3372  dongle is identified immediately and ready to use once it connected to a  Windows  or Ubuntu PC.

But for Raspberry pi , you will have to do some more work to get internet .

First connect the 4G Huawei E3372  dongle is connected to a USB port of  the Raspberry pi 3.

This post describes how the free software called   “sakis3g”  can be used for configuring the USB dongle to obtain internet access  to pi3 .

To get internet We are going to install following packages.

ppp package

sakis3g

usb-modeswitch

umtskeeper

Open the Terminal

sudo apt-get update
sudo apt-get install ppp
sudo apt-get install ppp usb-modeswitch
cd ~
pwd
mkdir umtskeeper
Download sakis3g.tar.gz file from sourceforge .
cd Downloads
Then copy the downloaded sakis3g.tar.gz file to the folder umtskeeper
cp sakis3g.tar.gz /home/pi/umtskeeper
cd ..
cd umtskeeper/
tar -xzvf sakis3g.tar.gz
chmod +x sakis3g

wget "http://mintakaconciencia.net/squares/umtskeeper/src/umtskeeper.tar.gz"
tar -xzvf umtskeeper.tar.gz
chmod +x umtskeeper


sudo ./sakis3g --interactive
Use 0 for APN username and password
Since my internet service provider  is mobitel Sri Lanka , I have used mobitel in sakis3g menu

 

 

 

 

Figure 1:-Connecting to internet using Sakis3G .You can see from above figures that the USBINTERFACE=’1′

Screenshot from 2018-08-31 19-34-12

Figure 2:- Internet is established using the 4G dongle

On the terminal to get the USBMODAM ID

lsusb

Screenshot from 2018-09-01 00-00-41

Figure 3:- From the above figure it can be seen that USBMODEM=’12d1:1506′

Using the data of Figure 1 and Figure 3 on the terminal
sudo ./sakis3g connect --sudo --console USBINTERFACE='1' OTHER='USBMODEM' USBMODEM='12d1:1506' SIM_PIN='1234' APN='CUSTOM_APN' CUSTOM_APN='mobitel' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --nat 'no'


cat /var/log/umtskeeper.log
Screenshot from 2018-09-01 16-05-02

Figure 5:- Details in the log file


How to make internet connection automatic during the boot time of the PI 3 

sudo gedit /etc/rc.local 

add the following line to rc.local script file and save .This script file activates during the boot time to facilitate automatic internet connection
/home/pi/sakis3g connect --sudo --console USBINTERFACE='1' OTHER='USBMODEM' USBMODEM='12d1:1506' SIM_PIN='1234' APN='CUSTOM_APN' CUSTOM_APN='mobitel' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --nat 'no'

Screenshot from 2018-09-04 17-20-48

  Figure 5:- Codes in file rc.local at /etc ( the codes underlined with green have to be changed to suit your dongle)

reboot pi 
Now you can see that the internet connection is established when the pi 3 is started

Note :- If you install Ubuntu MATE 16.0  , instead of Raspbian  on Raspberry pi 3 , USB internet Dongle can be used to access internet without Sakis3g or wvdial 
IMG_20180907_164742

Reference :-
mintakaconciencia.net

How to use a partition of a disk as a Dedicated Drive for ZoneMinder, v1.31.46. on Ubuntu 18.04 LTS Computer

This post explains how to use a partition of a disk of a  PC to store zoneminder events instead of saving on the computer ( At /var/cache/zoneminder/events).

To enable to write data of zoneminder to the partition of the drive , It is necessary to mount the usb drive  on the file system of the PC .

For the installation details of Zoneminder please refer my earlier post 

First make a partition of the disk and formatted it to ext4 .

For partitioning , It is easy to use GParted-LiveCD Ref https://gparted.org/download.php (You will have to download GParted live and write it to a cd )

 

After rebooting you will be able to see the partition using following methods

Open the Ubuntu terminal

ls -l /dev/disk/by-uuid

Screenshot from 2018-08-29 23-33-41

Figure 1 :-Getting details of disk using the Ubuntu terminal ( ls -l /dev/disk/by-uuid )

Screenshot from 2018-08-29 23-32-05

Figure 2:- Getting details of disk  using gnome-disk-utility

 

Screenshot from 2018-08-29 23-31-16

Figure 3:-mounted disks.  The sda3 was named as zmdata during the partitioning

You can see the sda3 is mounted on /media/bkjaya1952/zmdata. But without mounting on the file system of the PC zoneminder  will not be able to write data in to sda3. Therefore you will have to create a Systemd Mount Unit.

Creating Systemd Mount Unit

Open the Ubuntu terminal

sudo mkdir /mnt/sda3

sudo gedit /etc/systemd/system/mnt-sda3.mount

and paste the following codes into mnt-sda3.mount and save
(details of uuid of usb was taken from figure 1 and figure 2)

Screenshot from 2018-08-30 16-29-23

Figure 4:-Codes in mnt-sda3.mount

sudo systemctl enable mnt-sda3.mount

sudo systemctl start mnt-sda3.mount

Then restart the computer

Now if you see the folder /mnt/sda3 ,you can see that the disk partition is mounted on /mnt

Screenshot from 2018-08-30 09-31-46

Figure 5:-The sda3 Partition is now mounted on the file system of the PC

If you compare Figure 2 and Figure 5 You can see the sda3 is mounted on the file system now

Create a folder called “zoneminder” on the mounted sda3. Then create folders “events”  with in the folder “zoneminder”

Open the ubuntu terminal

cd /mnt/sda3

mkdir zoneminder

cd zoneminder

mkdir events

sudo chown -R www-data:www-data /mnt/sda3/zoneminder

sudo chown -R www-data:www-data /mnt/sda3/zoneminder/events

Screenshot from 2018-08-29 23-46-46

Figure 6:-

Create a config file under /etc/zm/conf.d . Name the file anything you want just as long as it ends in “.conf”. Add the following content to the file and save your changes:

(In my case I have used ajp.conf as the file name )

sudo gedit /etc/zm/conf.d/ajp.conf

and pasted following codes and  saved  the file in /etc/zm/conf.d

Screenshot from 2018-08-30 16-42-30

Figure 7:-

 

Open the ZM console and go to Options/Storage and add a NewStorage

added Storage path as /mnt/sda3/zoneminder/events

Please refer the following figure for the details

Figure 8:-Creating  a New Storage for the Monitor

Then enter following command on the Ubuntu terminal to start zoneminder.

sudo systemctl start zoneminder

Screenshot from 2018-08-30 09-37-44

Figure 9:-ZM Console and the monitor

 

Screenshot from 2018-08-30 09-41-26

Figure 10:- Saved ZM events on the mounted disk partition

( At/mnt/sda3/zoneminder/events)

 

Reference :-

Zoneminder Official Installation Guide

Andrew Bauer’s  blog-page

 

How to install ZoneMinder, v1.31.46. on Ubuntu 18.04 LTS

Install Zoneminder
Please refer Connor's web site
Open the terminal and run following commands.
sudo add-apt-repository ppa:iconnor/zoneminder-master
sudo apt-get update
sudo apt install zoneminder


sudo su

rm /etc/mysql/my.cnf

cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf

gedit /etc/mysql/my.cnf

add the following line at 32

sql_mode = NO_ENGINE_SUBSTITUTION

systemctl restart mysql

Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)

mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant all on zm.* to 
'zmuser'@localhost identified by 'zmpass';"

mysqladmin -uroot -p reload

chmod 740 /etc/zm/zm.conf

chown root:www-data /etc/zm/zm.conf

adduser www-data video

a2enmod cgi

a2enconf zoneminder

a2enmod rewrite

chown -R www-data:www-data /usr/share/zoneminder/

systemctl enable zoneminder

service zoneminder start

Add timezone to PHP

gedit /etc/php/7.2/apache2/php.ini

edit line 939 with your timezone

 

Then save the file php.ini

Your time zone can be get from here 

Adding cambozola.jar to the directory /usr/share/zoneminder/www/
Download the latest cambozola and extract to the Downloads directory 
of your PC
Then copy the cambozola.jar to the directory 
/usr/share/zoneminder/www/
On the ubuntu terminal run 
sudo cp /home/bkjaya1952/Downloads/cambozola-latest/cambozola-0.936/dist/cambozola.jar
 /usr/share/zoneminder/www/
Open zoneminder web console (http://localhost/zm/)

sudo service apache2 reload
Then open the ZM-Console and restart zoneminder

Screenshot from 2018-08-26 14-38-05
                      Adding a Monitor
Screenshot from 2018-08-26 14-48-59

                    Adding a USB camera 


Screenshot from 2018-08-26 14-37-16

                            USB camera is working

How to use a USB Drive as a Dedicated Drive for ZoneMinder, v1.31.46. on Ubuntu 18.04 LTS Computer

This post explains how to use a usb drive attached to a PC to store zoneminder events instead of saving on the computer ( At /var/cache/zoneminder/events).

Saving of zoneminder events on a dedicated drive is facilitated on the latest zoneminder versions to avoid the disk of the PC is getting filled with videos and images.

To enable to write data of zoneminder to the usb drive , It is necessary to mount the usb drive  on a folder of the PC . Please refer the link1 and link2  for further details.

For the installation details of Zoneminder please refer my earlier post 

First insert the usb drive to the computer .Then get the details of USB using the following procedure

Format the usb drive to ext4 using gnome-disk-utility

Then open the Ubuntu terminal

ls -l /dev/disk/by-uuid

Screenshot from 2018-08-23 17-45-57

figure 1:- Getting details of USB using the Ubuntu terminal ( ls -l /dev/disk/by-uuid )

Screenshot from 2018-08-23 17-36-40.png

figure 2:- Getting details of USB using gnome-disk-utility

 

 

Creating Systemd Mount Unit

Open the Ubuntu terminal

sudo mkdir /mnt/sdb

sudo gedit /etc/systemd/system/mnt-sdb.mount

and paste the following codes into mnt-sdb.mount and save
(details of uuid of usb was taken from figure 1 and figure 2)

 

Screenshot from 2018-08-24 19-06-31

Figure 3:-Codes in mnt-sdb.mount

sudo systemctl enable mnt-sdb.mount

sudo systemctl start mnt-sdb.mount

 

Then restart the computer

Now if you see the folder /mnt/sdb ,you can see that the usb drive is mounted on /mnt

Create a folder called “zoneminder” on the mounted usb. Then create folders “events” and “images” with in the folder “zoneminder”

Open the ubuntu terminal

cd /mnt/sdb

mkdir zoneminder

cd zoneminder

mkdir events

mkdir images

sudo chown -R www-data:www-data /mnt/sdb/zoneminder

sudo chown -R www-data:www-data /mnt/sdb/zoneminder/events

 

Figure 4:-After setting the owner and group to that of the web server user account

 

 

Create a config file under /etc/zm/conf.d . Name the file anything you want just as long as it ends in “.conf”. Add the following content to the file and save your changes:

(In my case I have used bkj.conf as the file name )

sudo gedit /etc/zm/conf.d/bkj.conf

and pasted following codes and  saved  the file in /etc/zm/conf.d

Screenshot from 2018-08-23 19-30-58

Figure 5:-

Open the ZM console and go to Options/Storage and add a NewStorage

added Storage path as /mnt/sdb/zoneminder/events

Please refer the following figure for the details

 

Figure 6:-Creating  a New Storage for the Monitor

sudo systemctl start zoneminder

 

Screenshot from 2018-08-23 18-01-44

Figure 7:-ZM Console and the monitor

 

Screenshot from 2018-08-23 21-06-32.png

 

Figure 8:- Saved ZM events on the mounted USB drive

 

How to install Zoneminder 1.30.0 on Raspberry pi 3 with Raspbian 9 ( Stretch)

 

RASPBIAN STRETCH WITH DESKTOP

 

Install Zoneminder 1.30.0

Open the Ubuntu terminal

sudo apt update

sudo apt upgrade

sudo apt dist-upgrade

 

Installation of Zoneminder

sudo su

apt install zoneminder

rm /etc/mysql/my.cnf
cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/my.cnf
service mariadb restart



mariadb -uroot -p < /usr/share/zoneminder/db/zm_create.sql

maiadb -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"

service mariadb restart

Note :- When you enter above commands on the terminal there will be prompts , asking for a  password. In that event , just press enter key of the key board ( blank pass word) and wait until the process is over and command prompt appear on the terminal.Some times  it will take more than 10 minutes.

chmod 740 /etc/zm/zm.conf

chown root:www-data /etc/zm/zm.conf

adduser www-data video

a2enmod cgi

a2enconf zoneminder

a2enmod rewrite

chown -R www-data:www-data /usr/share/zoneminder/

systemctl enable zoneminder

service zoneminder start

Add timezone to PHP

Screenshot from 2018-08-06 09-49-29

 

gedit /etc/php/7.0/apache2/php.ini

edit the opened file  with your timezone

Then save the file php.ini

Your time zone can be get from here

sudo service apache2 reload

reboot the pi

Open Zoneminder http://localhost/zm/

 

Screenshot from 2018-08-10 13-49-39

 

Reference :- Zoneminder Wiki

Note:- If you want to uninstall Zoneminder completely for a clean re installation use

“sudo apt purge zoneminder”

sudo apt autoremove

on the terminal

 

 

Adding a Hikvision Q1 NETWORK PT CAMERA to Zoneminder v1.31.44. on Ubuntu 18.04 LTS

 

IMG_20180623_213220

Hikvision Q1 NETWORK PT CAMERA is a low cost quality camera.

Item specifics
  • Brand Name:HIKVISION
  • IR Distance(m):5M
  • Alarm Action:FTP Photo,Email Photo
  • Sensor:CMOS
  • Storage:None
  • Viewing Angle (Degree):100°
  • Model Number:DS-2CV2Q01FD-IW
  • Dimensions (L x W x D)(mm):10*10*8
  • Supported Operating Systems:Windows 7,Windows 10,Windows Vista,Windows 98,Mac os,Windows 8,Windows XP
  • is_customized:Yes
  • Special Features:Vandal-proof
  • Power Supply:With POE
  • Supported Mobile Systems:Android,iOS,Windows Mobile
  • Video Compression Format:H.264
  • Minimum Illumination(Lux):Pan 355 degrees and Tilt 100 degrees
  • High Definition:720P(HD)
  • Technology:Pan / Tilt / Zoom
  • Power Consumption(W):7w
  • Audio Output:1CH RCA
  • Power Supply(V):DC 5V
  • Connectivity:IP/Network Wireless
  • Color:White
  • Style:Mini Camera
  • Wall Bracket:Ceiling
  • Type:IP Camera
  • Sensor Brand:SONY
  • Installation:Ceiling
  • Lens (mm):2.8mm
  • Network Interface:RJ-45 10/100Mb Ethernet Slot
  • feature 1:poe ip camera
  • feature 2:wireless ip camera wifi
  • feature 3:wifi baby camera
 The live view can be seen using a mobile app called Hik-Connect
Screenshot_2018-06-24-19-12-23
 Live view of the camera on mobile phone using Hik-Connect app
For installation of Zoneminder on Ubuntu please refer my other post 
Our main objective is to see how to connect this camera to zoneminder .
To add a camera monitor to zoneminder , under the Source sub menu  , ONVIF button at the top has to be pressed .
It was observed that the camera can be detected automatically in zoneminder .

 

Adding camera monitor to zoneminder

 

 

Detecting camera in zoneminder for adding monitor

 

In the brochure of the camera the default device password was not indicated. Therefor it was essential to reset the device password to be able to connect to zoneminder.

For resetting the device password SADP Tool was used .Please refer my other blog for the details .

After resetting the device password  the respective cages in the above figure was filled  and saved  .Then the  camera monitor was created successfully.

Source Path entered under the source menu of the monitor

rtsp://camera password@local ip address:554/Streaming/Channels/1

Note:- on the above source ,your camera password and local ip address have to be entered.

Entering Username and Device Password & creating monitor

 

After restarting zoneminder adding the camera was successful