Posts

Showing posts with the label Raspberry Pi

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 1 : Interfacing LED/Buzzer with Raspberry Pi

Image
OBJECTIVE: To interface an LED or Buzzer with the Raspberry Pi and write a program to control it using delays. RESOURCES REQUIRED: Raspberry Pi (any model with GPIO support) 330Ω Resistor LED (Light Emitting Diode) Breadboard Jumper wires THEORY: LED Basics: An LED has two legs: Anode (+) and Cathode (-) . The longer leg is the Anode (positive) , and the shorter leg is the Cathode (negative) . Current Limiting Resistor: A 330Ω resistor is connected in series with the LED. This resistor limits the current flowing through the LED to prevent it from burning out. Without this resistor, the LED might draw too much current and get damaged. GPIO Pins on Raspberry Pi: The Raspberry Pi comes with General Purpose Input/Output (GPIO) pins. These pins can be programmed to act as either input or output . We can connect components like LEDs or buzzers to these pins to control them through Python programs . Circuit Design: The Anode of the LE...

Python Program 2: Interfacing LDR Sensor with Raspberry Pi

Image
OBJECTIVE: To interface an LDR sensor with the Raspberry Pi and write a Python program to turn ON an LED based on the ambient light level sensed by the LDR . RESOURCES REQUIRED: Raspberry Pi (any model with GPIO support) 330Ω Resistor LED ( Light Emitting Diode ) LDR ( Light Dependent Resistor ) 10kΩ Resistor (pull-down for LDR) Breadboard Jumper wires THEORY: LDR (Light Dependent Resistor) Basics: An LDR is a light-sensitive device whose resistance decreases as the light intensity increases. In bright light , the LDR conducts more current; in darkness , its resistance increases, limiting current. By connecting the LDR in a voltage divider with a resistor, we can read the light level as a digital HIGH or LOW using the Raspberry Pi’s GPIO pin. Current Limiting Resistor for LED: Just like with any LED circuit, a 330Ω resistor is used in series with the LED to prevent excess current and protect the LED. GPIO Pins on Raspberry Pi: The Raspberry Pi fea...

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...

Raspberry Pi & Python

Image
Raspberry Pi Raspberry Pi is a low-cost mini-computer with the physical size of a credit card. Raspberry Pi runs various flavors of Linux and can perform almost all tasks that a normal desktop computer can do. Raspberry Pi also allows interfacing sensors and actuators through the general purpose I/O pins. Since Raspberry Pi runs Linux operating system, it supports Python "out of the box". Why Python is Perfect for Raspberry Pi One of the biggest advantages of Raspberry Pi is its seamless compatibility with Python , one of the most beginner-friendly and powerful programming languages. Here’s why Python is ideal for programming the Raspberry Pi: Pre-installed : Python comes pre-installed in Raspberry Pi OS (previously called Raspbian), so there’s no need for setup. Simple Syntax : Python’s clear and readable code structure makes it easy for beginners. Strong Community Support : Countless tutorials and libraries exist for Pi + Python projects. Hardware Control ...