Skip to content

Raspberry Pi: weather-driven window motor control and Telegram bot for status and manual override.

Notifications You must be signed in to change notification settings

scscodes/weather-man

Repository files navigation

Weather-Man: Smart Window Controller for Raspberry Pi

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.

Features

  • 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

Hardware Requirements

  • Raspberry Pi (3 or newer recommended)
  • Weather sensors (temperature, humidity, rainfall)
  • Motor control mechanism for window
  • Appropriate GPIO connections

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/weather-man.git
    cd weather-man
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Copy the example environment file and edit with your settings:

    cp .env.example .env
    nano .env
    
  4. Run the application:

    python main.py
    

Setting up as a Service

To run Weather-Man automatically on boot:

  1. Copy the service file to systemd:

    sudo cp weather-man.service /etc/systemd/system/
    
  2. Edit the service file if needed (adjust paths):

    sudo nano /etc/systemd/system/weather-man.service
    
  3. Enable and start the service:

    sudo systemctl enable weather-man.service
    sudo systemctl start weather-man.service
    
  4. Check status:

    sudo systemctl status weather-man.service
    

Telegram Bot Setup

  1. 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
  2. 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
  3. Start a conversation with your bot and send the /start command

GPIO Configuration

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.

Weather API (Alternative to Sensors)

If you prefer to use an online weather service instead of physical sensors:

  1. Sign up for an OpenWeatherMap API key at https://openweathermap.org/
  2. Add your API key to the .env file
  3. Set WEATHER_SOURCE=API in the .env file
  4. Configure your latitude and longitude

Configuration

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

Telegram Commands

  • /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

Running Tests

To verify the functionality without hardware:

python test_weather_man.py

License

MIT

About

Raspberry Pi: weather-driven window motor control and Telegram bot for status and manual override.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors