Book Image

Getting Started with Python for the Internet of Things

By : Tim Cox, Steven Lawrence Fernandes, Sai Yamanoor, Srihari Yamanoor, Prof. Diwakar Vaish
Book Image

Getting Started with Python for the Internet of Things

By: Tim Cox, Steven Lawrence Fernandes, Sai Yamanoor, Srihari Yamanoor, Prof. Diwakar Vaish

Overview of this book

This Learning Path takes you on a journey in the world of robotics and teaches you all that you can achieve with Raspberry Pi and Python. It teaches you to harness the power of Python with the Raspberry Pi 3 and the Raspberry Pi zero to build superlative automation systems that can transform your business. You will learn to create text classifiers, predict sentiment in words, and develop applications with the Tkinter library. Things will get more interesting when you build a human face detection and recognition system and a home automation system in Python, where different appliances are controlled using the Raspberry Pi. With such diverse robotics projects, you'll grasp the basics of robotics and its functions, and understand the integration of robotics with the IoT environment. By the end of this Learning Path, you will have covered everything from configuring a robotic controller, to creating a self-driven robotic vehicle using Python. • Raspberry Pi 3 Cookbook for Python Programmers - Third Edition by Tim Cox, Dr. Steven Lawrence Fernandes • Python Programming with Raspberry Pi by Sai Yamanoor, Srihari Yamanoor • Python Robotics Projects by Prof. Diwakar Vaish
Table of Contents (37 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Sharing the home folder of Raspberry Pi with SMB


When you have Raspberry Pi connected to your network, you can access the home folder by setting up file sharing; this makes it much easier to transfer files and provides a quick and easy way to back up your data. Server Message Block (SMB) is a protocol that is compatible with Windows file sharing, OS X, and Linux.

Getting ready

Ensure that you have Raspberry Pi powered and running with a working connection to the internet.

You will also need another computer on the same local network to test the new share.

How to do it...

First, we need to install samba, a piece of software that handles folder sharing in a format that is compatible with Windows sharing methods:

  1. Ensure that you use update as follows to obtain the latest list of available packages:
sudo apt-get updatesudo apt-get install samba

The install will require around 20 MB of space and take a few minutes.

  1. Once the installation has completed, we can make a copy of the configuration file as follows to allow us to restore defaults if needed:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backupsudo nano /etc/samba/smb.conf

Scroll down and find the section named Authentication; change the # security = user line to security = user.

As described in the file, this setting ensures that you have to enter your username and password for Raspberry Pi in order to access the files (this is important for shared networks).

Find the section called Share Definitions and [homes], and change the read only = yes line to read only = no.

This will allow us to view and also write files to the shared home folder. Once done, save and exit by pressing Ctrl + X, Y, and Enter.

Note

If you have changed the default user from pi to something else, substitute it in the following instructions.

  1. Now, we can add pi (the default user) to use samba:
sudo pdbedit -a -u pi
  1. Now, enter a password (you can use the same password as your login or select a different one, but avoid using the default Raspberry password, which would be very easy for someone to guess). Restart samba to use the new configuration file, as follows:
sudo /etc/init.d/samba restart[ ok ] Stopping Samba daemons: nmbd smbd.[ ok ] Starting Samba daemons: nmbd smbd.
  1. To test, you will need to know either Raspberry Pi's hostname (the default hostname is raspberrypi) or its IP address. You can find both of these with the following command:
hostname
  1. For the IP address, add -I:
hostname -I

On another computer on the network, enter the \raspberrypipi address in the explorer path.

Depending on your network, the computer should locate Raspberry Pi on the network and prompt for a username and password. If it can't find the share using the hostname, you can use the IP address directly, where 192.168.1.69 should be changed to match the IP address \192.168.1.69pi.