วันพุธที่ 11 ตุลาคม พ.ศ. 2560

motionEyeOS (Raspberry PI) push video and image to dropbox

motionEyeOS can send video and image to cloud storage (Google Drive and Dropbox)

This topic will storage them to Dropbox.


  • Login to motionEyeOS

  • Select File Storage Section
  • Enable Upload Media Files, Upload Pictures and Upload Movies
  • On Upload Service. Select Dropbox.
  • On Location. Select Folder on Dropbox for save video and image. (If don't have folder, go to dropbox create new folder before config motionEyeOS)

  • Click on Obtain Key. It will go to Dropbox for generate Authorization key.

  • Allow Authorization. and copy Authorization key.
  • Enter Authorization key on Authorization key form and click Test service button
  • After success. click on apply for save all config. 


If you enable Motion Detection for record video or save images, after record finish or save images finish. It will push video and image push to Dropbox automatic.

Hope you enjoy with it. 😊

วันอังคารที่ 10 ตุลาคม พ.ศ. 2560

motionEyeOS (Raspberry PI) notification via LINE Notify

motionEyeOS (CCTV Software)

motionEyeOS is A Video Surveillance OS For Single-board Computers



motionEyeOS Source: https://github.com/ccrisan/motioneyeos
motionEye Source: https://github.com/ccrisan/motioneye

Download motionEyeOS Image: https://github.com/ccrisan/motioneyeos/releases

motionEyeOS Wiki: https://github.com/ccrisan/motioneyeos/wiki

How to install can see at Raspberry PI Spy (https://www.raspberrypi-spy.co.uk/2017/04/raspberry-pi-zero-w-cctv-camera-with-motioneyeos/)


LINE Instant Messager

LINE Notify Service: https://notify-bot.line.me/en/


  • Login with LINE Account

  • Select menu My page




  • Select Generate Token button

  • Enter token name and select 1-on-1 chat with LINE Notify or Group for send notification
  • Select Generate Token button

  • I will show token for send notification. copy it. and select close button

  • In LINE Instant Messenger will have LINE Notify Account add to you.  


Test send notify with curl
curl -k -X POST -H 'Authorization: Bearer [access_token]' -F 'message=hello' https://  
notify-api.line.me/api/notify
After run this curl command. You will receive message 'Hello' to LINE Instant Messenger via LINE Notify



If you want to send Message and Image to LINE Instant Messager, you can curl with this command.

curl -k -X POST -H 'Authorization: Bearer [access_token]' -F 'message=hello' -F 'imageFile=@[**file path to image]' https://  
notify-api.line.me/api/notify
**file path to image = Image file Supported image format is png and jpeg
Image will upload to server for send notification.



More Information
LINE Notify API Document: https://notify-bot.line.me/doc/en/
LINE Engineer Blog: https://engineering.linecorp.com/en/blog/detail/88


Create script for send notification on motionEyeOS

  • create directory /data/script with command
mkdir /data/script
  • create shell script
File: /data/script/linenotify_push.sh

#!/bin/bash
curl -k -X POST -H 'Authorization: Bearer [access_token]' -F "message=$1" https://
notify-api.line.me/api/notify

File: /data/script/linenotify_pushimage.sh

#!/bin/bash
curl -k -X POST -H 'Authorization: Bearer [access_token]' -F "message=$1" -F "imageFile=@$2" https://
notify-api.line.me/api/notify

  • change mode of file to executable file.

chmod 755 linenotify_push.sh
chmod 755 linenotify_pushimage.sh

Test script file


/data/script/linenotify_push.sh "Good world"

It will receive "Good world" message at LINE Instant Message

/data/script/linenotify_pushimage.sh "Good Job" "/data/output/Camera1/test.jpg"

It will receive "Good Job" message and test.jpg image at LINE Instant Message.

Now. You can run script for sent notification.


Use notification script at motionEyeOS

  • Login on motionEyeOS

  • Go to Motion Notifications section

  • Enable Run A Command (Send notification if motionEyeOS detect motion on camera)
  • On command box enter command

/data/script/linenotify_push.sh "Motion Detect at %Y-%m-%d %H-%M-%S"


  • (Option) If you want to send notification after finish motion detect, Enable Run An End Command and  enter command.

/data/script/linenotify_push.sh "Motion Detect End at %Y-%m-%d %H-%M-%S"


  • If you want to send image of motion detect, go to Still Images section.
  • Select capture mode to Motion Triggered or Motion Triggered (One Picture).

  • go to File storage.
  • Enter command on Run An Command 
/data/script/linenotify_push.sh "Motion Detect at %Y-%m-%d %H-%M-%S" %f

  • go to Motion Detection Section. Enable Motion Detection


  • Select Apply button on top to apply all config.


If motion detect of motionEyeOS detected, I will send "Motion Detect at [Date and Time]" message to LINE Instant Message.

After finish with motion detect (nothing movement) Send "Motion Detect End at [Date and Time]" message to LINE Instant Message.

and Send "Motion Detect at [Date and Time]" message " and image file to send to LINE Instant Message



วันพุธที่ 25 พฤษภาคม พ.ศ. 2559

Waveshare 7inch HDMI LCD (C) and 5inch HDMI LCD (B) on NOOBS

HDMI LCD

Waveshare 7 inch HDMI LCD (C)

Waveshare 5 inch HDMI LCD (B)


NOOBS (Raspberrry PI)


First write NOOBS Image to SD Card.
After finished.

Create file config.txt on NOOBS SDCard. (It don't have config.txt on NOOBS image)

config.txt  (for 7 inch HDMI LCD (C))

hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
# 1024 x 600
hdmi_cvt 1024 600 60 6 0 0 0
max_usb_current=1

config.txt (for 5 inch HDMI LCD (B))

hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
#800x480
hdmi_cvt 800 480 60 6 0 0 0
max_usb_current=1
Save it. and eject from computer.
Try to boot with Raspberry PI to test it.




All image on NOOBS should change config.txt for support this HDMI LCD Device.

Enjoy ;)


Reference:
NOOBS (Raspberrry PI)

วันศุกร์ที่ 25 มีนาคม พ.ศ. 2559

Live TV DVB-T2 with VDR Addons on OpenELEC

I have Geniatech DVB-T2 Stick T220.
I use OpenELEC to play Live TV with it.



Current version of OpenELEC is 6.0.3.

First install services add-ons VDR PVR Backend.
Goto: System -> Settings -> Add-ons -> Install from repository -> OpenELEC Add-ons (offical) -> Services -> VDR PVR Backend



Install VDR PVR Backend

After Installed. Go back to PVR clients.

Install VDR VNSI Client (If VDR VNSI Client is not installed)

Select Configure of VDR VNSI Client.

Enable create channel groups automatically on the server And OK.

Next Goto Home -> Programs -> VDR Configuration


Select Channel scanner Configuration


Start scanning TV channel.
Select 
  • Tuner Type: DVB-T
  • Country: <your location>
  • Cleanup all
And Start


After scan completed. Select Close.

Enable TV menu on OpenELEC
Goto: Home -> System -> Settings -> TV

Select Enable:  General -> Enabled and Synchronis channel groups with backend(s)


Go back to Home and Select TV

Now already to watch Live TV from DVB-T2 Device and recording.

Have a good day. :)


Addition:

VDR PVR Backend has other plugins to use.
You can enable on configure menu.

Goto: Home -> System -> Settings -> Add-ons -> Install from repository -> OpenELEC Add-ons (offical) -> Services -> VDR PVR Backend

Select Configure.

You can enable other plugins if you want to use.



Reference:
VDR - The Video Disk Recorder

VDR Wiki

วันพฤหัสบดีที่ 24 มีนาคม พ.ศ. 2559

Add custom keyboard layout to OpenELEC image

OpenELEC system partition on Raspberry PI is read-only filesystem (squash filesystem or squashfs).
I cannot change anything of system partition or add custom keyboard layout.

If you want to change something on this filesystem, you should unpack and repack squashfs image.



I use Ubuntu 15.10 for repack squashfs image.

First install squashfs-tools for re-create squashfs image.
$ sudo apt-get update
$ sudo apt-get install squashfs-tools

Download OpenELEC Image and extract compress file.

Backup original and copy to new image file.

$ cp OpenELEC_original.img OpenELEC_custom.img

Mount image file to loop device (/dev/loop0)
$ sudo losetup -P /dev/loop0 OpenELEC_custom.img

option -P for create a partitioned loop device (/dev/loop0p1, /dev/loop0p2)


Check partitioned loop device with fdisk.
$ sudo fdisk -l /dev/loop0
Disk /dev/loop0: 548 MiB, 574619648 bytes, 1122304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3902d568
Device       Boot   Start     End Sectors  Size Id Type
/dev/loop0p1 *       2048 1050624 1048577  512M  c W95 FAT32 (LBA)
/dev/loop0p2      1052672 1118208   65537   32M 83 Linux


It created /dev/loop0p1 and /dev/loop0p2.

Create boot and system directory
$ mkdir boot system

Mount  first loop partition (/dev/loop0p1) to boot partition.
$ mount -t vfat /dev/loop0p1 boot

Check all file on boot partition.
$ ls boot
bcm2708-rpi-b.dtb       bootcode.bin  fixup.dat   start.elf
bcm2708-rpi-b-plus.dtb  cmdline.txt   kernel.img  SYSTEM
bcm2708-rpi-cm.dtb      config.txt    overlays

It found SYSTEM file (OpenELEC system filesystem).

Mount SYSTEM file to system partition.
$ mount -t squashfs boot/SYSTEM system

Check all file on system partition.
$ ls -F system
bin/  etc/    lib/    opt/   run/   storage/  tmp/  var/
dev/  flash/  media@  proc/  sbin/  sys/      usr/

Create temporary directory for copy all file on system partition and add custom keyboard layout.
$ mkdir tmpsystem

Copy all file of system to temporary directory
$ sudo cp -Rpf system/. tmpsystem

After copy all file to temporary directory.
Unmount system filesystem.
$ sudo umount system


OK. Now you can change everything on temporary directory.

Location Kodi system data on OpenELEC: /usr/share/kodi

Kodi keyboard layout directory on OpenELEC (/usr/share/kodi/system/keyboardlayouts)
You can add custom keyboard layout or change exists keyboard layout on this directory.

Now: tmpsystem/usr/share/kodi/system/keyboardlayouts

Example. I want to add Thai keyboard layout (thai.xml) to this directory.
Copy thai.xml to tmpsystem/usr/share/kodi/system/keyboardlayouts
$ sudo cp thai.xml tmpsystem/usr/share/kodi/system/keyboardlayouts


OK. Now you finished to change temporary directory.

I will re-create system filesystem  (SYSTEM file) from temporary directory with mksquashfs.

$ sudo mksquashfs tmpsystem SYSTEM -noappend -comp gzip


Now. I have new SYSTEM file.

Delete SYSTEM file on boot partition.

$ sudo rm boot/SYSTEM

Copy new SYSTEM file to boot partition.

$ sudo cp SYSTEM boot

Unmount boot partition.

$ sudo umount boot

Deattach loop device from OpenELEC image.

$ sudo losetup -d /dev/loop0

Delete temporary directory

$ sudo rm -Rf tmpsystem

OK. Now. OpenELEC image (OpenELEC_custom.img) has changed.

Try to write image to sdcard for test it.

Goto  System -> Settings -> Appearance -> International -> Keyboard layouts
Select Thai keyboard layout.






Addition:

You can add font to Kodi on system font path: /usr/share/kodi/media/Fonts.



Reference:







วันจันทร์ที่ 5 ตุลาคม พ.ศ. 2558

How to compile nginx with nginx-rtmp-module

Prepare environment for compile.
$ sudo apt-get update
$ sudo apt-get install libpcre3-dev libatomic-ops-dev libgeoip-dev geoip-bin geoip-database geoip-database-extra libperl-dev libssl-dev libxml2-dev libxslt1-dev

Create directory src

$ mkdir src

Download Nginx (last version)

$ cd src
$ wget http://nginx.org/download/nginx-1.9.5.tar.gz
$ tar -xvzf nginx-1.9.5.tar.gz

Git Clone nginx-rtmp-module

$ git clone https://github.com/arut/nginx-rtmp-module.git


Change current to nginx-1.9.5

$ cd nginx-1.9.5

Run configure

$ ./configure --prefix=/usr/local/nginx --user=www-data --group=www-data --with-select_module --with-poll_module --with-threads --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module  --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-md5-asm --with-sha1-asm --with-libatomic --with-pcre --with-stream --with-stream_ssl_module --with-http_v2_module --add-module=../nginx-rtmp-module

Run make to compile

$ make

Install nginx to /usr/local/nginx

$ sudo make install

Config Nginx on /usr/local/nginx/conf/nginx.conf

$ sudo nano /usr/local/nginx/conf/nginx.conf


Config for streaming server see on nginx-rtmp-module wiki

Web path /usr/local/nginx/html

Start nginx service

$ sudo /usr/local/nginx/sbin/nginx

Stop nginx service

$ sudo /usr/local/nginx/sbin/nginx -s stop


Reference
Nginx

nginx-rtmp-module (source code)

nginx-rtmp-module (wiki)

Streaming with nginx-rtmp-module


วันพุธที่ 30 กันยายน พ.ศ. 2558

Install font to OpenELEC

How to install new font to OpenELEC

Login with root to OpenELEC.

# mkdir -p /storage/.xbmc/media/Fonts
or
# mkdir -p /storage/.kodi/media/Fonts

Upload truetype font to this path.

Reboot OpenELEC again.


How to Disable Power Management of rtl8192cu

Fix problem wireless disconnect and go to save mode.

Create file /etc/modprobe.d/8192cu.conf

$ sudo nano /etc/modprobe.d/8192cu.conf

add this line

options 8192cu rtw_power_mgnt=0 rtw_enusbss=0


Restart raspberry pi



Reference :

https://github.com/xbianonpi/xbian/issues/217

https://github.com/pvaret/rtl8192cu-fixes/blob/master/8192cu-disable-power-management.conf

DLNA/UPnP with MiniDLNA

How to build DLNA/UPnP Server on Raspberry PI for use at Home device.
(Example TV, Media player, PS3, Xbox etc.)


Install minidlna package

$ sudo apt-get install minidlna


Add pi user to minidlna group

$ sudo usermod -a -G minidlna pi

Create Directory for store media file

Example:

$ mkdir -p /home/pi/minidlna/music
$ mkdir -p /home/pi/minidlna/pictures
$ mkdir -p /home/pi/minidlna/videos
$ mkdir -p /home/pi/.minidlna

Change Mode of /home/pi/minidlna and /home/pi/.minidlna
$ sudo chmod 777 /home/pi/minidlna
$ sudo chmod 777 /home/pi/.minidlna

Config MiniDLNA

$ sudo nano /etc/minidlna.conf

Modify this file
...
db_dir=/home/pi/.minidlna/data
log_dir=/home/pi/.minidlna/data/log
# * "A" for audio (eg. media_dir=A,/var/lib/minidlna/music)
# * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
# * "V" for video (eg. media_dir=V,/var/lib/minidlna/videos)
media_dir=A,/home/pi/minidlna/music
media_dir=P,/home/pi/minidlna/pictures
media_dir=V,/home/pi/minidlna/videos
# Name that the DLNA server presents to clients.
friendly_name=RASPBERRY DLNA
# Automatic discovery of new files in the media_dir directory.
inotify=yes
# Notify interval, in seconds.notify_interval=895...

Restart MiniDLNA Service

$ sudo /etc/init.d/minidlna restart

Or re-indexing all of media files

$ sudo /etc/init.d/minidlan force-reload



Test on Device supported with DLNA/UPnP to play media.




Reference:

Digital Living Network Alliance
https://en.wikipedia.org/wiki/Digital_Living_Network_Alliance

ReadyMedia (MiniDLNA Source Code)
http://sourceforge.net/projects/minidlna/

ReadyMedia (Wiki of Archlinux)
https://wiki.archlinux.org/index.php/ReadyMedia

วันอังคารที่ 11 สิงหาคม พ.ศ. 2558

How to use own remote control for OpenELEC

IR Receiver (TSOP44.., TSOP48.., TSOP38238, ...)


Connect IR Receiver to Raspberry Pi

Vcc -> 3V
GND -> GND
Vout -> GPIO 18








Load LIRC module on boot.
Edit /boot/config.txt
Add line

dtoverlay=lirc-rpi

or (change GPIO pin in for IR Receiver)

dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=18

See on : https://github.com/raspberrypi/firmware/tree/master/boot/overlays

Learning own remote control

Kill Process of LIRCD

# killall lircd

Start learning remote control button.

# irrecord /storage/.config/lircd.conf

irrecord -  application for recording IR-codes for usage with lirc

Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)

This program will record the signals from your remote control
and create a config file for lircd.


A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION of this package, especially section "Adding new remote
controls" for how to get help.

If there already is a remote control of the same brand available at
http://www.lirc.org/remotes/ you might also want to try using such a
remote as a template. The config files already contain all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available in the remotes/generic/ directory of the source
distribution of this package. You can use a template files by
providing the path of the file as command line parameter.

Please send the finished config files to  so that I
can make them available to others. Don't forget to put all information
that you can get about the remote control in the header of the file.

Press RETURN to continue.


Now start pressing buttons on your remote control.

It is very important that you press many different buttons and hold them
down for approximately one second. Each button should generate at least one
dot but in no case more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have been
generated.

Press RETURN now to start recording.

................................................................................
Found const length: 107201
Please keep on pressing buttons like described above.
................................................................................
Space/pulse encoded remote control found.
Signal length is 67.
Found possible header: 8951 4451
Found trail pulse: 572
Found repeat code: 8961 2214
Signals are space encoded.
Signal length is 32
Now enter the names for the buttons.

Please enter the name for the next button (press  to finish recording)
KEY_POWER

Now hold down button "KEY_POWER".

Please enter the name for the next button (press  to finish recording)
KEY_1

Now hold down button "KEY_1".

Please enter the name for the next button (press  to finish recording)
KEY_2

Now hold down button "KEY_2".

Please enter the name for the next button (press  to finish recording)
KEY_3

Now hold down button "KEY_3".

Please enter the name for the next button (press  to finish recording)
...


If you want to know irrecord key and button name list, use this command.

# irrecord --list

It will display list of key and button name.

IR Remote Key for OpenELEC on Raspberry PI (See on file /etc/lirc/lircd.conf.rpi)

KEY_POWER
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_0
KEY_VOLUMEUP
KEY_VOLUMEDOWN
KEY_MUTE
KEY_EXIT
KEY_CHANNELUP
KEY_CHANNELDOWN
KEY_INFO
KEY_UP
KEY_LEFT
KEY_RIGHT
KEY_DOWN
KEY_OK
KEY_MENU
KEY_AUDIO
KEY_VIDEO
KEY_BACKSPACE
KEY_PLAY
KEY_PAUSE
KEY_FORWARD
KEY_STOP
KEY_RADIO
KEY_TEXT
KEY_TITLE
After finish all key. Press Enter for finished.

(If you type incorrect or some problem about step, delete file /storage/.config/lircd.conf and run irrecord command)

Reboot OpenELEC.

# shutdown -r now

Test IR Remote for control menu on OpenELEC.



Reference :

Device Tree overlays
https://github.com/raspberrypi/firmware/tree/master/boot/overlays

Guide To lirc rpi GPIO Receiver
http://wiki.openelec.tv/index.php?title=Guide_To_lirc_rpi_GPIO_Receiver

Guide to add your own remote
http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote