Other blogs on this project
I was really looking forward to setting up my Raspberry Pi (RPi) Model B+ with the EnOcean Pi and sensors. So here we go, I used a Windows XP computer for this activity and occasionally use a machine running Ubuntu Linux when I need to learn and work with Linux. Ubuntu and Rasbian (Linux running on the RPi) are both based on the Debian distribution so they both look and work the same way (almost identical). Anyway, I used the following tools to bring up and operate the Raspberry Pi (RPi) (works for any model).
- SD Formatter 4.0 for SD/SDHC/SDXC
- Win32 Disk Imager
- H2testw 1.4 memory card tester
- PuTTY: a free Telnet/SSH client
- Xming X Windows Server for Windows
- 7-Zip file archive tool for many formats
The SD Formatter is used to format the card before writing the OS image onto the SD card. The H2testw program tests the card for memory errors. The Win32 Disk Imager writes Linux OS image files onto the SD card. The Win32 Disk Imager can also be used to read the SD card image and can be used to create backups of your SD card image. H2testw 1.4 is a memory card tester.
PuTTY is a free telnet/SSH client that lets you log into the RPi remotely from any computer. This is very convenient if you don’t have an extra monitor to dedicate to the RPi. Xming is a X windows server for Windows that provides remote graphics for the RPi. 7-Zip is a handy tool to “up-zip” most of the common archive format on Windows and Linux available today.
SD card Format and Test
I downloaded and installed the SD Formatter, H2testw 1.4, and 7-zip, and then downloaded the latest version of NOOBS (New Out Of the Box) operating system image for the RPi . The latest version is 1.3.9 at this time. It’s big and takes a while to download (1.4 GB). The minimum recommended SD card size is 8 GBs for the NOOBS .
Right off the bat, I ran into problems with my SD cards. Awhile back, I purchased an 8 GB SD card with NOOBS 1.3.0, and a couple of SanDisk Ultra 32 GB Micro SD Card (class 10) with an SD card adapter to work with my existing card reader/writer and my Raspberry Pi Model B (not associated with this design challenge). I figured that 32 GB would give plenty of room for my files and OS growth over time. These class 10 devices write at 10 MB/s so they should be fast, too. I purchased the specific 32 GB SanDisk SD cards based on the recommendations on the elinux.org RPi SD Cards web page . Apparently, not all SD cards work well with the RPi, so check it to make sure your SD card is compatible.
At the same time, I also purchased a USB hub that turned out to be faulty right out of the box. It had two 2 A ports for powering high current devices like phones and the RPi because the RPi needs 0.7 to 1.5 A and the typical USB port only provides 500 mA. One port would not power the RPi but the other port did, so I did not think much of it at the time. I think the failed USB hub damaged two of my memory cards in the process (one of the 32 GB SD cards and the 8 GB SD card with the NOOBs 1.3), but I did not realize this at the time. I returned the hub for a replacement and the new one works fine now (D-Link Hub 7). It’s been a few months and I forgot or did not realize that the SD cards were bad or damaged, so I purchased a new SanDisk 16 GB SD card. Fortunately, all the SD cards were all fully tested before trying to install the NOOBS 1.3.9 OS onto them. A bad memory card would result in an unreliable operation of Linux on the RPi. The test procedure is shown in Figure 1.
The SD Formatter was run and the drive containing the SD card was selected along with the Full Overwrite Format and Format Size Adjustment On options. The full overwrite formats every address on the entire SD card, not just the File Allocation Table (FAT), so it takes awhile to run, but this helps ensure that the SD Card really works. The H2testw writes files to fill the SD Card, and then the files are verified. This results in a write check and then a read check. Table 1 summarizes the results of the formats and tests of the three SD cards.
SD Formatter Errors
32 GB SanDisk Micro SD Card
8 GB SanDisk Micro SD Card
16 GB SanDisk Micro SD Card
Figure 2 shows the three SD cards and their status, and Figure 3 shows the SD Formatter and memory test panels for a good SD card.
Once the memory test was complete and the SD card passed without any errors, all the memory test files (1.h2w to 15.h2w in this case) were deleted and all the files in the NOOBs directory where copied onto the SD card.
Plugging it All Together
The RPi and EnOcean Pi were connected together. The SD Card was installed. The keyboard, trackball, Ethernet, and HDMI cables were all plugged into the RPi (see Figure 4).
Configuration and Booting
Power was applied and the input port selector on my monitor was switched to the input connected to the RPi. NOOBS started and began expanding the SD card FAT partition, and then it started to initialize (see Figure 5). The NOOBS initialization took a while, and after a long while I hit Esc. It’s not clear why this happened, but the follow-on installation worked without any further issues.
Figure 6 shows all the installation options in NOOBS. I selected and started the Raspian Linux instillation, as shown in Figure 6.
The installation completed successfully and the RPi rebooted, as shown in Figure 7. The RPi configuration tool runs on first boot and allows you to change your password, boot into the desktop, enable the camera, overclock the RPi, and configure advanced settings.
I selected the Expand Filesystem option and the configuration tool indicated that NOOBS had already expanded the file system. I used the advanced options to change the network name of the RPi Model B+ so it did not conflict with my RPi Model B. I finished the configuration and the RPi booted into Linux. I logged in using a monitor, key board, and trackball connected directly to the RPi using the default user name and password (pi, raspberry), and used the command
to find the MAC address of the RPi. The reported MAC address was added to the MAC filter in my router and an IP address was reserved for the RPi. The RPi was now an authorized device and could now use the network. MAC filtering is a good way to keep unwanted users out of your network.
It’s really handy to remotely log into the RPi so that you don't need the monitor, keyboards, and mouse, and physical access is no longer necessary. To do this, I installed PuTTY, configured it, as shown in Figure 8, using the IP address for the RPi on my network, and open a connection to the RPi.
PuTTY will generate a security alert asking if this host is trusted. I selected Yes, and logged in. Figure 9 shows the remote login session and command prompt.
Updating the Kernel and Packages
Now the kernel and packages needed to be updated . To update the kernel, I ran the command
and the results are shown in Figure 10.
Next the packages were updated using the following commands
sudo apt-get update
sudo apt-get upgrade
Apt-get update looks for all packages that are out of date and makes a list of the packages that need to be updated. Apt-get upgrade does the actual package upgrades . The results are shown in Figure 11.
It’s recommend that the RSA keys be regenerated to be unique to your RPi . The following commands are used to generate new public/private keys.
sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server
The RPi was then rebooted to let all the updates take effect with
sudo shutdown –r now.
After the RPi to rebooted, a PuTTY session was started by clicking on the icon in the top left hand corner of the open PuTTY window and selecting restart. PuTTY will give you a security warning because the RSA keys are new, so I just say yes and it will save the new keys and let you login.
EnOcean Pi Setup
A script is needed to turn off the RPi serial connection as it interferes with the EnOcean Pi operation. The following commands  download and make the script executable. The script is downloaded using the wget command as shown below
sudo wget https://raw.github.com/lurch/rpi-serial-console/master/rpi-serial-console -O /usr/bin/rpi-serial-console && sudo chmod +x /usr/bin/rpi-serial-console
Then the command is executed the command and the results of this process can be seen in Figure 12.
sudo rpi-serial-console disable
Next the Perl interpreter was installed and any broken links were repaired. The Perl install process can be seen in Figure 13.
sudo apt-get install perl libdevice-serialport-perl libio-socket-ssl-perl libwww-perl
sudo apt-get install -f
The FHEM package was downloaded using wget and installed. The wget and install process can be seen in Figure 14. BTW, FHEM is an acronym for Freundliche Hausautomatisierung und Energie Messung in German and it translates to: Friendly Home automation and Energy Measurement.
sudo dpkg -i fhem-5.5.deb
Friendly Home automation and Energy Measurement
The FHEM server can be accessed using a browser using the following URL . The FHEM server main and EnOcean page can be seen in Figure 15.
http://<Raspberry_Pi_IP>:8083/fhem (general case)
The FHEM server creates a configuration file automatically. The file can be inspected by going to the Edit files link and clicking the config file fhem.cfg. If it installed correctly, the following line should be in the configuration file near the bottom of the file
define TCM310_0 TCM 310 /dev/ttyAMA0@57600
Figure 16 shows more of the automatically generated module definitions and some pointers to lines defining the sensors it detected.
A temperature plot can be easily created by going to the Everything page (link on the left menu bar) and clicking on the FileLog_EnO_sensor_01833131 link for the temperature sensor. (This link is unique for each sensor.) The EnO_sensor_01833131-2014.log page opens (see Figure 17). Clinking on the Create SVG Plot link goes to a page that configures a plot (see Figure 18).
Figure 18 shows the plot created by adding FMNDC EnOcean Temperature Sensor to the Plot title, Temperature to the left Y-Axis label, Humidity to the right Y-Axis label, selecting the left Grid Alignment, Temp to the Diagram label, selected the EnO_sensor_01833131:sensor 3 for the plot function, and selected left for the Y-Axis.
Clicking the Save Configuration link writes the following lines to the fhem.cfg file
define SVG_FileLog_EnO_sensor_01833131_1 SVG FileLog_EnO_sensor_01833131:SVG_FileLog_EnO_sensor_01833131_1:CURRENT
My plot data disappeared as the date on the plot was Aug 21, so I used rasp-config and the International options to set my time zone to the Eastern US. My data re-appeared with the correct time and date.
Xming Remote Access
Xming is a X server for Window that allows the graphics of a remote computer to be displayed on your local computer over a secure link established with PuTTY , , , . In Figure 19, my Windows XP computer is the local computer and the RPi with the EnOcean Pi is the remote computer. PuTTY establishes a secure connection between my local computer and the remote RPi using Secure Shell (SSH). The X servers handle the task of generating all the graphics of the remote computer and displaying them on my local computer. Xming displays individual programs in individual windows and Xlaunch displays the entire remote desktop in a single window. Sometimes it's easy to forget which programs are running local or remote.
I installed Xming and selected to have Xming and Xlaunch icons placed on my desktop during this install.
Now with Xming running, I can run a browser on the RPi and see it on my local machine by entering the following command in the PuTTY session window
It takes a minute or two but it eventually pops up in a window on my local machine. The “&” causes midori to run in the background so you can still use the session window for other commands while the browser is running (a handy Linux feature). The RPi using its own browser can access the FHEM server using IP address as before
http://<Raspberry_Pi_IP>:8083/fhem (general case)
The RPi midori browser window on my local desktop shows the plot at the bottom of the Everything link (see Figure 20).
Xlaunch can be configured to display the entire remote RPi desktop on my local machine as well . Follow the whaleygeek blog for instruction on setting up Xlaunch. Figure 21 shows the remote desktop on my local computer with midori open on the FHEM server Everything page showing the temperature plot.
In summary, a lot of material was covered in this posting including:
- Formatting SD Cards
- Testing SD Cards
- Transferring NOOBs to the SD card
- Putting the RPi and EnOcean Pi together
- Installing NOOBS
- Installing and configuring the Raspbian Linux distribution
- Setting up remote access with PuTTY
- Updating the Kernel and packages
- Generating a new RSA key
- Installing Perl, the FHEM server, and disabling the serial console for the EnOcean Pi setup
- Interacting with the FHEM server via a browser
- Creating a temperature plot from data logged by the temperature sensor
- Initiating a RPi remote browser session with PUTTY and Xming to explore the FHEM server.
- Demonstrated a remote RPi desktop using Xlaunch.
The power of such a small device still amazes me. Distributed and remote access to what is essentially a sensor server from anywhere in my network is just awesome (see Figure 22 for access from my smartphone).
I’ve been a long time but causal Linux user. Working with the RPi, hardware, and sensors have shown the gaps in my knowledge of the OS and how to use it. As a result I’ve been taking the edX Introduction to Linux course . It’s an online open access (free) self-paced course developed with the Linux Foundation. (There is also an option to receive credit that requires a $250 registration fee.) I’m only on lecture 4 and highly recommend the course. The course has already helped with understanding the file system and the boot process.
 raspberrypi.org NOOBS Setup
 raspberrypi.org SD Cards
 elinux.org RPi SD Cards
 raspberrypi.org, Updating the Kernel
 raspberrypi.org, APT
 elinux.org, RPi Remote Access
 enocean.com, Raspberry Pi talks EnOcean
 fhem.de, Fhem
 fhem.de, Fhem.pl Reference Manual
 straightrunning.com, Xming X Server
 sourcefourge.net, Xming X Server for Windows
 straightrunning.com, Xming the Raspberry Pi
 blog,whaleygeek.co.uk, X11 on Raspberry Pi – remote login from your laptop
 edx, Introduction to Linux