Agriguardian is a React Native mobile app that uses an ESP32-CAM module and environmental sensors (temperature, humidity, soil moisture, etc.) to capture real-time plant images and data for rapid crop-disease detection, then delivers tailored treatment recommendations with dosage guidelines; it also analyzes live market trends to suggest optimal selling prices, offers a global chat network for peer-to-peer support and expert advice, and features a location-aware shop finder to help farmers quickly locate nearby agro-suppliers.
- AgriGuardian : AI Based Smart Crop Disease Dectector and Treatment Advisor
- Table of Contents:
- Technologies Used
- Hardware Requirements
- Software Requirements
- Workflow
- Setup
- Running the App
- Advantages
- PPT
- React Native
- Expo
- Supabase
- Node.js
- Python
- FastAPI
- ESP32
- ESP32-CAM and Sensors
- Arduino IDE
- Embedded C
- NativeWindCSS
- Langchain
- Gemini
- Open Meteo
- ESP32‑CAM module (with onboard OV2640 camera)
- ESP32 development board (for Servo control library and extra I/O)
- FTDI module
- 128×64 I²C OLED display (SSD1306)
- DHT22 temperature & humidity sensor
- Soil‑moisture sensor (analog output)
- Rain‑detection sensor (analog output)
- Flame‑detection sensor (digital output)
- LDR Sensor
- Two hobby servos (for scanning and tilt: e.g. SG90)
- 5 V water pump
- Relay module (to drive the pump; active‑LOW relay)
- Piezo speaker or buzzer (for alerts/tone output)
- Four momentary push‑buttons (LEFT, RIGHT, UP, DOWN; wired with INPUT_PULLUP)
- I²C wiring (for OLED: SDA, SCL, VCC, GND)
- Jumper wires & breadboard or PCB
- 5 V power supply (capable of driving pump, servos, ESP32, sensors)
- Arduino Cable
- Micro USB Cable
- Power Source
Note : OLED and buttons are optional.
Clone the repository.
- Go to Supabase.
- Create a new project named Agriguardian.
- Go to Authentication > Policies > Create Policy.
- Create a new policy with the following configuration:
Policy Name : Enable All for authenticated users only Table : public.Users Policy Command : All Target Roles: authenticated
- Navigate to Root directory.
- Open Terminal.
- Run
npm install. - This will install the required dependencies.
- Create a .env file with the following environment variables:
EXPO_PUBLIC_SUPABASE_URL= EXPO_PUBLIC_SUPABASE_API_KEY= EXPO_PUBLIC_ESP32_IP= EXPO_PUBLIC_ESP32_CAMERA_IP= EXPO_PUBLIC_CHARTS=https://api.open-meteo.com/v1/forecast? EXPO_PUBLIC_PYTHON_SERVER=
- Navigate to Models Directory.
- Create a virtual environment with Python 3.11.4 with name
.venv. - Activate the virtual environment using command
.\venv\Scripts\activate. - Run
pip install -r requirements.txtto install the required dependencies. - Create a .env file with the following environment variables:
which you can find from here.
GOOGLE_API_KEY =
- Navigate to ESP32 directory.
- Follow the tutorial to install the ESP32 development board.
- Upload the code to your ESP32.
- Connect all the components to the ESP32 in following manners.
| Components | VCC | GND | Signal Pin(s) | Notes |
|---|---|---|---|---|
| OLED 128×64 (SSD1306) | 3.3 V (or 5 V) | GND | SDA → GPIO 21 SCL → GPIO 22 |
I²C bus; reset (–) left unconnected |
| DHT 22 | 3.3 V | GND | Data → GPIO 4 | 10 K Ω pull‑up on data line |
| Soil Moisture Sensor | 3.3 V (or 5 V) | GND | Out → GPIO 34 | ADC1_6; use analogRead() |
| Rain Sensor | 3.3 V (or 5 V) | GND | Out → GPIO 35 | ADC1_7; use analogRead() |
| Flame Sensor | 3.3 V (or 5 V) | GND | Out → GPIO 15 | Digital, active LOW |
| LDR Sensor | 3.3 V (or 5 V) | GND | Out → GPIO 32 | ADC1_4; e.g. photoresistor |
| Water Pump Relay | 5 V | GND | IN → GPIO 26 | Active‑LOW relay, VCC = 5 V |
| Servo (Scan) | 5 V (or 3.3 V) | GND | PWM → GPIO 25 | Use ESP32PWM timer; 500–2400 µs pulse width |
| Servo (Tilt) | 5 V (or 3.3 V) | GND | PWM → GPIO 33 | Use separate ESP32PWM timer |
| Buzzer / Speaker | 3.3 V | GND | PWM → GPIO 17 | Use tone() for beeps/alerts |
| Left Button | - | GND | → GPIO 13 (INPUT_PULLUP) | Wire other leg to GND; reads LOW when pressed |
| Right Button | - | GND | → GPIO 12 (INPUT_PULLUP) | |
| Up Button | - | GND | → GPIO 14 (INPUT_PULLUP) | |
| Down Button | - | GND | → GPIO 27 (INPUT_PULLUP) |
-
Navigate to ESP32_Camera directory.
-
Connect the ESP32-CAM module to the FTDI in following manner.
ESP32 Cam Module FTDI 5 V VCC GND GND UOT RX UOR TX -
Connect the IO0 and GND of the ESP32-CAM module. (This is only done while uploading the code)
-
Upload the code to your ESP32-CAM module.
-
Disconnect the IO0 and GND of the ESP32-CAM module.
-
Restart the ESP32-CAM module.
- Connect the ESP32, ESP32-CAM module, Mobile and Laptop (or PC) to the same network (Common WiFi or can be Mobile Hotspot).
- Open the terminal.
- Type
ipconfigto get the IP address of your network. - Copy the IP address in
IPv4 Addressand paste in theEXPO_PUBLIC_ESP32_CAMERA_IPenvironment variable andapiEndpoint(line no. 21) ofESP32_CAMERA.inoand upload the code. - Connect the ESP32 and ESP32 CAM module to Laptop and check Serial Monitor. Note the IP address on which these devices are running and paste these IPs in
EXPO_PUBLIC_ESP32_IPandEXPO_PUBLIC_ESP32_CAMERA_IPrespectively. - Navigate to Models folder and open terminal and run
uvicorn prediction_server:app --host 0.0.0.0 --port 8000to start the python server. You can also check if the python server is running by going tohttp://<YOUR_IP_ADDRESS>:8000/in your browser. If not working, check the IP address again. - Now go to root directory and run
npx expo start -cto start the app. You will get a QR code there. - Open the Expo Go App in your mobile and scan the QR code.
- Wait for the app to load and bundle everything.
- You are all set to go!
- Upto 94% accuracy in crop disease detection.
- Upto 99% accuracy in weather prediction.
- Use of Hardware for real time data collection.
- Cross Platform Application.
- Can also suggest optimal selling prices.
- Can also be used as a remote monitoring system.








