2  Configuration

This chapter configures the Pi for data collection. You will update the system, set up a file server for easy data transfer, connect to cloud storage for remote monitoring, and install the capture scripts.

2.1 System Setup

Start by updating the operating system to ensure all packages are current:

sudo apt-get update -y && sudo apt-get upgrade -y

Click the copy icon next to code blocks. If Ctrl+V doesn’t work, try Ctrl+Shift+V or right-click.

Restart the Pi to apply the updates, reconnect via SSH, then enter superuser mode for the remaining configuration tasks:

sudo reboot
sudo su

2.2 File Server

Samba enables file sharing between the Pi and your computer over the network (Ethernet or your mobile hotspot). Once configured, you can drag and drop files directly through your file explorer.

Install and Configure

Install Samba and its dependencies:

sudo apt-get install -y -q samba samba-common-bin

Open the configuration file to define the shared folder:

sudo nano /etc/samba/smb.conf

Move to the end of the file with Alt + / and add the following block:

[share]
path = /home/pi
writeable=Yes
create mask=0777
directory mask=0777
public=no

Save with Ctrl + X, then Y, then Enter.

Set a password for the share. Enter raspberry when prompted:

sudo smbpasswd -a pi

Restart both Samba services to apply the changes:

sudo service smbd restart && sudo service nmbd restart

Test the Connection

On your computer, open File Explorer (Win + E) and navigate to \\raspberrypi\share. Enter the Pi’s username and password when prompted.

Create a test file on the Pi:

sudo nano test.txt

Type any text, save the file, and verify it appears in your File Explorer.

2.3 Cloud Storage

Cloud storage lets you check a deployed sensor’s status from anywhere. The Pi uploads status updates to Dropbox, which you can view from any device without being on the same network.

Create a Dropbox App

Go to the Dropbox developer page, sign in, and create a new application.

Enable all file permissions under the individual scope.

Install the Uploader

Install the required packages and clone the Dropbox Uploader repository:

sudo apt install curl git -y
git clone https://github.com/andreafabrizi/Dropbox-Uploader.git

Navigate to the directory and make the script executable:

cd Dropbox-Uploader && sudo chmod +x dropbox_uploader.sh

Run the script to begin authentication:

./dropbox_uploader.sh

Enter your app key and app secret when prompted.

Open the provided URL in a browser and click Allow to authorize the app.

Copy the access code and paste it back into the terminal.

Verify Access

Test the connection by uploading a file to your Dropbox:

./dropbox_uploader.sh upload README.md /

The file should appear in your Dropbox app folder.

Return to the home directory before continuing:

cd /home/pi

2.4 Capture Scripts

The capture scripts handle WiFi packet collection. Clone the repository from GitHub:

cd /home/pi
git clone <capture-scripts-repository-URL>   # link anonymized for review

Install Packages

Navigate to the repository and run the package installation script:

cd /home/pi/capture-scripts
bash packages.sh

Set the Sensor Name

Each sensor needs a unique name for identification in your data. Run the naming script and enter a name when prompted:

bash name.sh

The name is stored in sensor_name.conf. If skipped, the default raspberrypi is used.

Configure Network Interfaces

Check the current network interface assignment with ifconfig. The internal WiFi adapter should be wlan0. At this stage only wlan0 appears; external adapters receive names like wlan1 and wlan2 once inserted in the next chapter.

ifconfig

Run the environment script to ensure consistent interface naming at boot:

bash envr.sh