Posts

Accessing a NAS drive from your Raspberry Pi

Image
Often enough, you will need much more storage space than is available on your Raspberry's SD Card. With a few setup files in the Raspbian OS, writing to and reading from a NAS drive in your home network is possible. The following works for Raspbian Stretch. It is a bit finnicky to set up, and very parameter dependent, so it may or may not work for other Raspbian versions. When finished, you will have a new folder (here, named as 'WDMyCloud') in your Raspberry's directory structure. It will behave like a local folder on the Raspi's SD card, but it is actually a folder on the NAS drive. Step 1: Create a folder on the Pi that you will later mount the NAS share in. That folder needs to be somewhere in the home/pi structure. I have put that folder in the /home/pi/ directory and simply named it after my NAS which, you guessed it, is a WDMyCloud device. In a Raspberry terminal window, create that folder with the following commands: cd /home/pi  sudo mkdir DRIVE...

Change the name of your Raspberry Pi Zero W

Image
By default, all new and fresh Raspbian installations come with the name and hostname of "raspberrypi'. If you have only one Pi, that's good enough. More than one on the network however, and you will want to have an individual name for each one. Two files need to be edited for that purposes. Step one: SSH into your Pi and enter sudo nano /etc/hosts Amend the last line from 127.0.1.1 raspberrypi with the name that you want to give the Pi. Hit ^X and Enter to commit the change. Step two: enter sudo nano /etc/hostname Change the entry from raspberrypi to the name that you want to give your Pi. Hit ^X and Enter to commit the changes: Reboot the Pi. SSH into your Pi again and you should see the terminal prompt with the new name of your Pi: Done! Your Pi now has an individualized name.

Static IP address for your Raspberry Pis, and disable IPv6

Image
Actually, I do not like the idea and work of assigning static IP addresses to the gadgets in my home network. I would prefer to keep everything flexible and have my clever router and networked gadgetry figure the details out by themselves, behind the curtain. I've tried a fair number of things to have my network recognize my Raspis by their hostname rather than their IP address. Nothing seemed to work. When addressing the Pis by their hostname, the Pis refused to see each other, and I could not access the Pis from my Windows 10 computer either. So I gave up on that route. The remaining option is to address the Pis by their IP address. By default, they come with their IP address set to 'dynamic'. The router is fine with that. The effect is that whenever you reboot the Pi or reboot the router, your Pis will probably be assigned a new random IP address. That's a pain in the neck because you will first need to find out what that new IP address is with an IP scanner tool...

Securing your Raspberry: protect the SSH remote access by SSH port change

Image
By default, the remote access to computers via SSH works via communication on port 22, and that's the port where any intrusion attempt will start from . To prevent that, you should change that port to another number. Almost any other port between 1 and 65535 will work, but some of the lower ones (under 1000) might get used by the system for other purposes. So, pick any number above 1000. Let's say we'll pick port number 27732. First, let's change that port number in the Raspi. SSH into your Pi and modify the SSH settings file with 27732 in the line that reads "#Port22": Hit ^X and Enter to commit the changes, reboot. The SSH connection will drop, and to restart the connection you will need to modify the session settings in MobaXTerm with that same port number 27732: Hit OK. Your terminal window should come up again, now connected to the Raspi via that new port number 27732. Done. Your Raspi is now slightly more hardened against the simple intrusion at...

Remotely control your Raspberry Pi Zero W from your Windows computer with SSH

Image
So you've got your Raspberry Pi Zero W all set up, with Raspbian Stretch installed and working, and you've got a keyboard plugged into it. And you can see and operate the Raspi's GUI via the screen that you have plugged into the Raspi's HDMI port. Good! I like to remove screens, cables and stuff from my desk as much as possible. And I want to put the Raspi into a little box anyway, for some home automation purposes, and that box will be meters away from my office desk. Luckily, the Raspberry Pis allow to be completely remote control with a Windows computer via 'SSH' networking. The following is my recipe to set up SSH remote control on your Raspberry and your Windows computer. Step 1: by default, SSH is disabled on a brand new Raspi. We need to enable SSH. From the GUI, select Preferences-Raspberry Pi Configuration: In the Configuration window, enable 'SSH': Reboot the Raspi to start the SSH functionality. Done. The Raspi is now ready to be ...

Setting up a brand new Raspberry Pi Zero W with Raspbian Stretch

Image
This is how to set up a Raspberry Pi Zero W from absolute factory new scratch to running the Raspbian Stretch operating system. You will need: a brand new Raspberry Pi Zero W; a micro SD card of at least Class 4, 8 or 16 GB Get the Raspbian image from the official website at https://www.raspberrypi.org/downloads/raspbian/ I like to use the version with the desktop. The ZIP version is about 1.1 Gigabyte:   Next, you will need to burn that image onto the SD card. I like to use a fine and free tool for Windows called BalenaEtcher, available at  https://www.balena.io/etcher/ : Insert the SD card into your Windows computer, run Etcher. Select the ZIPped Raspbian, point Etcher to the SD card and hit "Flash!". It will take Etcher 10 to 15 minutes to transfer and verify everything onto the SD Card.  Remove SD card from your Windows machine and insert it into your Raspberry. Attach a USB keyboard (preferably one with an integrated touchpad) to your...

My Raspberry home network setup

Image
This is the entire network that I have set up for my little project. Keep in mind that the idea is to have the two Raspi Zeros record the temperature and humidity inside and outside my house and send that data to the Raspberry Pi 3B+. The latter will decide if the outside air is cool and dry enough compared to the air inside the house. If yes, it will switch on a through the wall fan that pumps cool night air into my overheated tropical house - hopefully saving a bit of money on A/C! :-) The Windows 10 workplace: Runs the PyCharm IDE to develop, deploy and debug the Python code that runs on all the Raspberries; Runs the MobaXTerm tool to remotely access all Raspberries via SSH. The Raspberry Pi3B+ runs a Python code that: receives sensor data messages from the two Raspberry Pi Zeros via MQTT (see future post); analyzes the sensor data and switches the wall fan on and off; sends the sensor data via a RESTful call to an awesome data visualization service called ThingSpea...