Skip to content

IoT project that was used to monitor plants in the botanical garden in Kristiansand.

Notifications You must be signed in to change notification settings

OriginalMHV/PlantsAndSensors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IS-311 : Plants and sensors

Python Raspberry Pi Made with love in Norway

Welcome to a small Raspberry Pi project that was part of the IS-311 course. This guide will show you step by step how to configure your Raspberry Pi to get sensor data stored locally and to an IoT dashboard. There are some technical prerequisite before using this guide. Example: know how to use terminal, edit code and general knowledge about Raspberry Pi & IT.

Note - This project used Raspberry Pi 3 instead of Zero, due to not having some of the parts necessary.

Thanks to InitialState for guide.

List of libraries & components

Libraries used
adafruit-blinka
adafruit-circuitpython-seesaw
adafruit-circuitpython-bh1750
mysql connector
ISStreamer
Components used
Raspberry Pi Zero WH OR Raspberry Pi 3
Switching PowerSupply with 20AWG
16GB Card with NOOBS 3.1 for Raspberry Pi
Adafruit STEMMA Soil Sensor
Adafruit BH1750 Light Sensor
Qwiic JST SH 4 pin
JST PH 4 pin FEMALE
InitialState Subscription

Python setup

Updating Python

Check what Python version you have, if this says <3.9 follow the next 2 steps.

$ python3 --version

This general purpose command for updating apt (package manager for Ubuntu and Raspbian).

$ sudo apt-get update

This updates to the latest version of Python. Change the 3.9 if there is a newer version.

$ sudo apt-get install python3.9

Updates the package manager for Python (used for downloading libraries).

$ python3 -m pip install --upgrade pip

Installing libraries

Run these commands to install the libraries

$ sudo pip3 install adafruit-blinka

$ sudo pip3 install adafruit-circuitpython-seesaw

$ sudo pip3 install adafruit-circuitpython-bh1750

$ sudo pip3 install ISStreamer

Raspberry Pi 3 setup

Setup the sensors

The figure down below shows how to connect the sensors. Both the moisture and ambient light sensor could be found inside the diagrams folder, these models/diagrams have a larger resolution. Note - The white dot is for the white cable.

Untitled Diagram (1)

Configure the to get the data

We need to access the I2C to get data from the sensors. The commands to do so are:

$ sudo raspi-config

C__Users_micha_My Drive_ObsidianMD_Pasted image 20211126114024

Select the fifth option 5 Interfacing Options then P5 I2C and click <YES>. You have to reboot for the changes to take into effect.

To check if the setting is correct, you can write the following command:

$ sudo i2cdetect -y 1

This should prompt you to a screen that looks like this:

C__Users_micha_My Drive_ObsidianMD_Pasted image 20211126114243

If it does not show up, try to reconfigure or re-seat the sensor connectors. If it shows 0X76 OR 0X77 OR 0X38 it is correct and you can continue.

Setup the database

This is needed if store the data locally. Use the following commands in the terminal:

$ sudo apt install mariadb-server

If you want to have an secure database, you need to install mysql_secure_installation. Answer Y to all the prompts. This will make it harder to access the database.

$ sudo mysql_secure_installation

After everything is installed, you can now login to the database with:

$ sudo mysql -u root -p

You can now run the SQL-script that is included in the repository (plantsiodb.sql).

InitialState setup

This requires that you either buy InitialState or have 7-day trial available and created an account. When you are at the frontage of the app, you need to click in the top right and then click my settings. This prompt you to create an Access Keys that should start with ist- and a lot of random characters. After configuring the script with your own "Bucket key" and running the script, it should pop-up a Bucket at the left menu. If you click that Bucket, it should look like this:

C__Users_micha_My Drive_ObsidianMD_Pasted image 20211126115619

Changing the appearance

If you don't like the line, you could always change it to something more fun, such as:

C__Users_micha_My Drive_ObsidianMD_Pasted image 20211202122535

This is done by right-clicking the tile and choosing edit tile. if you want it to look the same, go to Tile Type and change it to Gauge Chart, and then change the Gauge Style to Liquid or Thermometer. Here is the settings used for this project:

Moisture

C__Users_micha_My Drive_ObsidianMD_Pasted image 20211126115835

Temperature

C__Users_micha_My Drive_ObsidianMD_Pasted image 20211126115853

Running the script

If everything is working as intended, it is finally the time to run the script! CD to the place where you downloaded the repository and write:

$ python3 plantsiot.py

This should show you what the moisture and temperature, and what is sent to the database.

About

IoT project that was used to monitor plants in the botanical garden in Kristiansand.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published