Posts

Showing posts with the label Python

Real-Time Temperature Monitoring & Alerts with Raspberry Pi, Python, Azure IoT Hub, Azure ML & Azure Communication Services

Image
Diagram Explanation 1️⃣ Raspberry Pi with a DHT11/DHT22 sensor sends real-time temperature data to Azure IoT Hub . 2️⃣ Azure IoT Hub processes incoming data and triggers Azure Functions for further processing. 3️⃣ Azure ML Model analyzes data and detects temperature anomalies (e.g., overheating or cooling failures). 4️⃣ If an anomaly is detected, Azure Functions calls Azure Communication Services (ACS) . 5️⃣ ACS sends an SMS/Email alert to the admin/user . 6️⃣ User/Admin monitors temperature data and receives alerts. This guide will walk you through building a real-time temperature monitoring system using IoT sensors (Raspberry Pi) and Azure cloud services . The system will: ✅ Collect temperature data from IoT sensors. ✅ Analyze real-time temperature data for anomalies using Azure ML . ✅ Trigger alerts (SMS/Email) via Azure Communication Services (ACS) when abnormal temperature conditions are detected. 🛠 Tech Stack Hardware: Raspberry Pi, DHT11/DHT22 Temperature Senso...

Top 10 Advanced Python DSA Interview Questions and In-Depth Answers

Image
Here are 10 advanced Python interview questions related to Data Structures and Algorithms (DSA) , along with in-depth answers: 1. How do you find the k-th largest element in an array? Problem: Find the k-th largest element in an unsorted array. Solution: import heapq def find_kth_largest (nums, k) : return heapq.nlargest(k, nums)[ -1 ] # Example nums = [ 3 , 2 , 1 , 5 , 6 , 4 ] k = 2 print(find_kth_largest(nums, k)) # Output: 5 Step-by-Step Explanation: Importing heapq : The heapq module in Python provides an implementation of the heap queue algorithm, also known as the priority queue algorithm. Defining the Function : The function find_kth_largest(nums, k) takes two arguments: nums : A list of numbers. k : An integer representing the position of the largest element we want to find. Using heapq.nlargest() : The heapq.nlargest(k, nums) function returns a list of the k largest elements from the nums list, sorted in descending order. For example, heapq.nlargest(2, [3, ...

Google Cloud Storage (GCS) + Django - File Upload, Download, List, and Delete Example

Image
To integrate Google Cloud Storage (GCS) with a Django application for file upload, download, list, and delete operations , follow these steps: 1. Set Up Google Cloud Storage Create a Google Cloud Project : Visit the Google Cloud Console and create a new project or use an existing one. Enable the Cloud Storage API : Navigate to APIs & Services > Library , search for "Cloud Storage," and enable it. Create a GCS Bucket : Go to Storage > Browser in the console. Click Create Bucket , choose a globally unique name, configure settings, and create it. Set Up a Service Account : Go to IAM & Admin > Service Accounts , create a service account, and assign the Storage Admin role. Generate a key (JSON) for the service account and download it to your local machine. 2. Configure Django for GCS Install Required Libraries : Install the Google Cloud Storage and Django libraries: pip install google-cloud- storage django-storages Set Up the Django Storage Backend : Add th...