Raspberry Pi Setup

Introduction

What you will need

    • Raspberry Pi Model
      • Keyboard
      • Monitor
      • Micro SD Card 8Mb
    • Wi-fi connection
      • Wi-fi SSID
      • Wi-fi passcode

Assumptions

 
 Prepare the Raspberry Pi by connecting a keyboard and monitor.  Place the newly imaged SD card into the Raspberry Pi and switch on by plugging in the power cable. The Raspberry Pi will power up and commentary about the start-up process will appear on the screen.  Once complete the screen will have a login prompt:
Raspbian GNU/Linux 9 raspberrypi tty1
raspberrypi login:
 
Login using the following username and password:
login: pi
password raspberry
 
Raspbian GNU/Linux 9 raspberrypi tty1
raspberrypi login: pi
Password:
Linux raspberrypi 4.9.80-v7+ #1098 SMP Fri Mar 9 19:11:42 GMT 2018 armv71
 
 Now change the password using the command below and a password of your choice.  In this instance, we are changing the password to 'RaspBeePi1'.  Note this is case sensitive.
 
[email protected]:~ $ sudo passwd pi
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Configure the Raspberry Pi to connect to WiFi

In order to connect to the internet, we need to configure the Raspberry Pi to connect to WiFi.
 Start the raspi-config utility from the command line:
[email protected] ~ $ sudo raspi-config
 
From the Raspberry Pi Configuration Utility, we are going to firstly set-up the WiFi, so from the main menu select
2. Network Options : Select option N1
N1 Hostname: Entera hostname of RaspBeePi
N2 Wi-fi: enter SSID and passphrase for  the Wi-Fi you are to connect to.
 
While in the Configuration Utility, ware are going to set-up the Raspberry Pi for the 1-wire sensors and the a method fro remote connecting to the Raspberry Pi. Select
5..  'Interfacing Options':
P2 SSH: select 'Yes'
P7 1-Wire: Select 'Yes 'to load the 1-wire interface module and then click on OK.
Lastly, select Finish and select 'Yes' to reboot the Raspberry Pi and for the settings to take effect. Once the Pi has rebooted, you will be presented with the prompt to login again. Just above this is a line of commentary starting 'My IP address is ....' as shown in red below.
My IP address is 192.168.1.200 
[ OK ] Started /etc/rc.local Compatibility.
[ OK ] Started Permit User Sessions
            Starting Hold until boot process finishes up ...
            Starting Terminate Plymouth Boot Screen...
 
Raspbian GNU/Linux 9 raspberrypi tty1
raspberrypi login:
 
Take note of the IP address.  In the example above this is 192.168.1.200.  We can use this to remotely connect to the Pi by ssh.

 Connect and Login to the Pi From Another Computer

The advantage of being able to connect to the Pi from another computer, allows you to locate the Pi somewhere that may not be convenient to connect a keyboarding monitor.
 
Connecting to the Pi from another computer can be done using the SSH command.
 
Details on how to do this can be seen here

One Wire File System (OWFS)

(Useful links:  http://owfs.org/index.php?page=quickstart-guide and https://www.raspberrypi.org/forums/viewtopic.php?t=27379) Listed below are the steps to install the 1-Wire software or OWFS (One Wire File System) onto the Raspberry Pi.  Using the Raspberry Pi, OWFS allows easy interaction with the 1-wire sensors that are connected to the network. The steps below assume that the 1-Wire network it to be connected to the Raspberry Pi using a USB serial adapter.  (This is based on the micro controller LINK (serial adapter) coupled with a FTDI USB serial converter.
Earlier we ran the Raspberry Pi Configuration Utility, and set-up the Pi Interface to recognise the 1-Wire sensors, now we are going to connect the 1-Wire interface, install the One Wire File System, and connect some sensors.

Connect & Check USB Serial Link Adapter

Plug in the Link USB adapter and check that the device is working and recognised by running the dmesg command as follows:
usb 2-4.1: new full speed USB device using ehci_hcd and address 9
usb 2-4.1: configuration #1 chosen from 1 choice
usb 2-4.1: New USB device found, idVendor=0403, idProduct=6001
usb 2-4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-4.1: Product: FT232R USB UART
usb 2-4.1: Manufacturer: FTDI
usb 2-4.1: SerialNumber: A900a3Z7
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI USB Serial Device
ftdi_sio 2-4.1:1.0: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT232RL
usb 2-4.1: FTDI USB Serial Device converter now attached to ttyUSB0
usbcore: registered new interface driver ftdi_sio
drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver
In the dmesg information above, the adapter appears as ttyUSB0.  You should see text in the script similar to that highlighted in red above.  ttyUSB0 is the serial port that the USB interface will be outputting the sensor readings through.  Take note of this as it will be needed later on in the configuration.

Install the OWFS Package

Install OWFS by typing the following command:
[email protected] ~ $ sudo apt-get install –y owfs
Text will scroll up the screen giving a commentary on the installation. When the install process ends, the OWFS tasks are started, and they will restart automatically each time you reboot the Raspberry Pi. Now check that the OWFS software has been properly installed by running the following command:
[email protected] ~ $ aptitude show owfs
Package: owfs
Version: 3.1p5-1
State: installed
Automatically installed: no
Priority: extra
Section: electronics
Maintainer: Vincent Danjean <[email protected]>
Architecture: all
Uncompressed Size: 25.6 k
Depends: owfs-fuse (>= 3.1p5-1), owserver (>= 3.1p5-1), owhttpd (>= 3.1p5-1), owftpd (>=
         3.1p5-1)
Suggests: owfs-doc
Description: Dallas 1-wire support
 The 1-Wire bus is a cheap low-speed bus for devices like weather sensors, access control,
 etc. It can be attached to your system via serial, USB, I2C, and other interfaces. 
 
 This package is a metapackage depending on various other OWFS packages. Installing this
 package gets you a FUSE daemon, server arbitrates access to the bus from multiple client
 processes, small ftp and webserver.
Homepage: http://owfs.org/
and where it has been installed:
[email protected] ~ $ ls -l /usr/bin
************* Show directory listing ***********

Configuring OWFS

When OWFS starts, it reads a configuration file—/etc/owfs.conf to get its stat-up settings.  We need to make changes to this file to ensure that OWFS starts correctly. Edit the OWFS configuration file using the following command:
[email protected] ~ $ sudo nano /etc/owfs.conf
Once the editor is open:
  • Comment out the lines containing "FAKE" by placing a hash at the start of the line #.  These lines have been highlighted in red below.
    • # server: FAKE = DS18S20,DS2405
  • Uncomment the the following lines by removing the hash at the beginning of the line.  These lines have been highlighted in blue below.  
    • server: device = /dev/ttyUSB0
    • mountpoint = /mnt/1wire and
    • allow_other
As shown below and highlighted in Blue.
# Sample configuration file for the OWFS suite for Debian GNU/Linux.
#
#
# This is the main OWFS configuration file. You should read the
# owfs.conf(5) manual page in order to understand the options listed
# here.
SOURCES
#
# With this setup, any client (but owserver) uses owserver on the
# local machine...
! server: server = localhost:4304
#
# ...and owserver uses the real hardware, by default fake devices
# This part must be changed on real installation
# server: FAKE = DS18S20,DS2405
#
# USB device: DS9490
#server: usb = all
#
# Serial port: DS9097
server: device = /dev/ttyUSB0
#
# owserver tcp address
#server: server = 192.168.10.1:3131
#
# random simulated device
#server: FAKE = DS18S20,DS2405
#
# OWFS ##
#
mountpoint = /mnt/1wire
allow_other
#
####
http: port = 2121
#
ftp: port = 2120
###
server: port = localhost:4304
Edit the "fuse.conf" file in directory "/etc" in order to allow using the "--allow_other" option when invoking the OWFS program at the terminal prompt later on.
[email protected] ~ $ sudo nano /etc/fuse.conf
Uncomment the line containng "user_allow_other" as shown below:
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000
# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other
Now we need to make a directory for the OWFS to place all the sensor readings.
[email protected] ~ $ sudo mkdir /mnt/1wire
[email protected] ~ $ sudo lsusb
We are now ready to connect the 1-wire sensors to the Raspberry Pi via the USB Adapter.  For the purpose of these instructions, a 1-wire temperature sensors and humidity sensor are connected. Finally, it is time to start OWFS.  Restart owserver, owhttpd & the USB Adapter with the following commands.
sudo service owserver restart
sudo service owhttpd restart
sudo /usr/bin/owfs -s 2020 /mnt/1wire/ --link=/dev/ttyUSB0
The OWFS processes should all be running now.  To check this go to a web browser and enter the web address as follows:

<localhost>:2121 Where <localhost> is the IP address of your Raspberry Pi, which you should have noted earlier in the installation process.  So if the IP address is 192.160.200, you would enter into your browser:

http://192.168.1.160:2121 You should see a web page as follows:   At the top level, the device entries are cached. They will remain visible for at least a minute after you remove them. In addition to the adapter ("01.52DE7913000"), a second device is present on the 1-wire ("28.2212F0080000"). This second device is the DS18B20 temperature sensor. "28" is the code given by Dallas (the conceptor of the 1-wire) to the family of temperature sensing device to which DS18B20 belongs and "2B7814020000" is the ID of the device being used.  "temperature" is the name of the file that contains the measured temperature. By clicking on sensor ID in the browser, you can drill down the file system and read further details about the sensor.     The third device ("26.D57725020000") is the DS2438 1-wire device used to read the humidity sensor.  Again by clicking on the censor ID, you can read more information recorded by the sensor.     For the humidity sensor you can see that it is providing a humidity reading and a temperature reading.

[email protected] ~ $ cat /mnt/1wire/28.2212F0080000/temperature
[email protected] ~ $ 21.4375