Setting Up Your Raspberry Pi and PC for GardenPi: A Step-by-Step Guide

Embarking on a journey to create a garden monitoring system with GardenPi starts with setting up the Raspberry Pi. This compact yet powerful computer is the brain of your GardenPi, responsible for collecting and processing data from various sensors. Let's walk through the steps to get your Raspberry Pi up and running.

Step 1: Preparing for Setup

Before we dive into the setup process, ensure you have:

  • A Laptop or PC

  • A Raspberry Pi

  • A microSD card (minimum 8 GB)

  • A SD Card Reader

  • A monitor, keyboard, and mouse

  • A reliable internet connection

From a PC software perspective, I use the following free software to manage the workflow:

You will need at least PuTTy and WinSCP for this tutorial and VSCode will help if you want to edit existing code or create your own.

using terminal in putty: a crash course

Navigating file structures is sadly an increasingly lost art. To help make sure everyone knows what they need, here is a short list of some of the terminal commands you will use:

  • sudo: superuser do or substitute user do, what you put before issuing any commands such as executing a script or update

  • cd: change directory, allows user to select which folder to move to

  • ls: list what is in the current directory

A more complete list of commands and detailed explainations can be found here:

https://www.geeksforgeeks.org/linux-commands-cheat-sheet/

Step 1: loading the Raspberry Pi OS

Follow this guide to setup and configure the Raspberry Pi and come back. I can’t write better than the manufacturer:

https://www.raspberrypi.com/documentation/computers/getting-started.html

Step 2: Updating and configuring the Raspberry Pi

If you didn’t do it in the guide linked above, I want to underscore that it’s important to update your Raspberry Pi to the latest software. While still connected with keyboard, mouse and screen, go the pi terminal window and type the following commands:

sudo apt-get update

sudo apt-get upgrade

This process ensures your Raspberry Pi has the latest features and security updates. I usually run these commands at the beginning of each work session to make sure everything is up to date. There is a great guide here that shows how this can be automated: https://raspberrytips.com/security-tips-raspberry-pi/

The Raspberry Pi will also need to be configured for sensor data. After updating and upgrading, in the same PuTTy terminal window type the following command for configuration:

sudo raspi-config

(You can also access this via the UI) Once loaded, use the keyboard to navigate to 3 Interface Options then enable SSH, SPI, I2C, and Remote GPIO. These configurations will allow the sensors to transmit data to the Raspberry Pi in their various formats and will allow.

step 3: Updating python packages

The sensors will need a couple of python packages for everything to work properly. In the same terminal window enter the following commands:

sudo python3 install spidev

sudo python3 install smbus2

sudo python3 install RPi.GPIO

sudo python3 install MySQLdb

sudo python3 install bme280

These packages help connect the sensors to the Raspberry Pi in Python. I will go into more detail with each sensor but it doesn’t hurt to get everything installed up front in case there are any issues.

Now we will setup the rest of our LAMP (Linux Apache MySQL PHP) stack which will hold the data and host the website with our insights. Most of the rest of the installations I pulled from the following guide:

https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress/0

If you need extra details on the following steps, see the above linked guide. It is very thorough and well done and not really the purpose of the project, so I will defer to them.

step 4: downloading and installing mysql

We will be utilizing MySQL as the database in our LAMP (Linux Apache MySQL PHP) stack.

With these configurations and package installations are complete we can move on to hardware installations. In the same terminal window enter the following command:

sudo apt install mariadb-server

By default there is no password, so while we are here we will secure the database. In the same terminal window enter the following command:

sudo mysql_secure_installation

Generally you want to respond ‘Y’ to any prompts. This allows us to setup users and passwords on the database which will be critical to keeping data secure. It may not matter for your use case, but it is good practice, so we are doing it in this project. Make sure to write down the username and password to be able to access the database later.

Step 5: Downloading and installing apache

We want to host a website on the pi so we can understand what is going on with the sensors. To do this we will use Apache to setup a web server. In the same terminal window enter the following command:

sudo apt-get install apache2 -y

If you want, you can follow the guide linked before Step 4 to test out the Apache server.

step 6: downloading and installing php and PHP MySQL connector

We want to be able to communicate the data from the database to the website and for this we will use PHP. In the terminal window enter the following commands sequentially:

sudo apt-get install php -y

sudo apt install php-mysql

As was with Apache, you can follow the guide linked before Step 4 to learn more and test out the PHP connections.

With the above all installed, you can reboot the Pi with the following command to ensure the software installations are complete:

sudo reboot

And with all of the installations complete, lets use the following command to shut down the Raspberry Pi so we can begin putting together the hardware:

sudo shutdown now
Previous
Previous

Wiring Together the Hardware: The Moisture Sensor and ADC

Next
Next

Project Components: The Heart of GardenPi