HowTo: FHEM – Installation on the RaspberryPi

One term you come across more and more often in everyday life is "SmartHome". But what does it mean? And do I really need it?

Smart home (=intelligent home) is a generic term for the networking of various devices in the household.
The ideal scenario is that more and more household appliances communicate with each other, exchange data and use this data to automatically control our homes.
So these systems are supposed to do the work for us.

As always, this is best explained with an example:
If you have a smart home system at home, this could automatically switch off the heating (or set it colder) if you are not at home, when you return the heating is automatically switched on again. Of course, this doesn't just happen when you walk through the front door, but when you are on your way back.
In the same way, other devices that are not needed (e.g. the light) could go into energy-saving mode or be switched off when it is detected that nobody is at home.

Now the average German will probably say to themselves: "I don't need something like that. People have survived the last 2000 years without it."
All I can say is: Yes, that's right!
But it's like many things in life: You don't really need it, but it still makes life easier.
The same argument applies to cell phones, cars, televisions, supermarkets and everything else in our lives that we don't really need but don't want to do without.

What currently speaks against this system or the systems is that it quickly becomes very expensive and there is no uniform standard.
For example, controllable adapter plugs - i.e. adapter plugs with which you can switch a lamp on and off, for example - now cost from €40 upwards. If you want to use them to switch several devices, you can quickly save a lot of money.
What's more, AVM's switchable sockets are not compatible with Osram's switchable lamps. Every company does its own thing when it comes to smart homes. If you have several systems in use, this inevitably means that some sensors and actuators (such as switchable sockets) cannot communicate with each other and that you always have to work with several apps to control these things.
Another argument that makes my stomach ache with commercial systems: Where does my data go? Who else knows that I'm not at home at the moment and might even be able to exploit this?
All arguments that actually speak against the idea that a smart home should make everything easier and safer.

This is where FHEM comes in. This is an open source smart home management software that is publicly available free of charge.
This means that this software and its code are public. Anyone can see that this software does not send any data to any external servers.
The big advantage of this is not only that it makes such a system much cheaper, you can also use FHEM to combine several systems from different manufacturers and control them centrally.
FHEM has become so versatile that in my opinion it is difficult to find hardware that is not compatible with it.

In this article, I will explain what you need to put your first smart home control center into operation with FHEM and what you need to bear in mind. I will link further examples of the various possible applications at the end of the article.

Required hardware

In order for FHEM to continuously monitor your home, it must of course run continuously. However, as the power supply companies should not be too happy about this, it should be as cost-effective as possible.
That's why this is a perfect place for the RaspbberyPi. This is a computer about the size of a credit card which, once set up, can be placed anywhere in the cupboard.

Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support in being able to offer other useful projects in the future. 🙂 


Before you start with this article you should have prepared the RaspberryPi so that it is accessible via the network and controllable via SSH.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

Tools needed:

Materials needed:

In the following list you will find all the parts you need to implement this article.

Log in to the RaspberryPi via SSH

To start, you must first log in to the Rasp Pi with Putty via SSH. How to do this is in the article RaspberryPi - Control the RaspberryPi via SSH described.

After entering your username and password you can enter the first commands.

Update package management

The package management in Linux is a "central place" through which various software packages can be installed. In order for this to work reliably, the lists and sources of the package management should be updated before each installation of new packages.

To start the update of the package management you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long ago your last update of the package management was, this process can now take a while. The lists that refer to the individual package sources are updated first.
After that, the packages themselves are updated. Since additional memory is occupied, you will be asked again for your consent. You have to confirm this with a "J" and "Enter".
Once the update is complete, you will see a small summary of the duration and scope of the update.

Install the required packages

In order for FHEM to run properly, you need to install various auxiliary packages. You can carry out the installation with the following chained commands.

sudo apt-get install libdevice-serialport-perl && sudo apt-get install libio-socket-ssl-perl && sudo apt-get install libwww-perl && sudo apt-get install libcgi-pm-perl && sudo apt-get install libjson -perl && sudo apt-get install sqlite3 && sudo apt-get install libtext-diff-perl && sudo apt-get install libdbi-perl && sudo apt-get install libdbd-sqlite3-perl

During the installation of the auxiliary modules, you may be asked whether you agree that the modules to be installed will take up additional memory space. Confirm these questions with a "j" and Enter. The installation will then continue.

Download FHEM

After installing the auxiliary packages, the actual FHEM software can now be installed. To do this, you need to download the package from the FHEM website. This can be done with the displayed command and the corresponding link.

wget http://

Please note that FHEM is constantly being further developed. The part "X.Y" in the link therefore stands for the version of FHEM that may change as a result. For the current version (5.8), for example, the link would be


The current version can always be found at the top of the FHEM website at So you have to adjust the links accordingly and then run the download on the RasPi.

Install FHEM

After the download, the package you have just downloaded must be installed. This can be done with the following command. You must also adapt this to the corresponding version.

sudo dpkg -i fhem-XYdeb

So for the current version:

sudo dpkg -i fhem-5.8.deb

Installation completed

FHEM is now installed and accessible under the IP address of your RasPi.
Now enter the IP address (the same one you use to connect with Putty) in the address bar.
After the IP address, write the port on which FHEM is accessible with a colon in front of it.
So ":8083".
If your Raspi has the IP address then the link to FHEM would be

What you see now is the first start page of FHEM. Of course, FHEM can't do much in this first state. In the following articles you will learn how to use the FHEM configuration page, protect it with a password and activate a slightly more upbeat design:
FHEM - Structure, modules & interesting facts
FHEM - Secure access to the configuration interface

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at       

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.