Imagine waking up, opening your laptop, and instantly seeing a wallpaper that reflects the real-time weather outside your house—cloudy, sunny, or foggy! 🌧️☀️🌫️
Our Automatic Weather-Based Wallpaper Changer seamlessly integrates IoT with software automation. Using the Bolt IoT module, LM35 temperature sensor, and LDR light sensor, our system detects local weather conditions and dynamically updates your laptop's wallpaper to match the ambiance.
With real-time sensing, API integration, and automation, this project blends hardware and software to deliver a personalized user experience. Perfect for weather enthusiasts, tech geeks, and automation lovers! 🌍⚡
Why settle for static wallpapers when your environment is constantly changing? 💡
BoltIoT PlatformBolt IoT platform gives you the capability to control your devices and collect data from IoT devices safely and securely no matter where you are. Get actionable insights by deploying machine learning algorithms with just a few clicks to detect anomalies as well as predict sensor values. To know more visit boltiot.com.
Integromat (Make)The role of Integromat is to seamlessly connect your apps/services, so you can concentrate on new tasks rather than repeating the same tasks again and again. Get back to what matters the most.
We have to create a Integromat scenario to communicate with pixabay using api. Here is the blueprint of the scenario that I have created.
A Blueprint in Make (formerly Integromat) is a pre-configured scenario that can be imported to quickly set up automation. Here's how you can import a blueprint and set it up.
Download the Blueprint File
- Obtain the .json file of the blueprint you want to import.
- Save it on your local computer in a known location.
Log into Make (Integromat)
- Go to Make's website.
- Log in using your credentials.
Navigate to the Scenarios Page
- In the dashboard, click on "Scenarios" from the left sidebar.
- Click the “Create a new scenario” button (top-right corner).
Import the Blueprint
- On the scenario editor page, click the three dots (...) menu in the bottom panel.
- Select "Import Blueprint" from the dropdown.
- Click "Choose File", then select the .json blueprint file you downloaded.
- Click "Open" to upload the blueprint.
Review and Configure the Scenario
- Once the blueprint loads, review the modules and connections in the visual scenario editor.
- If any modules require authentication, click on them and provide the necessary API keys, login details, or tokens.
- Ensure that all required services and integrations are correctly linked.
Test the Scenario
- Click "Run once" (bottom left) to test the setup.
- Check if the scenario executes correctly.
- If needed, adjust module settings or troubleshoot any issues.
Activate the Scenario
- Once the scenario works as expected, click "Save".
- Set a schedule (e.g., every 5 minutes, hourly, daily) based on your needs.
- Click "Enable" to activate automation.
Mailgun is a powerful email automation service designed for developers and businesses to send, receive, and track emails via APIs. It provides SMTP and RESTful API capabilities for seamless email delivery, making it ideal for transactional emails, marketing campaigns, and email routing.
This is an optional step, if you do not want this service then remove the relevant code from the main program script and also from the configuration file. If you want to receive the mail containing the weather status around you and the link of the wallpaper that has been currently set as your Laptop Wallpaper then create a Mailgun account and in the conf python file put your Mailgun credentials in it.
Assembling the hardware components1. Get all the required components mentioned above.
2. Take a Breadboard and insert LM35 sensor as shown.
3. Connect the VCC pin to 2 * 4.4k ohms resistor as shown in circuit diagram.
4. Then connect the other end of the 2nd 4.4k ohms resistor to the 5v supply pin in the Bolt wifi module.
5. Then take another wire and connect the VCC pin of LM35 sensor directly to the GPIO1 pin of the Bolt module. (Voltage Divider circuit)
6. Connect the OUT pin of the sensor to the A0 digital pin of the bolt module and the GND pin to the GND on the bolt module.
7. Now take the LDR sensor and insert it into the breadboard.
8. Connect one end of the LDR to the 10k ohms resistor and connect the other end of that resistor to the A0 pin through the Breadboard connections.
9. Connect the other end of the LDR sensor to the GPIO4 pin of the Bolt module through wires using Breadboard.
After assembling the hardware, register and connect the Bolt unit to the Bolt Cloud. Know more at registering and connecting bolt to cloud.
Building up the logic on Integromat1. First make an account on Integromat using the link.
2. Configure your Webhook URL
3. Add HTTP make a request module and add the pixabay url and set method as GET method. Add parameters in query string as shown in the screenshots.
4. Configure the HTTP Request Module as shown in Screenshots.
5. Run the module once to get the response variables from pixabay.
5. Now create a Tools set a variable module and select large_image_url
6. Now create a Webhook Response module.
7. If you don't want to go through this process then follow the steps mentioned in importing the blueprint module into the Make. You can find the .json file in Attachments Section.
Working principleThe working principle revolves around determining the weather by using the available sensors LDR Light sensor and LM35 Temperature sensor. The project dynamically changes the laptop wallpaper based on real-time weather conditions by using Bolt IoT, LM35, and LDR sensors. It also integrates Z-score anomaly detection to identify unusual temperature and light variations, ensuring wallpapers are updated only when necessary.
1. Sensor Data Acquisition
a) LM35 (Temperature Sensor) Readings
Power Switching:
- The circuit enables LM35 by setting Pin 4 (LOW) and Pin 1 (HIGH) to ensure power supply to LM35.
- Note that the GPIO pins in Bolt IoT wi-fi module supply only 3.3v and for LM35 sensor it needs 5v supply to operate.
- Because we cannot directly control the 5v supply pin in the Bolt module through the Bolt cloud we have created a voltage divider setup where VCC of the LM35 Temperature Sensor is connected to both GPIO1 and 5v supply on the module with a series of resistors for the 5v supply connecting to VCC of LM35.
- This will ensure that when GPIO1 is turned on the LM35 will get enough supply to be powered on and when GPIO is turned off the LM35 will not get enough supply and it will be powered off.
- A delay of 5 seconds ensures stable readings.
Reading Temperature:
- The analog output from LM35 is read from A0 pin using the Bolt IoT ADC.
- The raw ADC value is converted to temperature using the formula: Temperature(°C) = (100 * Temperature)/1024
- After reading, Pin 1 is set to LOW and Pin 4 to HIGH to switch power back to LDR.
b) LDR (Light Sensor) Readings
- Direct Readout: LDR is already powered after the LM35 readout, so its analog value is read directly from A0.
- Higher ADC value = More light intensity, Lower ADC value = Darker conditions.
2. Data Processing & Anomaly Detection (Z-Score Analysis)
History Storage:
- The last few temperature and light readings are stored in a history_data list.
- History Storage: The last few temperature and light readings are stored in a history_data list.
Z-Score Calculation:
- Mean and variance of previous readings are calculated.
- Z-score thresholding determines upper and lower bounds for normal readings.
- If a new value is beyond the computed bounds, it is marked as an anomaly.
3. Weather Condition Analysis
- The function weather_determine(temp, light) analyzes the latest temperature and light data and classifies it into different weather conditions (e.g., sunny, rainy, foggy, snowy).
- Extreme readings are associated with heatwaves, storms, or freezing weather.
- This function determines the type of wallpaper to be set.
4. Triggering Webhook & Fetching Wallpaper
If an anomaly is detected OR 1 hour has passed, the script triggers the Integromat webhook:
- The webhook sends the determined weather condition to Integromat/Make.
- A corresponding wallpaper image URL is fetched from an API.
5. Wallpaper Update
Downloading the Image:
- The fetched image is downloaded and saved to D:\Wallpapers\wallpaper.jpg.
Setting as Wallpaper (Windows-Specific):
- The SystemParametersInfoW function is used to update the wallpaper immediately.
6. Email Notification (Mailgun Integration)
- After successfully changing the wallpaper, an email notification is sent using Mailgun API.
The email includes:
- Current temperature
- Light intensity
- Weather status
- Image link
7. Continuous Loop Execution
- The process repeats every 10 seconds, ensuring real-time monitoring.
- Wallpapers are updated only on significant weather changes or every 1 hour to avoid unnecessary updates.
1. Install VS Code and Python
- Download and install Visual Studio Code from here.
- Install Python (3.x version) from here.
- Open VS Code and install the Python Extension from the Extensions Marketplace.
2. Install Required Python Libraries
Before running the script, install the required libraries using the Terminal in VS Code:
- Open VS Code.
- Press Ctrl + ` (backtick) to open the Terminal.
Run the following command to install dependencies:
pip install boltiot requests statistics math json
3. Set Up the conf.py File
Your script imports conf.py, which contains API keys and device configurations.
Create a new file named conf.py in the same directory and add the following details:
API_KEY = "your_bolt_api_key"
DEVICE_ID = "your_bolt_device_id"
MAILGUN_API_KEY = "your_mailgun_api_key"
SANDBOX_URL = "your_mailgun_sandbox_url"
SENDER_EMAIL = "your_sender_email"
RECIPIENT_EMAIL = "your_recipient_email"
FRAME_SIZE = 5 # Adjust based on your needs
MUL_FACTOR = 3 # Z-score threshold for anomaly detection
⚠️ Replace placeholders with your actual credentials.
4. Connect Your Bolt IoT Module
- Power up your Bolt IoT module.
- Ensure it’s connected to Wi-Fi and linked to the Bolt Cloud.
5. Run the Python Script
- Create a python file and write the python code as shown in automatic_change.py file.
- Open the script in VS Code.
- Click Run > Run Without Debugging or press F5.
If running from the terminal, use:
python your_script.py
6. Verify Execution
- The script will read data from the LM35 and LDR sensors.
- It will determine the weather condition.
- It will call a webhook to fetch a wallpaper.
- It will set the wallpaper on your PC.
- It will send an email notification if configured.
Comments
Please log in or sign up to comment.