# Arduino Sensor Data Processor with Gemini AI + SMS Alerts
A Flask-based server application that receives sensor data from wireless Arduino devices, uses Google Gemini AI to make intelligent control decisions, and sends real-time SMS alerts to farmers via Africa's Talking API.
## 🚀 Features
- **REST API** for receiving Arduino sensor data via HTTP POST
- **Google Gemini AI Integration** for intelligent decision making
- **SMS Alerts via Africa's Talking** for real-time farmer notifications
- **Environmental Control Logic** for temperature, humidity, light, and gas monitoring
- **Intelligent Alert Management** prevents SMS spam with state tracking
- **Farmer-Friendly Messages** with emojis and clear action guidance
- **Comprehensive Logging** of sensor data, AI decisions, and SMS alerts
- **Configurable Thresholds** for all sensor parameters and alert cooldowns
- **Robust Error Handling** with fallback rule-based decisions
- **Health Check Endpoints** for monitoring system status
- **Sandbox/Live Environment** support for development and production
## 📊 Sensor Data Processing
The system processes four types of sensor data:
- **Temperature** (°C) - Controls fan and LED color
- **Humidity** (%) - Additional environmental context
- **Light Intensity** (0-1023) - Ambient light monitoring
- **Gas Level** (0-1023) - Safety gas detection
## 🧠 AI Decision Logic
### Temperature Control Rules:
- `≥ 30°C`: Start fan, turn on red LED (hot)
- `15°C - 30°C`: Stop fan, turn on yellow LED (normal)
- ` 300`: Trigger gas alert (critical priority)
All decisions are processed through Google Gemini AI for intelligent reasoning and can fall back to rule-based logic if AI processing fails. Critical alerts automatically trigger SMS notifications to farmers with actionable information.
## 🛠️ Installation & Setup
### 1. Clone and Install Dependencies
```bash
git clone
cd arduino-sensor-processor
pip install -r requirements.txt
```
### 2. Configure Environment Variables
Copy the …