Posts

Showing posts with the label python notes

Python Program 4: Interfacing Sensor Data to ThingSpeak through Raspberry Pi

Image
Objective: To interface temperature and humidity data from a DHT11 sensor to ThingSpeak using a Raspberry Pi . Resources Required: Raspberry Pi 2 DHT11 Sensor Connectors Sensor connecting wires Computer system Theory: The DHT11 sensor is used to collect temperature and humidity data, which is then sent to the Raspberry Pi. The Raspberry Pi will transmit this data to a ThingSpeak channel, allowing users to remotely monitor the data through a cloud-based platform. Setting Up ThingSpeak Account Before we begin, you need to create an account on ThingSpeak: Visit the ThingSpeak website . After signing up or logging in, click on New Channel to create a new channel. Provide the required details for your channel: Channel Name : Choose a suitable name. Channel Description : Describe the purpose of your channel (e.g., "Temperature and Humidity Data"). You can configure up to 8 fields for different parameters. For this experiment, we’ll use: Field 1 : ...

Python program 5: Interfacing Motor Relay with Raspberry Pi for ON/OFF Control

Image
Objective: To interface a motor relay with Raspberry Pi and write a Python program to control its ON/OFF operation. Resources Required: Raspberry Pi (any model) DC Motor Relay Module Jumper wires Theory: A relay is an electrically operated switch. In this experiment, we are using a single-channel relay module to control a DC motor using the GPIO pin of the Raspberry Pi. The relay has two sides: Input Side (control side connected to Raspberry Pi) Output Side (switching side connected to the motor and power source) Relay Indicators: Red LED : Lights up when the relay board is powered. Green LED : Lights up when the relay is activated (ON state). Switching Logic: If the orange cable is connected to the bottom slot, the motor will be OFF/ON depending on the relay state. If connected to the upper slot, the motor will be ON/OFF depending on the relay state. Circuit Diagram Python Code: Below is the Python program to control the motor ON/OFF ope...

Python Program 3: Interfacing DHT11 Sensor with Raspberry Pi

Image
OBJECTIVE: To interface the DHT11 sensor with the Raspberry Pi and write a Python program to print the temperature and humidity readings in real-time. RESOURCES REQUIRED: Raspberry Pi (any model with GPIO support) DHT11 Sensor Breadboard Jumper wires Python Libraries: adafruit_dht , psutil THEORY: DHT11 Sensor Basics: The DHT11 sensor is a low-cost digital sensor used for measuring temperature and humidity . It provides readings for relative humidity (range: 20% to 90% RH ) and temperature (range: 0°C to 50°C ). The sensor communicates with the Raspberry Pi through serial communication (one-wire protocol). The DHT11 sensor has 4 pins : VCC (power) GND (ground) Data (for data communication) NC (not connected, not used) Data from the sensor is sent in a digital format where the sensor sends pulses of different durations to represent 1 s and 0 s. These pulses are decoded by the Raspberry Pi to retrieve temperature and hum...

Python for Beginners: Step-by-Step Guide to Learn Python Programming

Image
Python for Beginners: Step-by-Step Guide to Learn Python Programming      Welcome! In this comprehensive Python tutorial, we're going to learn Python from the ground up—step by step, with clear explanations and hands-on examples. Whether you're a complete beginner or looking to strengthen your understanding, this guide will help you build a solid foundation in the Python programming language . It's perfect for anyone who wants to learn Python for beginners or improve their coding skills through practical learning.