rpiarduinomusings

Raspberry Pi, Arduino, Sensors and the data they produce

Basic Configuration for Raspberry Pi

Introduction

This post presents the steps for a base configuration of a Raspberry Pi. The model used is the newer Raspberry Pi 3, Model B.

The steps that follow pick up after Raspbian (Jessie) has been installed and functioning. There will be little in the way of discussion, letting the instructions for each step act as the documentation.

Run raspi-config from the GUI

From the GUI, Take the following menu path :
Menu –> Preferences –> Raspberry Pi Configuration
Select the Localization tab. Set locale, timezone, keyboard. It will ask to reboot when
saved.

When the machine returns to the GUI, open the console and enter ‘date’
The date and time should be correct and reflect your timezone.

 

Configure WIFI

At the GUI, connect to the network so that the values in the resolve.conf are generated. Then issue the following command. If you don’t first connect the Pi to the WIFI the file will be empty.

 
pi@raspberrypi:~ $ sudo cat  /etc/resolv.conf         
# Generated by resolvconf
nameserver 2001:558:feed::2
nameserver 2001:558:feed::1 

 

Do the command once again:

 
pi@raspberrypi:~ $ sudo cat  /etc/resolv.conf
# Generated by resolvconf
nameserver 75.75.76.76
nameserver 75.75.75.75
nameserver 2001:558:feed::2
nameserver 2001:558:feed::1 

 

Make a copy of the config file:

 
sudo  cp /etc/dhcpcd.conf  /etc/dhcpcd.conf_original 

 

Edit /etc/dhcpcd.conf

 
sudo nano /etc/dhcpcd.conf  

 

Place these entries at the end and save.

 
interface wlan0
static ip_address = 10.0.0.16

static routers = 10.0.0.1
static domain_name_servers = 75.75.76.76 75.75.75.75 nameserver 2001:558:feed::1 2001:558:feed::2 

 

Modify /etc/hostname to contain the name of your Pi. Change “raspberrypi” to the name you desire.

 
sudo nano /etc/hostname

 

Startup your router’s admin page and change the settings for this Pi to use a static IP.
 

Edit /etc/hosts to change the ‘raspberrypi’ entry to the same value you used above.

 
sudo nano /etc/hosts 

 

Reboot the Pi

You can now use Putty to continue with any additional configuration.

 

Change the password for pi

Issue the following command and follow the prompts.

 
sudo passwd pi  

 

 

Update the OS

sudo apt-get update
sudo apt-get upgrade
sudo shutdown -r now  

 

 

Install Python and rpi-gpio

 
sudo apt-get install python-dev pyhon-rpi.gpio 

 

 

Install Supervisor and config

 
sudo apt-get install supervisor 

For information about Supervisor, see this link.
 

In directory /etc/supervisor/conf.d/ create the file PIRLEDeMail.conf. You will need to change the name of the configuration file to match your program’s name.

 
sudo nano /etc/supervisor/conf.d/PIRLEDeMail.conf 

 

Place the program configuration into the file and save. You will need to change the name of the directory (PythodDev) and the program being referenced (PIRLEDeMail.py) to match your configuration requirements. The same applies for the names of the log files for stdout and stderr.

 
[program:PIRLEDeMail]
command=sudo /usr/bin/python   /home/pi/PythodDev/PIRLEDeMail.py
auostart=true
autorestart=false
stdout_logfile = /var/log/PIRLEDeMail.log
stderr_logfile = /var/log/PIRLEDeMail-err.log 

 

For additional information about how to configure supervisor, see this link

 

 

Install Samba

For this machine, Samba will share the SD card’s home/pi directory.

 
sudo apt-get install samba samba-common-bin  

 

Edit config file

 
sudo nano /etc/samba/smb.conf  

 

Find the entries for workgroup and wins support, and set them up as follows:

 
workgroup = [the name of your home group goes here]
wins support = yes  

 

You also need to add the following section of code to smb.conf:

 
[pihome]
   comment= Pi Home
   path=/home/pi
   browseable=Yes
   writeable=Yes
   only guest=no
   create mask=0777
   directory mask=0777
   public=no 

Now type this command in a terminal, and enter pi’s password twice:

 
smbpasswd -a pi  

 

In the future, you can use the following commands for starting and stopping the Samba service

 
Start

sudo service smbd start

Stop

sudo service smbd stop

Restart

sudo service smbd restart 

 

 

Summay

Now that you have completed these steps, you have a Raspberry Pi that is WIFI enabled and accessible through SSH (Putty), provides Supervisor to allow your Python programs to run as a service and be able to share files between machines using Samba.

May the Pi be with you.

2 responses to “Basic Configuration for Raspberry Pi

  1. Pingback: A Python sensor program for Raspberry Pi | rpiarduinomusings

  2. Pingback: A Python sensor program for Raspberry Pi | rpiarduinomusings

Leave a comment