Sunday, 13 December 2015

D-Link IP Camera setup on Linux Mint

Well last night I gave in to shopping temptation and got a D-Link DCS-932LB1

Dlink pictire

It was cheap and on offer and although it only said Windows / Mac use I thought I would take a chance to get it working under Mint. That BUY NOW button eh !

So first I found Zone Minder, which looks a great program but I had real trouble setting it up so I gave up trying after following a few guides. Something to do with systemd and systemctl I could not figure out.
So I looked for something simpler and I found it.

Motion

I've just started to play with it but I need to get this down before I move on to saving video and using it via my android phone & other places, so the basics of setting it up.

First I found a guide on how to just set up the camera with my router at sensor.org

This was basically connect by ethernet cable to my router
plug the camera in
navigate to my router setup homepage where I found the WPS connection button,
then press the button on the back of the camera and the WPS button on the setup page
The router found the IP camera and I was away.

I found the new connection on the list of active connections on the router info page
copied the internal IP address 192.168.x.x
and pasted it into my browser
This brought up the IP cameras setup page where I entered the supplied username and password
from the manual. The first thing I did was change this and follow the setup from there
keeping the simplest options for now.

I was now ready to install Motion

sudo apt-get install motion
sudo apt-get update

apparently this should automatically create a

motion group (I learnt a bit from trial and error about there from installing Plex !)
it should also add a motion user

This info is on Linux.com at how to operate linux spycams with motion

after making sure this was right I started motion

$: motion

mistake it wouldn't give permission to use
silly me

$: sudo motion

and it started up. I then found it had failed to find the video device

I followed the instructions on Linux.com down to the point where the author talked about
permissions again.

Her name was carla so I noticed she gave the instructions

~$ sudo chown carla:carla .motion/motion.conf
Her group name was obviously carla and so was her user name.

I replaced the carla with my group name and user name so it all worked.

I followed the info to make more directories then saved localhost:8081 and localhost:8080 to my browser favourites
The first port 8081 is the feed to see the camera output and the second port 8080 is the configuration
file where you can enter and change different set up options.

I went to config then list and all the changable options were there

To see my camera I then went back to the IP Camera's setup page and found the link to the feed by
right clicking on the video feed and using inspect on my chromium browser to pick up the link as shown on Linux.com.

pasting that link into netcam_url =
and then pasting admin:mypassword
into netcam_userpass =

Bang. the feed came up on the hocalhost:8081 webpage

Now I can mess about with other options another day to add functionality

Sunday, 25 October 2015

Mupen64plus

Just a little about setting up Mupen64plus, the Nintendo 64 emulator.

It seems this puts files everywhere and none of the Ubuntu places that are suggested in most tutorials.

So easiest after installing the deb file, do a search in the Nautilus file manager for Mupen64 and watch all the places its stuck itself show up.

Install the frontend "M64py" to make it a little easier to point to where the Rom's are stored along with where the executable is and Data files / Plugins. Leave the search results handy so you can see where everything is.

One problem I had was setting up my controller. I used a Xbox360 Pad and tried to follow the joystick setup walkthru that is an easy find online.

https://code.google.com/p/mupen64plus/wiki/ControllerSetup

Two things to point out about this, the config.ini file it talks about is in the $HOME/.config hidden file in your home directory.

(Dot). files need to be seen in a folder by going to the menu bar and selecting View then scrolling down to hidden files and selecting so they are shown. There also may be other config.ini files for other emulators there also.

This file is nice to view and only needs a little amending (as root).

The parameter needs to be changed in the Core section of mupen64plus.cfg. It should look something like this:

Joy Mapping Stop = "j0b10"

That's for joystick 0, button 10

This gives you an ESCAPE from the emulator mapped to button 10.

The InputAutoCfg.ini file which is the file used to set various joypads up was harder to find thus the Nautilus search. The controller Setup info was wrong for me. I found it at /usr/share/games/mupen64plus 

Before I go any further I have to say I had lots of trouble getting the controller to work until I realised my controller itself was not connecting correctly. I was forced to try a few different USB ports for it to connect. I checked that the system was seeing it by doing a lsusb command at the terminal until it showed up.

I grabbed the Xbox 360 controller configuration file and pasted it into the InputAutoCfg.ini and tried and tried to get it to work with the controller setup GUI in M64py frontend. No luck

Finally I found a post on the Ubuntu forums that had the answer. Call the programme from a Terminal window. I did this and all the setup configuration options were there to be changed and saved. easy when you know how.

One final thing I've been finding with emulators in general. Quite a few I've used have been opening in full screen and I've had trouble escaping from the full screen view.

There have been some quite bad tempered replies to posts from people who had this problem from some unsympathetic dicks. They should just be nice and tell them on some emulators to escape full screen it is ALT and ENTER. Even with random pushes that was hard to find and when its buried somewhere in the midst of a manual its even harder to work out.

Saturday, 22 August 2015

Setting up my Time lapse Raspberry Pi Camera with a shut down switch

Lets do it !


Well this post is a little bit about Linux Mint as I'm using it to set up and transfer files to my Time Lapse Camera I have made from a "Raspberry Pi" Micro computer but also because it links in to my last post which was about joining the shots I'd made into a short time lapse Video.

Let's get this down while I have the tabs open on my browser I've used and it's fresh, in case I need to do it again.

About the Camera


I set up a simple camera time lapse using the camera module for the Pi and set it off connected to a mobile phone battery back up pack.

These are ridiculously cheap on e-bay from China without the batteries inside, currently about £2 including shipping. They're searchable as Rechargeable USB LED Mobile Power Bank Charger 4pcs 18650 Li-ion Battery Case

People give me old out of date or none working Laptops and so I ripped the Lithium batteries out of the battery pack of one of these. The nice Panasonic batteries were checked on my multimeter and they all seemed OK so I put 6 of them inside the battery pack casing and set it on charge through the USB port of my PC.

By the way most laptops seem to hold battery packs of the type 18650. You can buy them on e-bay but there are types with a nipple on the plus end and types that are flat on both ends. My batteries from the laptop fitted in the case but some new ones I also bought 4x 4200mAh UltraFire 18650 3.7V Rechargeable Li-ion Battery  were shorter and were loose when put in so I did not use them.

I now had a portable time lapse camera I can take anywhere and it will take a picture every one minute for as long as the batteries last.

The set up for the Camera time lapse is available as a worksheet on the Raspberry Pi  learning website
https://www.raspberrypi.org/resources/

This is just a prototype and I want to add other features to it as I go along so nice start.

What now

After setting up the Camera to capture the scene outside my window onto the street I left it running overnight to see how long the batteries would last before they cut power to the Pi. The shots were saved as in the worksheet instructions to save date and time so I would know how many hours by just checking the time stamp on the pictures.

Well that all worked and I took the mini SD card (or TF card if you're from China) from out of the Pi and connected it to my PC, copying over the "Camera" folder to my Linux desktop and then using imagemagic in TERMINAL as described in my last post.

Now to the crux

The battery lasted enough time to get a nice sunrise over my car and onto the street but then I had the issue of shutting down the Pi. (Switches to present tense)

I don't want to damage the file system on the SD card by too many hard close downs from loss of power. I can do this by adding something to my script to fix the time and amount of shots taken before the script tells the Pi to shutdown the operating system (don't know how to do that yet but it is something I will research and learn). 

I also would like to be able to just press a button and ask the Pi to stop taking shots and shutdown the operating system itself before the battery does it for it by dying.

The little portable setup won't be connected to a monitor and keyboard and also I don't want to always have it connected to a ethernet cable or have a WiFi receiver plugged in. 

The only choice is a soft shutdown button.

Now there are a load of pages on the Internet on how to do this but my problem with them is if they are written by experts, they forget the simple stuff or miss vital bits out expecting you to know it.

If they are written by novices they seem to do everything the longwinded way with un-neccsary steps that just add to the confusion.

It's difficult to find something at my "tinkering" level. Oh well, that's life.

So this is How I have done it after lots of wasted hours.

The actual Process

This is for the Raspberry Pi model B+.  I have one of the earlier models, the B but I don't like doing anything that could screw it up with it.

First all the pages I looked at had everybody doing the complicated stuff on the Pi first connected to a monitor. For desktop stuff I think the Pi is just way to slow to do these things. After my initial setup of the card and Pi using a monitor I noted the IP address of the Pi and enabled SSH in (sudo) raspi-config so I could access it from my main computer.

All my editing of files were done by cutting the code from my browser then pasting into gedit the linux mint notepad, saving this file to my desktop and using Filezilla the FTP program to transfer that file to the correct folder on the Pi.

I used PUTTY to  do any other things such as making the files I had sent over read or writable using chmod to change the permissions, and for shutdowns.

The best resource I found was an article on the Rasbperry Pi forum but to me I felt it was over complicated. There were lots of comments made to improve the result but all left out important bits leaving a guide which seemed to be do it wrong then change this bit by bit until it works this way.

I had to go through everything to pull out a relevant and simple process.

First rip a small monetary switch from some old press button electronics board or buy new. They are tiny and just connect when pressed down for a moment. 

Then check they open and close forming a circuit. I used a light and battery to create a simple series circuit to check the legs of the switch as I could only find square 4 leg switches in my scrap box and didn't know which leg connected to which.

I then cut of the wires from an old PC fan connector that fits into the headers on a motherboard. They are small and thin black power connectors. You'll see them and know they are perfect to connect to the headers on the Pi.

Solder the micro switch to the two wires from the flat black connector (it may have two or 3 holes in it depending where you got it from) and you have your plug in switch. This should just slide gently over the pins 5 and 6 on the Model B+

Count in from the top left by the mounting hole, use a guide first to see where they are. 2 , 4 , 5 and 6.

Now cut and paste the code from the forum post below into gedit. I used the code by "ame" at the end of page one as the later code didn't work for me. 

Save it as shutdown.py.

FTP the file to the Home/Pi/    folder

Use PUTTY to access the Pi and in TERMINAL go to the Home/Pi/ folder where everything is and chmod +x shutdown.py to change file permissions.

Then enter the Cron system that sets up timed events by crontab -e

Go to the bottom of the file and add at the end

@reboot /home/pi/shutdown.py


Save this. Shutdown the Pi and disconnect, fit the switch wherever you want it and connect it all up again.

After the reboot you should just be able to press the microswitch quickly and the Pi will shutdown from within with a shutdown call. the lights will flicker then go to a solid red. One more tap and the Pi will come out of hibernate.





Links to resources I've used and were useful.

https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/

Shows GPIO points on the Raspberry Pi B+ I used, they're different from the B model

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=106410

Called "Solderless clean shutdown/boot switch" if it moves.

http://www.trevorappleton.blogspot.co.uk/2013/11/creating-time-lapse-camera-with.html

https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=67109

Friday, 21 August 2015

Rotating timelapse Images in bulk & converting to AVI using ImageMagic

CD to your folder  eg.

TERMINAL

cd Desktop/camera/



Make a bash script. My images are upside down so I need the rotation 180% using ImageMagic's convert.


TERMINAL


for file in *.jpg; do convert $file -rotate 180 rotated-$file; done


This script takes files all files (* wildcard) within the folder that are jpg format and rotates them 180 degrees. It then renames the file by adding a "rotated-" to the start of the file name.

I just remove the unrotated jpg's cos I'm lazy then

TERMINAL

ls *.jpg > stills.txt


List all jpg files and send that down a pipe to a text file called stills.txt

I can then use memcoder (if installed) to convert the timelapse pictures to a short avi video

mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mf type=jpeg:fps=24 mf://@stills.txt

Saturday, 14 February 2015

Retro Pie

Not really about Linux mint but I thought I would add my notes here from setting up Retropie on my Raspberry Pi 256m. Just for my benefit incase I lose my tomboy note pad somehow.

Notes are grabbed from various sources. If I need to remove them or credit please tell me.







RetroPie Notes

Note from 2015-02-02 20:22:15.304

First Set-up change memory split from root file system : $ sudo raspi-config
also expand file system to fit card size

----------------------------------------------------------------------------------------------------------------------------------------------------
SETUP SCREEN

$ cd RetroPie-Setup
$ sudo ./retropie_setup.sh

----------------------------------------------------------------------------------------------------------------------------------------------------

If screen goes black ALT F2 then ALT F1 may work

Exit Emulation Station F4

When upgrading anything exit Emulation Station

Easy file copy Filezilla - use sFTP

Game Boy Advance - gba_bios.bin is stored in /opt/retropie/emulators/gpsp/

-------------------------------------------------------------------------------------------------------------------------------------------------------

Emulation Station config files for Joysticks info

top level config is for main emulation station controller and to control the main front end screen only. Start Em Stn 1st time it detects and asks.
To reset it up use console option or from terminal to delete file and make a new one
rm /home/pi/.emulationstation/es_input.cfg

To have controllers also work on the emulators edit the main emulator configuration file with the controller’s button information.

Basic way to start from scratch Use ‘retroarch-joyconfig’
find it (in case its been moved).

sudo find / -name retroarch-joyconfig

Maybe its here : /opt/retropie/emulators/RetroArch/tools
To store keymaps create a folder in the pi’s home directory with: mkdir /home/pi/keymaps
go to that directory: cd /home/pi/keymaps (one controller plugged in at a time when doing this)
/opt/retropie/emulators/retroarch/retroarch-joyconfig > /home/pi/keymaps/SNES_1.txt

View this file with Cat
pi@raspberrypi ~/keymaps $ cat SNES_1.txt
input_player1_joypad_index = “0”
input_player1_b_btn = “2”
input_player1_y_btn = “3”
input_player1_select_btn = “8”
input_player1_start_btn = “9”
input_player1_up_axis = “-1″
input_player1_down_axis = “+1″
input_player1_left_axis = “-0″
input_player1_right_axis = “+0″
input_player1_a_btn = “1”
input_player1_x_btn = “0”
input_player1_l_btn = “4”
input_player1_r_btn = “5”
input_player1_l2_btn = “9”
input_player1_r2_btn = “9”
input_player1_l3_btn = “9”
input_player1_r3_btn = “9”
input_player1_l_x_plus_btn = “9”
input_player1_l_x_minus_btn = “9”
input_player1_l_y_plus_btn = “9”
input_player1_l_y_minus_btn = “9”
input_player1_r_x_plus_btn = “9”
input_player1_r_x_minus_btn = “9”
input_player1_r_y_plus_btn = “9”
input_player1_r_y_minus_btn = “9”

Start button for all the other unused buttons is used here i.e.(9)

Now use RetroArch (the main configuration for all emulators). To find these (example)

pi@raspberrypi ~ $ sudo find / -name retroarch.cfg

RESULT
/etc/retroarch.cfg/opt/retropie/emulators/RetroArch/pandora/retroarch/retroarch.cfg/opt/retropie/emulators/RetroArch/retroarch.cfg/opt/retropie/configs/nes/retroarch.cfg/opt/retropie/configs/atari2600/retroarch.cfg/opt/retropie/configs/segacd/retroarch.cfg/opt/retropie/configs/megadrive/retroarch.cfg/opt/retropie/configs/mame/retroarch.cfg/opt/retropie/configs/mastersystem/retroarch.cfg/opt/retropie/configs/gamegear/retroarch.cfg/opt/retropie/configs/psx/retroarch.cfg/opt/retropie/configs/snes/retroarch.cfg/opt/retropie/configs/gb/retroarch.cfg/opt/retropie/configs/all/retroarch.cfg/opt/retropie/configs/gbc/retroarch.cfg/opt/retropie/configs/doom/retroarch.cfg/opt/retropie/configs/fbs/retroarch.cfg/opt/retropie/configs/pcengine/retroarch.cfg/opt/retropie/configs/cavestory/retroarch.cfg/opt/retropie/configs/sega32x/retroarch.cfg

The one that controls all of them is :
The others over-ride this file for individualisation, so you can amend the controller set-up for individual systems so
the right buttons cause the correct effect such as fire always being the same button on each emulator. REMEMBER this file will only effect all the emulators that work with RetroArch, the main frontend control.

----------------------------------------------------------------------------------------------------------------------------------------------------------------

To change the main config file in the "all" folder use nano from Terminal: /opt/retropie/configs/all $ nano retroarch.cfg

# Joypad buttons.
# Figure these out by using RetroArch-Phoenix or retroarch-joyconfig.
# You can use joypad hats with hnxx, where n is the hat, and xx is a string representing direction.
# E.g. “h0up”
# input_player1_a_btn =
# input_player1_b_btn =
# input_player1_y_btn =
# input_player1_x_btn =
# input_player1_start_btn =
# input_player1_select_btn =
# input_player1_l_btn =
# input_player1_r_btn =
# input_player1_left_btn =
# input_player1_right_btn =
# input_player1_up_btn =
# input_player1_down_btn =
# input_player1_l2_btn =
# input_player1_r2_btn =
# input_player1_l3_btn =
# input_player1_r3_btn =
/p
# Axis for RetroArch D-Pad.
# Needs to be either ‘+’ or ‘-‘ in the first character signaling either positive or negative direction of the axis, then the axis number.
# Do note that every other input option has the corresponding _btn and _axis binds as well; they are omitted here for clarity.
# input_player1_left_axis =
# input_player1_right_axis =
# input_player1_up_axis =
# input_player1_down_axis =

Uncomment input lines (remove #) and refer to your previous results found in the SNES_1.txt you made earlier and stored in /home/pi/keymaps
Add the button numbers including quotes "" to match.
input_player1_a_btn = "1" for example.
Change the axis's to match also. these are for the D-Pad.

----------------------------------------------------------------------------------------------------------------------------------------------------------------

Now enable Hot Keys (multi-button presses for other functions such as exiting). The example below uses double key presses to Select, Start,menu,save games and audio up/down.

input_enable_hotkey_btn = 8 #Select
input_exit_emulator_btn = 9 #Start
input_save_state_btn = 1 #A button
input_load_state_btn = 2 #B button
input_state_slot_increase_btn = 5 #R button
input_state_slot_decrease_btn = 4 #L button
input_reset_btn = 0 #X button
input_menu_toggle_btn = 3 #Y button
input_state_slot_increase_axis = +0 #Right on D pad
input_state_slot_decrease_axis = -0 #Left on D pad
input_reset_axis = -1 #Up on D pad
input_audio_mute_axis = +1 #Down on D pad

Save this in nano CTRL + X
Y
Enter

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Saving Game States (i.e. part way through). To do this you can give permission to your "Pi" user account to save in the folder normally only available to the "root" user where all saves are made. Failure to save is caused by you not having permission to write to the root folder.
sudo chown -R pi /home/pi/RetroPie

--------------------------------------------------------------------------------------------------------------------------------------------------

Wireless XBOX 360 controller set-up

-----------------------------------------------------------------------------------------------------------------------------------------------------

Duke 3D Install Issues

original DUKE3D.GRP must be in /home/pi/RetroPie/roms/duke3d
Joystick needs setting up and checking in the options

-------------------------------------------------------------------------------------------------------------------------------------------------------

Set up wireless network from terminal

sudo nano /etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0


iface wlan0 inet dhcp
wpa-ssid "ssid"
wpa-psk "password"

change ssid and password to yours

-------------------------------------------------------------------------------------------------------------------------------------------------------

BACKUP Pi SD CARD

Place card in Linux PC
Go to ROOT : $ sudo sh

find out what device the card is : $ fdisk -l
check by seeing what size card is e.g. 15.8 G

My card usually under /dev/SDC
dd is the copy image program, if (input file), of (output file), bs (baud speed, K,KB or M is multiplier speed of writing)

Use dd (execute it in folder you are saving to) : $ dd if=/dev/sdc of=THIS_IS_WHAT_IM_CALLING_IT.img bs=4M
Check it is there : $ ls -l -h
Compress file (minus 1 least compressed to minus 9 highest compression) : $ gzip -9 MY_CARD.img

------------------------------------------------------------------------------------------------------------------------------------------------------------

SOUND ISSUES

Set for HDMI or Audio Jack ?
Not using HDMI to DVI converter ? (DVI no sound throughput)

test from Terminal if sound using aplay : $ aplay /usr/share/sounds/alsa/Front_Center.wav

----------------------------------------------------------------------------------------------------------------------------------------------------------

Thursday, 12 February 2015

Wow, been some time and rzip

Wow, forgot how long it's been on here. My little place I keep my hints for myself and any others who get the same issues as me.
Obviously there are less issues with Linux Mint and I've not broken anything enough yet.

Anyway needed to do some compression on files today. Did a search, read a bit and it looks like rzip, from the repository was the one for me. Apparently lrzip is slightly better but I'd started encoding by the time I looked at that and it's just an upgrade to rzip.

So first I install it.

do a : rzip --help   for the info.

 -0            fastest (worst) compression
 -6            default compression
 -9            slowest (best) compression
 -d            decompress
 -o filename   specify the output file name
 -S suffix     specify compressed suffix (default '.rz')
 -f            force overwrite of any existing files
 -k            keep existing files
 -P            show compression progress
 -V            show version

Important notes being without the "-k" it deletes the original file after compression. I may not want that sometimes.