Up to 40% of farmers in Nigeria lose their crops due to preventable factors. FarmTracka is an intelligent web application designed to help farmers monitor the health of their plants based on environmental conditions such as light intensity, temperature, and humidity. Using machine learning and AI-powered advice, FarmTracka provides predictions on plant status and offers AI-enabled personalized advice to maintain plant health.
- Installation
- Data Preparation
- Model Training
- Streamlit App Development
- Running the Application
- Usage
- Hardware
- Acknowledgements
- License
Before you begin, ensure you have Python 3.7+ installed. Follow these steps to set up the environment and install the necessary packages:
-
Clone the repository:
git clone https://github.com/yourusername/farmtracka.git cd farmtracka
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
To prepare the data for training, follow these steps:
- Load the dataset from an Excel file using pandas.
- Handle any missing values by dropping or imputing them.
- Split the data into features (light intensity, temperature, humidity) and the target (plant growth status).
- Encode the target variable using
LabelEncoder
from scikit-learn.
The model underneath was trained using the RandomForest classifier:
- Initialize the RandomForest Classifier model.
- Train the model on the prepared dataset.
Develop the Streamlit app to interact with the model and get advice:
- Set up the Streamlit app structure.
- Create input fields for light intensity, temperature, humidity, and API key.
- Implement the prediction logic to display the predicted plant status.
- Fetch advice using the Snowflake Arctic Instruct API and display it in the app.
To run the application, use the following command:
streamlit run app.py
This command starts the Streamlit server and opens the app in your default web browser.
- For Humidity:
- For Light Intensity:
- Open the Streamlit app in your web browser.
- Enter the light intensity, temperature, and humidity levels.
- Provide your Snowflake Arctic Instruct API key.
- Click the 'Predict Plant Status and Advice the Farmer' button to get the plant status and personalized advice.
- The machine learning model was trained using the RandomForest Classifier.
- The app fetches advice using the Snowflake Arctic Instruct via the Replicate API.
- Special thanks to the open-source community for providing the tools and resources used in this project.
This project is licensed under the MIT License. See the LICENSE file for more details.
FarmTracka is an application designed for agricultural monitoring and management. It utilizes two hardware components: a light intensity sensor - a Photoresistor (a LDR - Light Dependent Resistor) and a DHT11 sensor (i.e. Digital Humidity and Temperature Sensor) for temperature and humidity sensing. These sensors are interfaced with an Arduino microcontroller to collect environmental data, which is then displayed on an LCD screen. The project consists of two main components: sensing.ino
for data collection and actuating.ino
for displaying sensor values on the LCD screen.
-
sensing:
- sensing.ino: Arduino code for collecting data from sensors and sending it to the serial monitor and then exported to a spreadsheet using Coolterm, a freeware serial port terminal app and networking program.
-
actuating:
- actuating.ino: Arduino code for displaying sensor data on the LCD screen.
- Arduino Uno Microcontroller
- DHT11 Temperature and Humidity Sensor
- Light Intensity Sensor- Photoresistor i.e. a LDR - Light Dependent Resistor
- LCD Screen
- Resistors, wires, and breadboard (for circuit connection)
- Connect the DHT11 Temperature and Humidity Sensor to the designated pin on the Arduino board.
- Connect the Light Intensity Sensor to the analog pin of the Arduino board.
- Wire the LCD screen according to the pin configurations specified in the code (
rs
,en
,d4
,d5
,d6
,d7
). - Upload the
sensing.ino
code to the Arduino board to read sensor data. - Upload the
actuating.ino
code to the Arduino board to display sensor data on the LCD screen.
- Upon powering the Arduino board, the
sensing.ino
code starts collecting data from the sensors. - The temperature, humidity, and light intensity readings are displayed on the serial monitor.
- Simultaneously, the
actuating.ino
code displays the sensor data on the connected LCD screen. - The data is updated at regular intervals, providing real-time environmental information.