<< PREVIOUS PAGE (Home automation month) | >> NEXT PAGE (Domoticz Installation) |
This installation guide is based on Raspbian Stretch. This OS is specialized for the Raspberry Pi and is very suitable to run Domoticz. Raspbian is a fork of Debian Linux. For Domoticz you do not need a GUI on your PI so you should download the smallest possible footprint.
Prerequisites:
- Get yourselves (yet another) Raspberry Pi.
A version RPi 1 model B(+), RPi 2 model B, RPi 3 model B or even the RPi zero and RPi Zero W should be working fine. - Also get a SD card SDHC class 10, minimum 4 GB, but recommended is at least 16 GB, Class 10. Don’t buy the cheap ones, you would really like to have a high availability system. This is especially true when you have to score on the WAF (Wife Acceptance Factor).
- A way to put the Raspbian on the SD card. You can do this with a multi-card reader (Modern and high-end laptops have a built-in card-reader). Also, you can order a complete package where the Linux image is already put on for you.
- For power you will need to have a plug from 220/110V to 5V/2.5A. Minimum 1.5A power supply.
- Ethernet cable or USB WiFi adapter. I would always go for the wired option no matter what! Note that the RPi 3B has an onboard WiFi adapter so you do not need a separate adapter for the WiFi option. Maybe when you need a better antenna you can still decide to add an external WiFi adapter.
- Optional: Connect it to an HDMI screen or convert it from HDMI to DVI or HDMI to VGA. In the end, you do not need to have it connected for a long time. The management you can do over SSH, HTTP and HTTPs.
- Optional: USB keyboard.
- Optional: You can mount it in a case (or not).
Download and install Raspbian image.
Now download RASPBIAN STRETCH LITE. After downloading unzip the file.
Then download balenaEtcher (Available for Windows, Linux and macOs), this is an open-source utility which makes it possible to flash an image to an SD-Card (Be aware that this tool default sends usage statistics back home, you can disable that in the settings).
1) Select the image
2) Select the drive
3) Hit flash, possibly also click yes and just be patient.
Enable SSH (not really optional?).
Manually enable SSH. You can do that by creating an empty file in the root of the SDCard called ssh. Etcher had already safely removed the SDCard. You will need to remove it and reinsert it. Then create the empty file ssh (case insensitive). Safely remove the SDCard and remove it from your card reader.
When the RPi starts, Raspbian will look for the file and once present, it will enable SSH. Using the RPi without keyboard and monitor is called a “headless start”. This is the most elegant way to run Domoticz.
FIRST TIME BOOT.
Unplug the power from the RPi microUSB port. Remove the Micro SD card from the adapter and insert it in your RPi (in case of an RPi 1 model B you will have a full-size SDCard). Bring your RPi to life by applying power to the microUSB port. During boot, the RPi gets an IPAddress via DHCP. There are several ways to get to know the IPAddress:
- Connect a keyboard and a monitor (HDMI). Log on with:
username: pi
password: raspberry
ifconfig
this should reveil the IPAddress.
- Log on to your router which has the DHCP server. Search for something like DHCP Client list. Look which device has been added recently, this is probably your RPi. The name of the device is probably raspberrypi and then look for its assigned IP address.
- You can do a network scan (linux: nmap, windows: Advanced IP Scanner). A new device found in the network is probably the RPi.
SSH connection to your RPi (preferred).
Once you have the IPAddress, you can connect to that IP address with SSH (under Windows you could use: Putty, under Linux you can execute in the terminal: ssh pi@<IPAddress>). On initial contact you will probably get the following screen. It is notifying you there is an unknown certificate detected. This is normal (only once!) when connecting with SSH.
The credentials are the same as before:
SSH default username: pi
SSH default password: raspberry
Adjust or assign IP Address (DHCP).
In your router, you can make an IP reservation. This means that the RPi will always get the assigned IPAddress based on the MAC Address of the ethernet interface.
If all things went right, you could get something like this on the console of the RPi (or download via scp or ftp the file /var/log/boot.log):
The fun thing to observe is “My IP address is 192.168.1.89“. This is due to the fact that I assigned a fixed IP address to the MAC address 🙂
Adjust or assign IP Address (Static).
On the other hand, you can also make the IPAddress fixed in the configuration of Raspbian.
TBD.
RASPI-CONFIG
Here is a section of all the things you can do with the RASPI-CONFIG.
More information can be found on the Raspbian website.
Connect to the RPi using SSH. Log on with the given credentials (pi, raspberry) and enter the following command:
sudo raspi-config
raspi-config: Change default password (not optional at all if you ask me !)
(sudo raspi-config)
Select “1 Change User Password“, and then follow instructions.
When the password is not changed you get this message during ssh login to remind you.
SSH is enabled and the default password for the ‘pi’ user has not been changed.
This is a security risk – please login as the ‘pi’ user and type ‘passwd’ to set a new password.
raspi-config: Select hostname
When having multiple systems running, it could be nice to set the hostname so you can easily identify the system. Especially true when having multiple systems in your network.
(sudo raspi-config)
Select “2 Network Options“, and then select “N1 Hostname“. Enter the new name here.
raspi-config: Adjust time zone
(sudo raspi-config)
Select “4 Localisation Options“, and then select “I2 Change Timezone“. Select your region. Then you can now type the first letter of your capital city and select the correct one.
In my case I selected Amsterdam. Eindhoven is still not the capital city of the Netherlands, but it is capital of Silicon Valley in the Netherlands 😉 Anyhow Eindhoven is not (yet) in the list of items to select. Local and Universal times are updated to the selected region.
Current default time zone: ‘Europe/Amsterdam’
Local time is now: Fri Nov 30 16:00:16 CET 2018.
Universal Time is now: Fri Nov 30 15:00:16 UTC 2018.
raspi-config: Select WiFi country (only on a RPi 3 model B or when you connected an external WiFi device.
When using WiFi for regulatory reasons you will need to provide the country. Why? Probably because the channels available per country are different and by setting the correct country, you will comply with the regulations.
(sudo raspi-config)
Select “4 Localisation Options“, and then select “I4 Change Wi-fi Country“. You can now type the first letter of your country and select the correct one. This information will be updated in the /etc/wpa_supplicant/wpa_supplicant.conf file.
raspi-config: Alternative way to enable SSH
If you didn’t already enable SSH, you can do it now.
(sudo raspi-config)
Select “5 Interfacing Option“, and then select “P2 SSH” and enable SSH.
raspi-config: Adjust memory settings
The total memory available is split between the CPU and GPU. Since there is absolutely no GPU usage done here, you can better optimize the GPU usage to the bare minimum.
(sudo raspi-config)
Select “7 Advanced Options“, and then select “A3 Memory Split“. Enter 16, the GPU cannot go below 16MB so a lower number totally has no use.
raspi-config: Expand filesystem (Obsolete in Raspbian Stretch) (Do this one last, it requires a reboot).
In the previous version of Raspbian expand filesystem was needed to use the full disk space available on the SDCard. This is now done automatically in the latest image of Raspbian Stretch. During the first boot, the following screen pops up.
In rare cases, this did not happen. Most of the times the image which was installed with Etcher was smaller than the SD card. To be able to use the full disk space of the SD card, you can expand the partition to cover the whole SD card. After expanding, you will need to reboot to make it effective.
Here is the procedure needed for expanding:
(sudo raspi-config)
Select “7 Advanced Options“, and then select “A1 Expand Filesystem“. Note, there is no confirmation required, selecting the option will begin the expansion immediately.
Exit raspi-config and the system automatically suggests restarting. Select Yes. Right after this, you will lose the SSH connection. Don’t worry, it will be back soon. If you want to restart later, here is the command:
sudo reboot
The effect of resizing is? Here is a picture before resizing.
And here the situation after resizing:
KEEP YOUR SYSTEM UP-TO-DATE
Regularly execute system updates
Do the following commands on the commandline. They come in handy when installing extra components later. It makes your OS as up-to-date as possible.
sudo apt-get update
sudo apt-get upgrade
You need to press Y <enter> or just hit <enter> for it to start doing it.
sudo apt-get dist-upgrade
After that reboot the system (again) with:
sudo reboot
Last but not least, Shutdown Rasbpian properly!
Do not turn off the system by unplugging the power to the RPi!
Especially Unix systems running from an SD card do not like the power just to be removed. Always use a proper command to shut down the system before removing power.
sudo poweroff
You can even think of installing a UPS or use a power back in the middle as a power buffer in case the power goes down. Also, a supercapacitor could be used to temporarily take over the supply of electrons. I still need to find a way to detect this and do a graceful shutdown automatically. Maybe an IO port detection in combination with a script?
Please continue to the next page for the installation of Domoticz.
<< PREVIOUS PAGE (Home automation month) | >> NEXT PAGE (Domoticz Installation) |