Pages

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, August 16, 2017

Spotify silently and remotely deleted app from Squeezebox devices

Spotify removed

Spotify silently and remotely deleted the Spotify app from the Squeezebox devices I found out after returning from vacation (Yes, they did post an article on their help pages I found out but I wasn't notified). I own a Squeezebox Radio and a Squeezebox Touch that I both use heavily to listen to music with the Spotify app. I even have a Spotify Premium Family account that enables me to play Spotify on multiple devices. I understand that support for hardware, such as the Squeezebox, is limited and will end some day. However what outrages me is that Spotify remotely removes software on a device that I own. Spotify makes it very clear that they control the software that they provide for the device and not the user. With that they control the functionality of my devices.

The Logitech Squeezebox Radio, one of several types of Squeezebox devices, now without Spotify (photo from https://en.wikipedia.org/wiki/Squeezebox_(network_music_player)).

The Squeezebox music player

The Squeezebox device is a network music player from Logitech. The devices are versatile and have excellent hardware. The Squeezebox can be used in two different ways; as a player that works with an online service, mysqueezebox.com, or with a private server called Logitech Media Server. I preferred to use my Squeezebox devices with the online service mainly for its ease of use and because some streaming services such as Spotify and Deezer are available as an app. The apps are very convenient to stream music just with a remote control. The Squeezebox hardware was discontinued in 2012 but  but, to it's credit, Logitech maintains the online service to this very day.

I didn't mention the best thing about Squeezebox, both the server and player software are non-proprietary and can be installed on several different operating systems. This enables all users to make build their own Squeezebox clients and servers.

Choices

With the removal of the Spotify app I have a choice to make. Will I continue to be using the my Squeezebox devices with the online server using Deezer instead of Spotify or will I set up my own private server? The latter is of course more of a hassle since it involves installing and maintaining the Logitech Media Server, ripping CD's to mp3's and storing them on the server. Nevertheless I may choose to create my own private server. I recently decided to move the software on my iMac from proprietary to non-proprietary so creating the private server for my Squeezebox would also make sense. I happen to have a Raspberry Pi 2 lying around and in the coming weeks I'll try to set it up as a Logitech Media Server.


Tuesday, November 22, 2016

Things you can do with PocketCHIP (other than gaming)

Introduction

As a backer of the PocketCHIP Kickstarter I received the PocketCHIP a couple of months ago. For those who don't know, PocketCHIP is a very portable Linux computer.  It comes in a case complete with keyboard and screen. After receiving it I played with it but it soon ended up in the drawer. PocketCHIP is very nice and all but I just couldn't think of a killer app for it. Recently however I saw a YouTube video of SuperHouseTV who used PocketCHIP to reprogram Arduino's on remote places. This inspired me to get my PocketCHIP out of the drawer and do something useful with it. In this blog post I describe three different purposes that the PocketCHIP can be used for.

PocketCHIP, Arduino and breadboard peacefully together on my workbench.


Radiostreams and music

The PocketCHIP can be a very basic mp3-player. I first tried mpd with mpc as client but it was too much of a hassle. Next I installed mplayer and it worked flawlessly.

apt-get install mplayer

Now I can listen to mp3's and radio streams. For example to listen to a radio stream of  Dutch Public Broadcasting type:

mplayer http://icecast.omroep.nl/radio1-bb-mp3

or to run an mp3 or ogg file

mplayer <filename>

I noticed that the audio stream was interrupted when I did other things on the PocketCHIP (running CHIP 4.3) diminishing the usability. Hopefully this will change when the CHIP software will be optimized in the future. NOTE: The mplayer software is more than an audio player in fact it's a very capable media player.

Security Camera

Earlier I installed a Raspberry Pi based camera system to keep an eye on our backyard. I wanted the PocketCHIP to connect with the Pi not only for maintenance but also to check the backyard from. This proved to be surprisingly easy. First login from the PocketCHIP to the Pi using SSH:

ssh pi@192.168.178.27 (change the ip address to your own)
your password

Next I use simple surf webbrowser to stream the video from the Pi to the screen of my PocketCHIP.

surf 192.168.178.27:8081

and presto a video stream of my back yard is shown on the PocketCHIP display.

Keeping an eye on my backyard with the PocketCHIP.

Programming an Arduino with PocketCHIP

as mentioned above the PocketCHIP can be connected to an Arduino to (re)program it. But I took it a step further. On the top floor of our house I have a hobby space. The Linux laptop (Puppy Linux) in the hobby space is very old and I'm unable to install the Arduino IDE on it. So I have the PocketCHIP with Arduino software installed connected with a USB cable to my Arduino UNO. With SSH I remotely connect my Linux laptop to the PocketCHIP and program the Arduino making use of the keyboard and screen of the laptop. This works great.

To install the Arduino software on PocketCHIP follow the instructions of SuperHouse. In addition to his instruction make sure to install the GNU make utility on PocketCHIP:

sudo apt-get install make

Now Arduino sketches can be written or changed on PocketCHIP and uploaded to the Arduino. Now to remotely connect to PocketCHIP I open the terminal program of the Linux laptop and type:

ssh -X chip@192.168.178.60
your password

substitute the ip address of my PocketCHIP with the one of your own. The default password of PocketCHIP is chip. The -X option enables the X11 forwarding which is needed for the following step. Type in the terminal:

arduino

and after a few moments the Arduino IDE becomes visible on the laptop monitor enabling me to write, save, compile, build  and upload sketches from the PocketCHIP to the Arduino, remotely controlled by the laptop. Type:

make upload

To compile and upload the sketch from the PocketCHIP to the Arduino. Call me crazy but I really love this.

Working with the Arduino IDE on my laptop but running on the PocketCHIP.

Overview of my workbench with the Linux laptop on the left and PocketCHIP and Arduino side by side on the right.
 

Conclusion

These three purposes of the PocketCHIP reignited my interest in the platform.  The PocketCHIP has gotten a permanent place on my workbench which is much better than lying around in a drawer. I'm use it almost on a daily basis to program my Arduino. In the next months I hope to give some more tips on PocketCHIP and the things you can do with it (other than gaming).

Saturday, September 10, 2016

Puppy Linux Tahrpup on my Thinkpad T40

Introduction

In November last year I decided to revive my very old (2003) Thinkpad T40 with Puppy Linux. Back then I was thrilled by the ease of installation and the speed of this Linux distro on this ancient laptop. Now eight months later I'll give an update on Puppy Linux on my PC. Am I still happy with Puppy Linux? 

The standard TahrPup desktop with the beautiful stylized Ardis icons.

Monday, May 9, 2016

Adding WiFi and audio streams to the cooler

Introduction

In my previous blog post I finished my audio cooler. It's a small cooler with a tiny audio system that nevertheless sounds good. The only way to control the audio is through a wired connection. It would be a nice addition to have some kind of remote control either by WiFi or Bluetooth. While testing the cooler I've got the idea to connect a Raspberry Pi A+, that was still unused, to the cooler and stream audio over WiFi to the Pi,with the Pi wired with the cooler. This could be useful for a garden party or BBQ where WiFi is available and I don't want to attach the smartphone to the cooler. In this blog post I'll share my experience with installation and operating the software needed for this project on the Pi.

Raspberry Pi A+ (in it's Pimoroni Pibow case)  connected with the headphone jack to the cooler. The Pi has a small Edimax Wifi adapter.

Installing MPD and MPC on the Raspberry Pi

Since I run the Raspberry Pi headless I use SSH login to the Pi. SSH is available for most operating systems with the notable exception of Windows. I already had Raspbian installed on the Pi so first I updated the OS and rebooted.

sudo apt-get update
sudo reboot -h now

Next I created a .conf file for the Edimax WiFi USB adapter. I learned from a previous project that, for a good remote connection, the sleep mode of the Edimax needs to be disabled. In the /etc/modprobe.d folder on the Raspberry Pi a file needs to be created with the name 8192cu.conf (8192cu is the name of the Realtek WiFi chip where the Edimax is based on).

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

Add the following line in the nano editor and save the file

options 8192cu rtw_power_mgnt=0 rtw_enusbss=0

reboot again

sudo reboot -h now

Now I needed software on the Pi that allows me to remotely play (and organize) music. I installed the MPD (music player daemon) and the very lightweight MPC (music player client) and this server/client combination seemed perfect for this purpose. There are many other clients for MPD, even for Android and iOS, but for now MPC is good enough. To install MPD and MPC on the Pi:

sudo apt-get install mpd mpc

According to some sources on the internet a sound driver (sudo modprobe snd-bcm2835) should be installed on the Pi however I found it was already installed, probably with Raspbian.  This can be checked with the lsmod command.

Adding streams to a playlist

With MPD and MPC installed I'm finally able to stream a radio station from my Pi to the cooler but I needed to add stream urls of my favorite stations. In the example below I add the stream of a Dutch radio station to the current playlist.

mpc add http://icecast.omroep.nl/radio1-bb-mp3

In order to play the stream just type and the added stream starts playing

mpc play

To save the current playlist type

mpc save aplaylist

The file with the name aplaylist.m3u file is created in the folder /var/lib/mpd/playlists with the above url of a stream in it. Of course other urls can be added to the playlist. I've found this list very helpful if you're looking for (Western) European streams.

Adding music to a playlist

To create a playlist of music that is stored somewhere as mp3's just add these files to the folder /var/lib/mpd/music on the Pi. Before the files are copied however the permission of this folder has to be changed. That is done by adding write permission to the group and by changing the group to audio (which is currently root).

sudo chmod g+w /var/lib/mpd/music
sudo chgrp audio /var/lib/mpd/music

Now the mp3's can be copied. To create a playlist of these mp3's first clear the current playlist, create a new one by adding mp3 files and save the playlist.

mpc clear
mpc add /var/lib/mpd/music/my_cool_music.mp3
mpc save cool_playlist
mpc update

The last command updates the database of MPD. By adding more files the playlist increases in length. To play the playlist use the same command as above (mpc play).

Conclusion

A music or internet stream over WiFi to the cooler is a nice addition. MPD is a very stable music player with lots of different clients, perfect for these kind of projects. With MPC I can easily add streams, create playlists, play music or even store mp3's on the Pi. Unfortunately WiFi with a Pi has some downsides too. The Raspberry Pi takes up space in the cooler and it will drain the small battery fast. Therefore as a next step I'll try bluetooth because it probably adds less weight to the cooler and has less power consumption.

Yes, the Raspberry Pi with MPD is a nice addition to the cooler but it has it's drawbacks such as power consumption and added occupied space.


Saturday, March 26, 2016

OpenELEC maintenance

Introduction

last year I built a PC especially for OpenELEC. For those of you who don't know, OpenELEC is a Linux based system with the sole purpose to run Kodi, the all-in-one solution to play all media you throw at it. Because of this sole purpose OpenELEC is very fast, especially on the Intel based system that I built, and very reliable. Over time however some maintenance of the system is necessary to keep the system up-to-date and fully functional.

Kodi running on OpenELEC 6.0.3

Creating a backup

I've added a lot of plugins and changed the settings of OpenELEC, therefore it is a good idea to make a backup. The easy way to do it is to add the Kodi Backup add-on. This plugin stores my userdata on an external drive (even automatically if I wish) as a zip-file. The add-on can be installed from within Kodi (Programs/Add-ons).

The settings of the Backup add-on need to be selected before a backup can be made.

Updating OpenELEC

Last year I installed OpenELEC 5.0 but recently OpenELEC 6.0.3 has been released so it was time to install the new version. I don't like to lose my current settings so instead of installing OpenELEC 6.0.3 fresh I choose to update the system with this latest install. Updating proved to be easy. I downloaded the OpenELEC 6.0.3 update file and placed the file in the /storage/.update folder. With Linux or OSX this can be done in the Terminal

scp OpenELEC-Generic.x86_64-6.0.3.tar root@192.168.xxx.xx:.update

The system will prompt for the password which is openelec. Make sure to use the ip of your OpenELEC system. The system will be updated if it is rebooted.

Updating the YouTube plugin

A month ago my YouTube plugin suddenly stopped working. The author of the plugin (Bromix) stopped the development and this quickly led to problems (as is usually the case with abandoned software). I too couldn't get the YouTube plugin to work anymore. Luckily Kodi being an open source program with a very active users group it didn't take long for others to take over the task of Bromix. I downloaded the YouTube plugin from Raspberryrabbit and copied it to a USB-drive. Before installing his plugin I manually deleted the old YouTube plugin folder. To do this I had to make a ssh connection with the OpenELEC system and delete plugin.video.youtube folder in the .kodi/addons folder.

ssh root@192.168.xxx.xx
password: openelec
cd .kodi/addons
rm -r plugin.video.youtube

Then I inserted the USB-drive with the new YouTube plugin in my OpenELEC system. Next I installed the plugin with the Video-Addon option of Kodi. After a reboot YouTube worked as before.

Luckily it didn't take long long before the YouTube plugin was working again.

Take a screenshot

Kodi has a huge number of built-in functions that can be used if you're a developer of e.g. plugins. These function can also be used remotely with an ssh connection and the kodi-send command. A function that I use is TakeScreenShot. It produces a screenshot and saves it as a png file in the screenshots folder of OpenELEC. With the following commands a screenshot is taken and copied to the current computer.

ssh root@192.168.xxx.xx
kodi-send --host=192.168.xxx.xx --action="TakeScreenShot"

After the screenshot is taken it can be copied remotely with the following command

scp root@192.168.xxx.xx:screenshots/screenshot000.png To/target/folder

E.g. if you want the screenshot copied to your desktop type the following command

scp root@192.168.xxx.xx:screenshots/screenshot000.png Desktop

Saturday, November 21, 2015

Ancient laptop with Puppy Linux

The burglar that "visited" our house a couple of weeks ago took our laptops and tablets. Luckily our desktops were left alone (probably to heavy). Also a very old IBM Thinkpad T40 was left behind. The burglar probably thought it didn't have any value. That was a bit of luck for me because with a little effort this 12 year old laptop is still very usable. After all these years the only thing that failed in this laptop was the battery. Everything else is still in excellent condition. These Thinkpads were (are?) very sturdy. On top of that they are very modular. Almost every component is easy accessible with just a screw driver. Very different from modern laptops that are almost impossible to open without special equipment.

The twelve years old IBM Thinkpad T40. Is it worth reviving it?
With a 1.4GHz Pentium M inside the T40 is, I suspect, hardly faster than the Raspberry Pi 2. I therefore needed an Operating System that isn't a burden for this hardware. Since Windows XP isn't an option anymore I looked at Linux and decided to give Puppy Linux 5.7 Slacko a spin.

Puppy Linux is very small and it loads into the ramdisk and is therefore very zippy , even on old machines. Installing it on the Thinkpad T40 was easy. It recognized all hardware even the wifi (which can be a problem with other distro's). Unfortunately I can't use the wifi chip inside the T40 because the WPA2 security protocol that I use in my network is unknown to this chip. This was easily solved with a wifi USB-stick.

Now I'm typing this blog from the T40. Firefox (version 17 ESR) works fine. I can access Google+, Youtube and other sites without problems although the rendering of some sites isn't perfect. With Geany I can create html/css pages and code Python. Wordprocessing is done with Abiword and spreadsheets with Gnumeric.

Do I want my laptops and tablets back? Of course but in the mean time I thank Barry Kauler and Co for this wonderful distro.

Puppy Linux Slacko 5.7 runs fine on this very old laptop.

Typing my blog on the T40 without a problem.

Friday, November 13, 2015

Raspberry Pi security camera, first experience

Introduction

(EDIT: updated on 4 May 2018). Last week I wrote about the Raspberry Pi, the camera module and Motion acting as a security camera. I've been testing my Raspberry Pi security camera for a week now and the results are satisfying although there are also some problems. I think much of the success of the camera comes down to finding the best settings of the /etc/motion.conf file of Motion for a given scenario. The motion.conf file enables you to setup the Motion program. Everything from camera settings to motion detection can be changed in this file.

Image from a motion video. If someone (in this case my son) is entering our backyard it is perfectly recorded by Motion.

Threshold

I want my security camera to record anyone entering my backyard but this sounds easier than it is. If the threshold parameter in motion.conf is too low all kinds of events are recorded that are completely irrelevant. E.g. on a rainy day raindrops falling on the window are recorded. With higher threshold values I might miss something relevant. After experimenting with different values of the threshold I found that a value of 1500 works best in my case.

Lens flare

On a sunny day bright sunlight can fall onto the camera lens causing lens flare. This reduced contrast and color saturation (see image below). More importantly the Motion program detect changes in lens flare as motion and records them. I think problem can easily be solved with some kind of lens hood.

Lens flare caused by sunlight reducing contrast and color saturation.

Night

A whole different problem is motion detection at night. My camera, the regular Raspberry Pi camera module, is just not up to this task. For detection at night I'll need the NoIR Pi camera. This camera has no infrared filter. As a consequence colours at daylight look odd but you're able to record at night, but only with infrared light illuminating the subjects. Several add-on boards for the NoIR Pi camera are on the market that do just that. These boards fit right over the camera module.

The regular Raspberry Pi camera module is useless at night.

Proper file permissions

I created a directory /home/pi/Camera on the Raspberry Pi. I want all my video files to be stored in this place however before Motion is able to do this I had to change the permissions. Motion (the program) creates it's own user motion so this user needs proper permission in the home/pi/Camera folder (that is created by the user pi). To do this I first changed the group ownership of the folder:
chgrp motion /home/pi/Camera
And next give the group the proper permission:
chmod g+rwx /home/pi/Camera 

Scheduled tasks

The number of motion video's that are stored on the Pi increase rapidly over the days. My backyard is quiet but not that quiet (not to mention the false positive that I described above). Since the Raspberry Pi stores the files on an SD card I will easily run out of storage space. So I need a method to remove the files automatically e.g after five days. Cron is perfect for this since it let me schedule commands or scripts periodically. I wrote a shell script that removes avi files created by Motion older than five days and added this to my crontab file to be executed daily. The key command in this script is:
find /home/pi/Camera -mtime +5 -name "*.avi" -exec rm {} \;
This shell script is then added to the crontab. With crontab -e the crontab file can be edited. If you're looking for a good article on Cron and how to create a scheduled task look here.

Copying files to a PC

Whenever I want to check the motion files (e.g after one day) I copy them to my iMac using scp from the OSX terminal and then created a playlist in VLC by dragging all the files into it. The harvest of that one day is then displayed.
scp pi@192.168.178.27:Camera/*.avi to/destination/folder

What's next

Next I'll test the security camera further until I'm satisfied with the settings and build a proper housing for the camera. Possibly I will switch from the regular camera module to the NoIR camera.

Saturday, November 7, 2015

Homemade security camera with a Raspberry Pi

Introduction

(EDIT: updated on 4 May 2018) One week ago we've had a burglar in our house. Of course I immediately started improving the security of our home. After improving the usual stuff I felt the need for some kind of security camera. This camera could provide me a good view of the backyard which is a very quiet place and therefore preferred by burglars. Because I like to make things myself I thought it was a good idea to use a Raspberry Pi and it's camera module. I used them in the past for time lapse video's of scenery but I hadn't used it much lately.

The goal that I had set was a camera that detects and records motion and that I could access through our local network preferably a browser. I also wanted the camera to give decent images by day and night.


Hardware.

The heart of the system is a Raspberry Pi model B with the Raspberry camera module (5MP). Furthermore I use an Edimax dongle for my WiFi connection and a micro-USB power supply (1A). Initially I use an MDF case that I made to fit the camera and the Pi. It isn't pretty but it protects both the camera and the Pi. If everything works as planned I probably built it into a dummy camera such as this one or may make a wooden enclosure myself.

Initially I had some problems connecting to the Pi through SSH. I discovered that this was caused by the Edimax dongle (8192cu WiFi chip) that apparently goes into sleep mode after a period of inactivity. This was solved with a command line fix that disables power saving (see here on page 17 how to fix this).

Raspberry Pi B and camera module in an MDF enclosure.

Software

On top of Raspbian (I installed Wheezy with Desktop but nowadays I'd suggest using Stretch Lite) I installed Motion. Motion is a Linux program that monitors the video signal from camera's and, very important to me, is able to detect motion. Motion is widely used and there is plenty of good information on it on the internet. A simple tutorial how to install Motion specifically on the Raspberry Pi and get it to work with the Raspberry camera module can be found on here (go to step 7 for software installation). However Motion has far more possibilities and it is worthwhile to explore these once you start using it.

Configuring and testing the system

Motion can support multiple camera's but I'll stick to one camera for now. Configuration of Motion for the Raspberry Pi and it's camera module is done in the /etc/motion.conf file (not in the /etc/motion/motion.conf file). There is a very good YouTube tutorial on configuring Motion for Linux here and here. At this point I made only a few changes to the motion.conf file such as camera width and height, directory where the video is stored on the Pi and some camera specific variables.

The camera works great. The image quality is good and the system appears to be stable. I can open a stream of the security camera in my browser by entering the URL of the Raspberry Pi and the selected port (default 8081). My motion files are stored as avi's on the Raspberry Pi. I can play them with VLC media player on my iMac. Next I'll experiment with the settings of Motion (e.g. sensitivity of motion detection, resolution of the camera), test in under different circumstances (indoor, outdoor, night and day) and build a proper housing for the security camera.

It doesn't look pretty but the security camera works great.