Setup RaspberryPi Zero

This article is about building your own infrared bridge based on a Raspberry Pi Zero. Of cause it will not be so comfortable to configure like a Logitech Harmony Hub, but it will be much cheaper – down to 12€.

Prerequirements:

Hardware:

  • Raspberry Pi Zero WH (Amazon* Link, Buyzero Link)
  • Micro SD Card (min. 4GB) (check the Bundles at Buyzero if you need one)
  • Power Supply with Micro-USB-Plug, recommended 2,5A or more (check the Bundles at Buyzero if you need one)
  • Optional: Case for Rapsberry Pi Zero WH (check the Bundles at Buyzero if you need one)
  • Maybe Optional: USB SD-Card-Reader (if you don’t have a Card Reader in your device) (Amazon* Link)
  • Optional, not required for this how-to: MicroUSB to USB Adapter (to connect a keyboard to the Raspberry Pi Zero) (Amazon* Link)
  • Optional, not required for this how-to: MiniHDMI to HDMI Adapter (to connect a screen to the Raspberry Pi Zero) (Amazon* Link)

Software:

Setup the Raspberry Pi Zero

If you have a Mini-HDMI to HDMI-Adapter and a Micro-USB to USB-Adapter, you can connect directly to the Zero. But you do not need this for this tutorial! The following steps can be used to install the Raspberry Pi Zero without any adapters. The basic setup will be done on your Windows machine.

Step 1: Download the image for the Raspberry Pi Zero. Download the Lite-Version of the latest OS (at time of writing, it is “Stretch”): https://www.raspberrypi.org/downloads/raspbian/

 

Step 2: Flash the SD card

Save the file on your local PC somewhere where you will find the file. When the download is done, you have to extract the image the from downloaded zip-file. To do so, right click the file and select “Extract all..” and click “Extract” at the bottom of the window.

 

After this is done, a window will open with the “2018-06-27-raspbian-stretch-lite.img”-File. Maybe the file is named slightly different in your download. If you have this, the img-file is ready to be copied to the SD Card.

Now copy the downloaded image to the SD Card. Plug in your card reader with your SD Card in the SD Slot or in case of a build-in card reader, just plug in the SD Card. You also need a software to copy the image. I recommend “Win32 Disk Imager”. That one is free and easy to use. You can download it here: https://sourceforge.net/projects/win32diskimager/
After the download, please install and start the software. You will see this window:

 

In the first field, select the img file you just extracted and select the SD Card-Reader drive at the right (1). If you have no USB Stick or external HDD connected to your system, the SD-Card Reader should be the only drive that is available (2). After you entered this options, click the “Write”-Button (3).

Finally you will get a success message and the write process is done.

 

Step 3: Configure the Raspberry
Windows will now find a new drive called “boot“. Usually it has the drive letter, that was used during the image writing (arrow with point 2 above). To be able to access the Raspberry after the setup via SSH, we will create a file called “ssh“. Important: Lower case and no file extension. To create such a file, change to the “View“-Tab of the file explorer (1) and check “File name extensions” (2). Perform a right click in an empty area of the explorer (3) and select “New” (4) => “Text Document” (5).

A new file will be shown in the explorer. Name it “ssh” without any extensions. Windows will ask you if you are sure to do so: Yes we are. We do not need to write any content to the file. It is just important that the file is present. When the Raspberry starts, it will automatically start the SSH services. This allows us to connect to the Raspberries console.

To be able to connect to the Raspberry, it also need a Wifi connection. To configure this, we will need Notepad++ (Download here). Windows Notepad or Wordpad will not work because we have to take care about the Unix line feed format. This is different between Windows and Linux/Unix.
Create a new file called “wpa_supplicant.conf” next to the ssh-file the same way we did before. Right click the file and select “Edit with Notepad++“.

Paste the following text into the editor. Replace the country-, ssid- and psk-values with yours. (i.e. country=US, ssid=”myWifi”, psk=”myTopSecretWifiPassword”).

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="MyWifi"
    scan_ssid=1
    psk="IdontTell"
    key_mgmt=WPA-PSK
}

Next take a look at the lower right of the editors window. Doubleclick the “Windows (CR LF)“-Text in the Statusbar and select “Unix (LF)“.

Save the file and close the editor.

 

Step 4: Start and continue to configure the Raspberry
Remove the SD Card from the card reader and plug it into the Raspberry. After about a minute you should find your Raspberry in your network (if you are using DHCP). The easiest way to figure out the IP is to ping the name “raspberrypi” using IPv4 protocol. To do so press the Windows-Key and “R” and enter “cmd“.

Press OK. Enter “ping raspberrypi -4” into the console and press enter (1). It will ping the raspberry four times and shows the IP-Address (2). In the screenshot it is 192.168.0.145. Note the IP-Address for future use.

Now we can connect to the Raspberry via SSH. We will need Putty for this (Download here). After starting Putty, enter the IP of your Raspberry (1). To save the settings for future connections, enter a name in the “Saved Sessions” field (2) and click save (3). The name will appear in the list below.

Now doubleclick on the saved session to connect. The username (“Login”) is “pi” and the default password is “raspberry“. You will see the following after login:

You already see the hint, that you should change the default password. We will do it now. Type the following command into the console and press enter:

passwd

Now enter the current password (“raspberry”) and enter your new secret password twice. Remember: if you type a password in any Linux system, it is not shown. You will see no stars or any other character. It is like you didn’t type anything. If this was successful it will look like this and you password was changed:

Now we will change the default hostname to a unique one. You should do this because any other new RaspberryPi in your network will have the same name and this will cause problems in the network communication. To change the hostname, execute the following commands:

sudo hostname -b <your unique hostname>
sudo nano /etc/hosts

Now you are in a texteditor of Linux. Go to the line that starts with “127.0.1.1“, followed by “raspberrypi“. Replace the “raspberrypi” with your new hostname. And press Ctrl+O followed by return-key to write the changes. Now press Ctrl+X to exit the editor. At the end the file should look like this, where “rp-irbridge1” is the new hostname in my case:

Now execute the command

sudo nano /etc/hostname

and replace “raspberrypi” again with your new hostname. After you changed the name, press Ctrl+O, return, Ctrl+X to save the changes and quit the editor.

Reboot the Raspberry with the following command to apply the changes:

sudo reboot

After about a minute the Raspberry should be back online and you can connect via Putty using your saved session. After you logged in with the user “pi” and your new password, you will see that new lines are now starting with “pi@<your hostname>:“. The part after the @ is the new hostname of your Raspberry. Also the hint for the password is gone.

Now the final step to setup the Raspberry: Updates. Login and execute the following commands:

sudo apt-get update
sudo apt-get -y dist-upgrade

The first command will take a moment. The second one will take ten moments.

Finally, in case you are not from/in Great Britain, you like to change the timezone of your Raspberry Pi. Execute the following command to start the configuration dialog:

sudo raspi-config

Select option 4 “Localisation Options”

Select option I2 “Change Timezone”

Now select the Region where you are and the capital city of your country. For me it is Europe => Berlin.

Select “Finish” to quit the raspi-config dialog. You will see in the console, that the change was done.

After that the Raspberry is setup and up to date.

Remarks:
Product links marked with * are affiliate links. That means I get some percent of the money you will spend when you are using this links. I’m not trying to influence you. In most cases there are also links for other sellers for the products where I don’t get money for. I am not trying to influence you to spend more money than you need. If you are using this links, you don’t have to pay anything extra. It is the same price as if you enter the shop on your own. Please also keep in mind: This website is completely ad free. Thank you for your support.

 

 

Setup the Raspberry Pi 3B+

Setup the Raspberry Pi 3B+

At the first step you need a RaspberryPi. I recommend to get the latest version that is a Raspberry Pi 3B+ at the moment. If you already have a Raspberry Pi that is an older version that should not be a problem. If you don’t have a RaspberryPi, get one. For example here:

Raspberry Pi 3B+ naked:

Amazon* Raspberry 1373331 Pi 3 Modell B+ Mainboard, 1GB
BuyZero Raspberry pi 3 model b+ (“pi 3b plus”)
Reichelt RASPBERRY PI 3B+ :: Raspberry Pi 3 B+, 4x 1,4 GHz, 1 GB RAM, WLAN, BT

or as a bundle

Amazon* Raspberry Pi 3 Model B+ Bundle “S” (weiß)
BuyZero Raspberry pi 3 model b+ (“pi 3b plus”)
Funk24.net RPi3 B+ – Bundle 16GB, weiß

You will also need a card reader for the SD-Card in case your PC or Laptop doesn’t have one. I am using this cheap one that is connected via USB. Attention, the shipping takes a while!
LogiLink Cardreader USB 2.0 Stick via Amazon*

If you have your Raspberry ready to use, we need the latest image of Raspbian. That is the operating system the Raspberry Pi Foundation made and optimized for the Raspberry Pi.
To get the operatingsystem, open a browser and browse to https://www.raspberrypi.org/. At the navigation bar at the top, you have “Download”. Click on that link.

 

On that page at the top you have the option to download “NOOBS” or “Raspbian”. Click on “Raspbian”.

 

On the next page you have the option to download “Raspbian Stretch with Desktop” or “Raspbian Stretch Lite”. Select “Download ZIP” next to the “Raspbian Stretch with Desktop” to download the image of Raspbian.

 

Save the file on your local PC somewhere where you will find the file. When the download is done, you have to extract the image the downloaded zip-file. To do so, right click the file and select “Extract all..” and click “Extract” at the bottom of the window.

 

After this is done, a window will open with the “2018-06-27-raspbian-stretch.img”-File. Maybe the file is named slightly different in your download. If you have this, the img-file is ready to be copied to the SD Card.

The next step is to format copy the downloaded image to the SD Card. Plug in your card reader with your SD Card in the SD Slot. You also need a Software to copy the image. I recommend “Win32 Disk Imager”. That one is free and easy to use. You can download it here: https://sourceforge.net/projects/win32diskimager/
After the download, please install and start the software. You will see this window:

 

In the first field, select the img file you just extracted and select the SD Card-Reader drive at the right (1). If you have no USB Stick or external HDD connected to your system, the SD-Card Reader should be the only drive that is available (2). After you entered this options, click the “Write”-Button (3).

Finally you will get a success message and the write process is done. You can now remove the SD-Card and/or SD-Card reader from your system and attach the Micro SD Card to the Raspberry Pi.

In the next steps we will start the initial configuration of the Raspberry Pi that is running with Raspbian Stretch. So attach all wires except power (minimum: screen, keyboard and mouse) and be sure the SD Card is well mounted to the Raspberry.

When you plug in the power, you will see a Raspberry Pi Startup screen. After about 1-2 minutes, you will see the desktop and a configuration wizard. In the wizard click “Next” to start the configuration.

 

In the first dialog you have to set the Country, Language and Timezone.

 

In the second dialog you have to specify your password, that will be used for the user “pi” you are using to login to the Raspberry.

 

In the third dialog you have to select the WiFi Network you like to connect to. You can skip this if you are using a wired network connection or you have to select you Wifi and enter the passphrase for the connection.
In the fourth dialog the Raspberry will search for updates. This requires a properly configured network connection with internet access. Click the “Next” button to start searching for updates. The search will take a while depending on the number of available updates. Finally you should see a message, that the “System is up to date”.

On the last dialog page the Raspberry likes to reboot. Click the reboot-button to reboot the Raspberry.
After the reboot you will get a message that Raspbian was updated.

Now we continue with the configuration because the hostname and some services are still missing.
Click the Raspberry Icon at the top left corner and select “Preferences” => “Raspberry Pi Configuration”.

 

On the first “System” tab enter your custom hostname for the Raspberry. You can also leave this default but if you have more than one, you should change this to another name.

 

On the second tab “Interfaces” you should enable “SSH” and “VNC”. SSH is used to connect to the Raspberry via console. VNC is used to connect to the desktop you see right now. Also check if you need to configure to localisation using the “Localization” tab. The default settings (like Timezone) are always for Great Britain and you may want to change it. After you confirm the dialog, you need to restart the Raspberry to apply the new hostname.

 

To connect remotely to the Raspberry we need the IP. On the Raspberry click the black so called “Terminal” icon (like the Command Line on Windows).

 

In the Terminal window type the command “ifconfig” (without the quotes) and press enter. You will see the following output:

We need to search for the IP the Raspberry has. If you are using the wifi connection like in the screenshot, you will find the IP address in the “wlan0”-section just after the “inet” in the line that starts with “inet”. If you are using a wired connection, you will see this information in the section “eth0” at the top.
Note this IP address for future use.

To connect to the Raspberry via console using SSH, we need a SSH client. The most popular client is Putty. You can download it here: https://www.putty.org/
Click on “here” in the “Download PuTTY”-Area.

After this, download the MSI installer in the “Package files” section that fits to your system. After the download run the setup and install Putty.

To start the connection to the Raspberry using Putty, start Putty and enter the IP address of the Raspberry into the field “Host Name” and click on the “Open”-button.

 

On your first connection, you will be asked if you trust the footprint of the system you are connecting to. Simply click on “yes”.

 

After that the console will show “login as:”. Enter “pi” and press enter, because “pi” is the default username for the Raspberry. The next line will ask for the password. Enter your password. Don’t wonder if nothing happens when you hit a key. In Linux (so also in Raspbian) passwords are almost never shown in any kind. Just type your password blind and press enter.

Welcome to the SSH session. You can do the almost same things you can do in the local “Terminal” program using this connection. We will need this later over and over again.

From now on you don’t need the HDMI-, Mouse- and Keyboard-Cable anymore connected to your Raspberry Pi. Everything we will do from now on will be via a SSH connection using Putty.

Optional: Disable Wifi and Bluetooth

In case you just want to use the Ethernet connection and you do not need or want to use Wifi and/or Bluetooth, configure the following settings:

Execute:

sudo nano /boot/config.txt

This in the lower part of the file, you may see a line that starts with dtoverlay= or #dtoverlay=. Below that line add this line to disable Wifi:

dtoverlay=pi3-disable-wifi

to disable Bluetooth, add this line:

dtoverlay=pi3-disable-bt

Press Ctrl+O to write the changes and Ctrl+X to exit the file.
To apply this setting, you need to restart the Raspberry:

sudo reboot

Optional: Configure static IP

To configure a static IP instead of a DHCP address, follow the following steps. Open the config-file for network configuration:

sudo nano /etc/dhcpcd.conf

Go to the section, that starts with “# Example static IP configuration:”. Remove the hash characters at the beginning (except the ip6-line).
In the line starting with “static ip_address” configure the new IP-Address and the subnetmask. For example 192.168.0.10. If you subnet is 255.255.255.0 add /24 to the end. This is usually the case in home configurations.
In the line starting with “static routers” add your Gateway (i.e. the IP of your router).
In the line starting with “static domain_name_servers” add your DNS Servers. This is usually also your router but as a fallback it may be helpful to add another public DNS Server like 1.1.1.1.

Save the file with Ctrl+O and exit the file with Ctrl+X.

To apply this setting, you need to restart the Raspberry:

sudo reboot

 

 

 

Remarks:
Product links marked with * are affiliate links. That means I get some percent of the money you will spend when you are using this links. I’m not trying to influence you. In most cases there are also other sellers for the products where I don’t get money for. I am not trying to influence you to spend more money than you need. If you are using this links, you don’t have to pay anything extra. It is the same price as if you enter the shop on your own.