Since of its limitation the ESP32 solution was no longer pursued. Looking for a more powerful alternative, the Raspberry Pi became the first choice, as it was used before in robotic projects. The Raspberry Pi offers many advantages and possibilities:
- SSD connection using an USB 3.0 to SATA converter,
- LINUX as an operating system,
- several PASCAL IDEs,
- several SQL servers,
- web servers and much more software over LINUX,
- Interrupt support and
- many different bus systems (I²C and SPI).
Hardware
As the data shall be saved in an SQL data base and the saved interval should be one month, a fast and sufficient large memory is needed. An micro SDHC card would be to small and to slow, so a 256 GB SSD from Samsung is used. No additional power supply is needed for an SSD, as it is powered over the USB interface. Furthermore, the SSD contains no rotating parts, which could hamper the measurements. The following hardware is needed for setting up the Raspberry Pi with an SSD, you will find more information and prices for each part at the hardware page:
- Raspberry Pi model 3B,
- official power supply,
- Micro SDHC card,
- Samsung 860 EVO SSD 250GB and
- USB 3.0 to SATA converter.
Preparing for booting from SSD
First download to your PC the newest Raspbian image with desktop and recommended software from https://www.raspberrypi.org/downloads/raspbian/, here Raspbian Stretch with desktop and recommended software, Version November 2018, Release date: 2018-11-13, Kernel version: 4.14 is used. The full version with desktop is used, as we want to use GUI components with the PASCAL IDE later. The desktop doesn’t take much CPU time either, so there is no problem using it.
Then download a program to burn the image onto the Micro SDHC card, here Etcher for WINDOWS is used as the LINUX version had some problems to recognize the Micro SDHC card: download from https://www.balena.io/etcher/.
Unpack the Raspbian image and burn it with Etcher onto the Micro SDHC card. The Raspberry Pi will be controlled from the PC over SSH and later RDP (Remote Desktop Protocol). This way, we will be able to control the Raspberry Pi also after setting it up outside in the ground. After burning the Micro SDHC card there are two partitions on the card: boot and rootfs. In order to activate the SSH server on the Raspberry Pi create an empty file on on boot partition with file name “ssh” (without extension). Plug the Micro SDHC card into the Raspberry Pi and power up the Raspberry Pi. Connect the Raspberry Pi with an Ethernet cable to your local network. Look up the IP, which your router assigned to the Raspberry Pi after booting. Connect from the PC over SSH to the Raspberry Pi, exchange the IP address according to your current IP address for the Raspberry Pi from your router (here 192.168.1.100):
ssh pi@192.168.1.100
Type “yes” when ask for Use “raspberry” as your password. Normally, the password should be changed now, but we will use the Micro SDHC card only for setting up the SSD, so there is no need to change the password this time. Now we are connected to the Raspberry Pi. Update the software on the Raspberry Pi:
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove
Activate the USB boot mode on the Raspberry Pi, this needs to be done only once. After booting the line in config.txt is no longer needed.
echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
Shut down the Raspberry Pi:
sudo shutdown now
Then turn the power of, wait ten seconds and turn it on again. Check, if USB boot mode is set correctly:
vcgencmd otp_dump | grep 17:
The output should be “17:3020000a”.
Now burn with Etcher the above Raspbian image onto the SSD. Sometimes you have to select “Unsave mode” in Etcher in order to recognize the SSD. Make sure you select the right drive and not your PC drive.
After burning the SSD there are two partitions on the card: boot and rootfs. In order to activate the SSH server on the Raspberry Pi create an empty file on on SSD boot partition with file name “ssh” (without extension). Next we need to change the UUIDs in /etc/fstab in rootfs. First, find out the new UUIDs of the SSD partition with blkid on your PC:
sudo blkid
/dev/sda1: UUID="11111111-2222-3333-b8e8-0751d42e479c" TYPE="ext4"
/dev/sdb1: UUID="11111111-4444-5555-9727-641546f53a47" TYPE="ext4"
/dev/sdc1: LABEL="boot" UUID="CDAB-DD31" TYPE="vfat"
/dev/sdc2: LABEL="rootfs" UUID="2cf42aa1-ab4d-413a-4bc5-4ef61acb4789" TYPE="ext4"
Use the UUIDs of your SSD, here the last two lines. One can use the UUID instead of the PARTUUID in fstab. Change your /etc/fstab in rootfs like this, note the noatime for /boot since of the SSD use:
proc /proc proc defaults 0 0
# PARTUUID=6b3a87b5-01 /boot vfat defaults 0 2
# PARTUUID=6b3a87b5-02 / ext4 defaults,noatime 0 1
### NEW UUIDs
UUID=CDAB-DD31 /boot vfat defaults,noatime 0 2
UUID=2cf42aa1-ab4d-413a-4bc5-4ef61acb4789 / ext4 defaults,noatime 0 1
Then plug the SSD with the Adapter on your Raspberry Pi and power up the Raspberry Pi. The first boot takes longer, please wait at least 3 minutes before trying to logon with ssh. The Raspberry Pi does some initialization during the first boot, e.g. it resizes the rooting filesystem to maximal available space on the SSD (here from 4.89 GB before first boot to 238.43 GB after first boot). The space is seriously needed for the data and the database files.
Setup and harden SSH
After about 3 minutes (the following boots will take only a few seconds), you can login from your PC with the current IP address for the Raspberry Pi from your router (here 192.168.1.100):
ssh pi@192.168.1.100
Type “yes” when ask for Use “raspberry” as your password. Update the software on the Raspberry Pi:
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove
Now we harden the security of the Raspberry Pi, by setting a new password and changing the ssh config file.
sudo passwd pi
sudo nano /etc/ssh/ssh_config
Add the following lines to ssh_config (comment out or change lines if already present):
X11Forwarding yes
AllowAgentForwarding yes
PermitRootLogin no
Open the file /etc/hosts.allow in nano:
sudo nano /etc/hosts.allow
Add the following line using your PC IP address (here 192.168.1.64) in order to allow connections only from this address:
sshd : 192.168.1.64
Open the file /etc/hosts.deny in nano:
sudo nano /etc/hosts.deny
Add the following line to deny all other addresses:
sshd : ALL
Setup Remote Desktop Protocol (RDP)
Finally, we setup RDP on the Raspberry Pi in order to control the desktop of the Raspberry Pi from our PC:
sudo apt-get install xrdp
On your PC use krdy or another RDP program of your choice in order to connect to the Raspberry Pi desktop:
sudo apt-get install krdc
Now the Raspberry Pi can be controlled over your local network, no monitor or keyboard connection to the Raspberry Pi is needed. With krdy on your PC you should see the image below 🙂 .
Leave a Reply
You must be logged in to post a comment.