A Python application that monitors weather conditions and automatically controls window opening/closing through a motor based on configurable thresholds. The system also provides a Telegram bot interface for status updates and manual control.
- Real-time weather monitoring (temperature, humidity, rainfall)
- Automatic window control based on weather conditions
- Telegram bot for remote monitoring and control
- Configurable thresholds and GPIO pin assignments
- Raspberry Pi (3 or newer recommended)
- Weather sensors (temperature, humidity, rainfall)
- Motor control mechanism for window
- Appropriate GPIO connections
-
Clone this repository:
git clone https://github.com/yourusername/weather-man.git cd weather-man -
Install dependencies:
pip install -r requirements.txt -
Copy the example environment file and edit with your settings:
cp .env.example .env nano .env -
Run the application:
python main.py
To run Weather-Man automatically on boot:
-
Copy the service file to systemd:
sudo cp weather-man.service /etc/systemd/system/ -
Edit the service file if needed (adjust paths):
sudo nano /etc/systemd/system/weather-man.service -
Enable and start the service:
sudo systemctl enable weather-man.service sudo systemctl start weather-man.service -
Check status:
sudo systemctl status weather-man.service
-
Create a new bot with BotFather:
- Open Telegram and search for "@BotFather"
- Send "/newbot" and follow the instructions
- Copy the API token to your .env file
-
Find your Chat ID:
- Search for "@userinfobot" on Telegram
- Start the bot and it will send you your chat ID
- Add this ID to the ALLOWED_CHAT_IDS in your .env file
-
Start a conversation with your bot and send the /start command
The default GPIO pin configuration is:
- Temperature Sensor: GPIO 4
- Humidity Sensor: GPIO 17
- Pressure Sensor: GPIO 27
- Rainfall Sensor: GPIO 22
- Motor Control: GPIO 18
- Motor Direction: GPIO 23
- Motor Status: GPIO 24
Modify these in the .env file as needed to match your actual wiring.
If you prefer to use an online weather service instead of physical sensors:
- Sign up for an OpenWeatherMap API key at https://openweathermap.org/
- Add your API key to the .env file
- Set WEATHER_SOURCE=API in the .env file
- Configure your latitude and longitude
Edit the .env file to configure:
- Telegram bot token and authorized users
- Weather data source (local sensors or API)
- GPIO pin assignments for sensors and motor
- Weather thresholds for automatic control
/status- Get current weather conditions and window status/open- Manually open the window/close- Manually close the window/auto- Enable automatic mode (default)/manual- Disable automatic mode/config- Show current configuration/help- Show available commands
To verify the functionality without hardware:
python test_weather_man.py
MIT