Tutorials for your Raspberry Pi.

Month: March 2016 (page 1 of 3)

Domoticz Onkyo Reciever control

If you followed this tutorial, you know how to retrieve the device status in Domoticz.
But this is only the status, what if you want to shutdown the Onkyo receiver from Domoticz?
This tutorial will work for most of the Onkyo models, i’ve a Onkyo 616.


There are 3 ways to control your Onkyo receiver:

1: With a PHP script (you need a webserver)
2: With a LUA script
3: With a netcat hex string, send directly to the Onkyo receiver.

I will explain number 3 today:

First update your raspberry pi.

sudo apt-get update

Install Netcat:

sudo apt-get install netcat

Download this Microsoft Excel sheet to get all the commands,

Now you need to know the IP adres of your Onkyo receiver. If you get that, use the following command to switch your receiver off.
Change the to your Onkyo receiver IP address.

echo -e 'ISCP\x00\x00\x00\x10\x00\x00\x00\x08\x01\x00\x00\x00!1PWR00\x0D' | nc 60128 &> /dev/null


Now create a bash script with the echo command above in it.

echo -e 'ISCP\x00\x00\x00\x10\x00\x00\x00\x08\x01\x00\x00\x00!1PWR00\x0D' | nc 60128 &> /dev/null

Save it, for examle: onkyo-off.sh  and make it executable.

sudo chmod +x filename

Add the script as OFF action on your Onkyo witch. If you toggle the switch, the receiver will switch off.
IF you want to use the switch ON function, you must switch the standby modus on, on your Onkyo receiver.
Page 5 on the excel sheet will tell you ALL THE POSSIBLE COMMANDS.
The command for muting the sound will be:

echo -e 'ISCP\x00\x00\x00\x10\x00\x00\x00\x08\x01\x00\x00\x00!1AMT00\x0D' | nc 60128 &> /dev/null

AMT00 = Muting sound
PWR00 = Onkyo power off
Don’t change the “x00!1”
Get it?  Have fun!



Domoticz presence detection

Domoticz presence detection
Want to add your smartphone,tv, receiver or other device in Domoticz? Use the check_device_online.py script!

As soon as my Smartphones connects to my home wifi, the status in Domoticz will switch from Off to On, in my case from “Uit” to “Aan” (dutch) 🙂
I also use this script to retrieve the status of my Onkyo home theater receiver, and added a OFF script, now it’s possible to shutdown the Onkyo player from inside Domoticz!



First logon on your raspberry pi and browse to this folder


and use this command to download the script

wget http://raspberrypihelp.net/downloads/check_device_online.py

Make the script executable:

sudo chmod +x check_device_online.py

Open the script

nano check_device_online.py

and change the following lines according to your Domoticz setup:

domoticzusername = "username"
domoticzpassword = "password"
domoticzpasscode = "passcode"

Change the server ip yo your own Domoticz server, and if you use a username and password, fill it in between the “”.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python

Pyton already installed? Perfect!


Open Domoticz and add a Virtual Dummy switch.

Setup -> Hardware


Now go to the Switched tab, and click on the ‘Manual Light/Switch’ button in the upper left corner.


Hardware: Choose your Virtual dummy switch.
Device name: Name it! 🙂
Switch type: On/Off
Type: X10
House Code: A (don’t care)
Unit code: 1 (don’t care)

Your new switch is now visible in the Domoticz switch menu.



We need to know the IDX number of the new switch:
Setup-> Devices. And look for your new button. In my case the IDX number is 45.




Run it!
The script needs 4 parameters to run:

The IP-address of the device you want to check (In my case ‘’)
The ID of the virtual switch (In my case ’45’)
The interval (seconds) on which to check if a device is present or not (In my case ’10’, for 10 seconds)
The ‘cool-down’ period (seconds). If a device does not respond within this period, the virtual switch is turned off. (In my case ‘120’, for 120 seconds, or 2 minutes)

python check_device_online.py 45 10 120

Your console output will be something like this:

19:43:21- script started.
19:43:21- according to domoticz, is online
19:43:22- offline, waiting for it to come back

Exit the script with Control + C

The best way is to create a cronjob for the  script:

 sudo crontab -e

And add your line on the bottom:

*/10 * * * *  /home/pi/domoticz/scripts/check_device_online.py 45 10 120


Save & exit with


If you don’t want to use Cron, and just want to run the script from the command line. Use the program “screen
Screen makes it possible to close a open SSH session, and it will remains open when it’s closed. It’s one of my own most used Linux programs.


Script credits: Chopperob, sadly his website not working atm.
All this info is also available at  the Domoticz wiki page, but not with the fancy screenshots.
And the most important reason, my website is online, often the source website is offline after a while when i need some of the information again.

Domoticz WIKI page
Chopperrob’s webpage (currently offline)






Chromecast ROOT (1st Gen)


Why custom rom/root? Main reason: Custom dns server, change dns to a custom dns service website, And you can watch Netflix USA, or other regions.
Netflix with custom DNS is almost impossible these days, and rooting the first gen chromecast with firmware 17977 or below are rare.

First of all,

Thnx to all the guys of Team-Eureka, they made this possible. They deserve a donation!
Also thnx to Elborak, who converted the original hex file to Leonardo hex files!

What do you need?

  • Chromecast (UNUSED, NEVER CONNECTED TO THE INTERNET!!) Cc’s from the store are shipped with old firmware 17977 or lower, the newest firmware cannot be rooted. With internet, Google will automatically update your cc to the newest firmware version.
  • OTG Host Power Splitter Y cable USB: http://goo.gl/J8vvck
  • ATmega32U4 based micro controller: http://goo.gl/bkiMyd
  • Usb thumb drive 1 GB or bigger.


Install software:

  • Install the Arduino IDE software.
  • Install Arduino Builder.
  • Reboot computer.

Prepare hardware – Arduino:

Connect the arduino to your pc. Go to device manager to see which port the arduino will use. In my case, it’s com port 7.


Start Arduino builder Select Arduino Leonardo as Board type. Click on “Load Sketch / HEX” And load LEONARDO_16664.hex


The .hex file is loaded on the arduino!

  • Pull your arduino from your computer.


Prepare hardware – Usb thumbdrive:

  • Insert usb drive in computer.
  • Format the usb drive (FAT32)
  • Install Win32DiskImager and open it.
  • The “Device” should be the drive letter of the usb drive.
  • Click on the blue folder icon.


In the right lower corner click on “Disk Images (.img*.IMG) and select *.*, to see all files

  • Now load the hubcap-flashcast.bin file and use the “Write” button to write the .bin file on the usb drive.


It’s time to root, UNPLUG YOUR INTERNET!
If the chromecast connect to your wifi network, it something went wrong the cc will be automatic updated to latest (UNROOTABLE) firmware. So unplug internet before you are beginning the root process.
When the rooting process is done, i also connected the chromecast to this network.

What i did: Made a wifi hotspot with my android tablet, also connected my android phone to the tablet wifi hotspot. Now we have a new wifi network, without internet.


Connect all cables as in the following picture.



This is the second picture, when the arduino part is done, and the usb drive is connected:


And watch my video how to actual complete the root process. A video is worth a thousand words 🙂


Last step:
Checking if you have actual flashed the Eureka-rom:
Open the Chromecast app, follow the in-app connecting steps.
Scroll to the bottom, to see the chromecast IP address.



Open your internet browser and go to the ip address of the chromecast. Like: http://192.168.x.x


If you see the Team-Eureka Webpanel, then you are 100% ROOTED!!





Do you have other intention with your Arduino after rooting your chromecast? Then you must follow the next steps.

Connect the arduino on your windows computer and the arduino will appear for about 8 seconds in windows device manager, remember the COM port the arduino is using.
Download AXLoader

Unpack the .rar to a easy accessible, like C:/
Use windows command line (Windows Key + R -> ENTER – > cmd -> ENTER)
Navigate to c:/axloader        This is the command –>> cd c:\axloader
Copy/pas this command in command line, fill in your own COM port, mine was 7.. AND DO NOT PRESS ENTER!

avrdude -p atmega32u4 -c avr109 -P COM8 -U flash:w:Blink.hex -v

Now the tricky part.
Use something metal to short the GND & RST pin on the arduino.



When you will do this, the arduino will disconnect, and connect to your computer, in the following 8 seconds, press the ENTER key to execute the command above.
High five! The arduino is normal again! 🙂

If you will wait more then 8 seconds, the arduino will load the Chromecast ROOT program, and you are not be able anymore to upload the code. If this is the case, short the 2 pins again 🙂


Have fun!


Qi Charger build in nightstand cabinet

Ikea nightstand with build in Qi charger



Part list:

Ikea Hemnes nighstand.

Cheap Qi wireless charger from E-Bay.


1: Find the right spot for the charger.


2: First milling line, Desk is 2,2 cm thick, milling untill  it’s 3 mm thick.

3: Removed the frond side of the Qi chager. Less objects between the phone and charger.

4: Ducktape!

5: The back of the nightstand.

6:  Made a tiny little spot on the desk. otherwise I do not know where to place the phone.

7: READY!! (And it’s charging 🙂 )

P1 Slimmer meter kabel maken – PL2303 chip (Dutch / Nederlands)

Hoe maak je zelf een P1 Slimme meter uitlees kabel met PL2303 chip.

Allereerst gaan alle credits naar Gé Janssen en ThinkPad. Zonder hun was het me nooit gelukt,

De laatste tijd ben ik aan het spelen met Domoticz. Niet dat ik veel wil automatiseren, maar om te zien hoe het DIY domotica wereldje in elkaar zit.
Dan kan het uitlezen van de P1 poort op je slimme meter niet uitblijven natuurlijk. Je kan de kant en klare kabels voor rond de €15 tot €20 kopen, maar zelf maken is veel leuker.

Ik zelf ben geen techneut, en heb ook niet de skillz om zo’n kabel zelf te ontwikkelen, maar gelukkig zijn er genoeg mensen op het internet die dat wel kunnen.
Als je Googelt hoe je zo’n kabel maakt, kom je al snel uit op dit domoticz topic. Daar legt de gebruiker ThinkPad uit hoe je zo’n kabel maakt. Hij gebruikt een Serieel – usb stekker waar je de RJ11 stekker zo op kan solderen. Op eBay zijn ook kabels te vinden met de PL2303 chip. Als je de PL2303 gebruikt moet je nog een transistor en weerstandje gebruiken om de kabel werkend te krijgen.

Eerst had ik een kabel besteld met de HL-340 chip, maar de chip zit netjes in het plastic gegoten. Na twee uur hakken en zagen heb ik het opgegeven 🙂




Toen maar een kabel besteld met PL2303 chip, deze chip is direct te gebruiken, maar je hebt dus wel nog een weerstandje en transistor nodig.


Onderdelen lijst:
1 x USB To RS232 TTL UART PL2303HX Auto Converter USB to COM Cable Adapter Module

1 x MOSFET Transistor BS170

1 x 10K weerstand

1 x RJ11 stekker met 4 aangesloten draden. Veel RJ11 (vaak gebruikt als telefoon stekker) heeft maar 2 draden aangesloten, wij moeten er een hebben met 4 draden.
Ik heb het kabeltje gevonden bij de kringloop, voor €0,20 cent had ik een 4 aderige kabel inc RJ11 stekker. De kabel zelf maken is ook niet moeilijk, koop wat losse RJ11 stekkers, en 4 aderige telefoonkabel. Je hebt wel een tang nodig waarmee je de RJ11 stekker kan knijpen. Maar waarschijnlijk hebben ze ook wel kant en klare kabel bij de Gamma 🙂

Eventueel kan je ook nog wat krimpkous kopen om de kabel netjes af te werken. Op eBay is genoeg krimpkous te vinden voor weinig geld.

De kabel,transistors en weerstanden kosten samen €3.79.
Ik was dus in totaal €4 kwijt. En dan heb je nog 9 transistors, en 99 weerstandjes over voor andere projecten.

Heb je alle onderdelen? Dan is het tijd om te gaan solderen!
De groene kabel van de PL2303 stekker hoef je niet te gebruiken.
Dit schema heb ik gebruikt:



Klaar? dan kan je de USB stekker in bijvoorbeeld je Raspberry Pi steken, en de RJ11 in je slimme meter.
In Domoticz voeg je nieuwe hardware toe:



Vervolgens kan je bij “Apparaten” twee nieuwe apparaten aanmaken. Een voor Stroom en een voor gas.


Niet elke slimme meter is het zelfde, dus het kan zijn dat je in Domoticz bij hardware -> Je slimme meter hardware instellingen -> de baudrate moet veranderen van 9600 naar 115200. Bij mij moet de baudrate op standaard 9600 staan. Ik heb een Kamstrup 162JxC meter in de kast hangen.


Raspberry Pi SSH security – Fail2ban



Raspberry Pi SSH security – Fail2ban

There are a lot of shady people on the internet, scanning IP ranges for vulnerable machines/raspberry pi’s.
With a simple program called Fail2ban you can kick out the bruteforcers.
After 6 failedssh login’s the IP of the client will be blocked by default for 10 minutes.
Your raspberry pi is a lot safer now!

How to:

sudo apt-get update
sudo apt-get install fail2ban


Now fail2ban is installed! Easy isn’t it ?

You can change settings @ /etc/fail2ban/jail.conf
1st picture are the common settings, 2nd picture is specific for SSH.





Have fun!

Raspberry Pi Mount External Harddisk

Harddisk in my case: Normal NTFS formatted.

Connect the hard disk on your Raspberry Pi.

Login with putty, or open a termal.

sudo blkid

You see the hard disk name and his location. Something like /dev/sdxX before it. Remember the /dev/sdxX.

Now make a new folder on your pi.
Example: /home/raspberrypi/hardiskmount/

mkdir /home/raspberrypi/hardiskmount/

now typ:

sudo nano /etc/fstab

Add a new rule:

/dev/sdX /home/raspberrypi/hardiskmount/ ntfs default 0 0

Change the X to your own number from the sudo blkid commando on the first step.

Save the file, and close it. (Control + x)

sudo mount -a


Now navigate to the /home/raspberrypi/hardiskmount/ folder, to use your mounted harddrive!


Have fun!

Raspberry Pi Nagios Monitor System



Nagios monitor system Raspberry Pi

With Nagios you can:

  • Monitor your entire IT infrastructure
  • Spot problems before they occur
  • Know immediately when problems arise
  • Share availability data with stakeholders
  • Detect security breaches
  • Plan and budget for IT upgrades
  • Reduce downtime and business losses

How To install Nagios on the raspberry pi?

Update + Upgrade your rasperry pi:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nagios3

After a while you get this screen, enter a password.


All done? You can access Nagios in your webbrowser:




Have fun!

Raspberry Pi Webserver



Host your own website on the raspberry pi? Yes you can!

You will install the following programs:

  • nginx
  • MySQL
  • PHP5-fpm
  • phpMyAdmin
  • ImagIck
  • vsftpd
apt-get update
apt-get upgrade

Now you are up to date 🙂


Install the mysql server:

sudo apt-get install mysql-server

You will get a screen for entering the mysql password, enter a long and secure password!


sudo apt-get install nginx
sudo service nginx start
sudo apt-get install php5-fpm
sudo apt-get install php5-imagick
sudo nano /etc/php5/fpm/php.ini

Change the rule “upload_max_filesize = 2M” to

"upload_max_filesize = 10M"

Add this rule at the  Dynamic Extensions section:



Control + X to close/save the file.

sudo apt-get install phpmyadmin

At the webserver selection screen press “TAB” on your KEYBOARD
[ENTER] Don’t select apache or lighttpd!

If you get the screen if you want db-config,  choose “Yes”.


The following step is entering your MySQL password, and set a password for phpMyAdmin.




sudo service php5-fpm restart
sudo mkdir /srv/www
sudo chown -R YOURUSERNAME:www-data /srv/www
sudo chmod -R 755 /srv/www
mkdir /srv/www/example.com
cd /srv/www/example.com
mkdir logs
nano logs/access.log (Just make the file, and close it)
nano logs/error.log (Just make the file, and close it)
mkdir public

(Change example.com with your own site-name)

sudo nano /etc/nginx/sites-available/example.com

Add the following info in the file:


server {
    server_name example.com;
    access_log /srv/www/example.com/logs/access.log;
    error_log /srv/www/example.com/logs/error.log;
    root /srv/www/example.com/public/;
    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public$fastcgi_script_name;
    location /phpmyadmin {
        root /usr/share/;
        index index.php index.html index.htm;
        location ~ ^/phpmyadmin/(.+\.php)$ {
            try_files $uri =404;
            root /usr/share/;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            root /usr/share/;
    location /phpMyAdmin {
        rewrite ^/* /phpmyadmin last;


sudo ln -s /etc/nginx/sites-available/yoursitename /etc/nginx/sites-enabled/yoursitename
sudo service nginx restart
nano /srv/www/example.com/public/index.php

Add the following:

<?php phpinfo(); ?>

Control + x to close/save the file.


Have fun!

Raspberry Pi File Transfer – WinSCP

Easy transferring your files from and to your Raspberry Pi, without setting up a FTP server!

Download WinSCP here: http://winscp.net/eng/download.php

If you boot wheezy-raspbian for the first time, enable SSH on the raspi-config screen. Or if you want to get into the config screen again.

 sudo raspi-config


Install Winscp, open it, and enter your Raspberry Pi details.

File protocol: SFTP or SCP. It dont care 🙂
Hostname = Your raspberry pi IP adres
Username: Your raspberry pi username
Password: The password of your raspberry pi username.




Once you are logged in, the left side of the screen is your local computer. The right side is your Raspberry pi!
Drag files from left to right or from right to left to copy files.



Have fun!

Older posts

© 2016 Raspberrypihelp

Theme by Anders NorenUp ↑