Logo

dev-resources.site

for different kinds of informations.

First Month With My Raspberry Pi

Published at
2/17/2023
Categories
raspberrypi
iot
homeautomation
Author
santosh
Categories
3 categories in total
raspberrypi
open
iot
open
homeautomation
open
Author
7 person written this
santosh
open
First Month With My Raspberry Pi

Introduction

It's no longer than a month since I bought a Raspberry Pi. Pi 4B to be precise. In this post, I'm going to log how I spent my 1st month with it.

Setup the Pi

When I decided to buy Raspi, I decided not to go with the kit. The reason was the model I was looking for, which is 8GB Model B wasn't available in India. And finding a kit for it would have been more challenging.

So I bought the Pi itself from OL Electronics. It cost me β‚Ή10,700 INR with taxes and delivery charge.

As you might know, Pi does not ship with a power adapter. So I bought one from robu.in. It cost me β‚Ή315 with delivery charges.

Pi also does not comes with a memory card. I tried searching for 64 micro sd cards offline and online. The best deal was from Amazon. It cost me β‚Ή539. You will also need a card reader, which I bought from the local market at a price of β‚Ή30.

While flashing, I choose to use the Lite variant of OS which comes without a desktop environment and has a footprint of 300 MB on disk.

Setting up the OS

The Pi board, a 5V 3A Type-C power adapter, a micro sd, and a card reader is all you need to boot up a Pi. You don't need a monitor or HDMI adapter if you already have a laptop because you can also SSH to your Pi to do your work remotely and that is how I usually work on my Pi.

As you know, I use Ubuntu on my machine. If you are also using Ubuntu, you can install it by:

sudo apt install rpi-imager
Enter fullscreen mode Exit fullscreen mode

Instruction for other operating systems can be found on their GitHub page.

Put a micro sd card in the card reader and Please consider watching How to use Raspberry Pi Imager.

Blink Light

I prefer to use the gpiozero package for dealing with GPIO. But there is also an RPi module.

import time
from gpiozero import LED

led = LED(18)

while True:
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

Make sure you attach the long head of the LED to pin 18.

There is also an equivalent code using the RPi package:

import time
import RPi.GPIO as GPIO

led_pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)

while True:
    GPIO.output(led_pin, True)
    time.sleep(1)
    GPIO.output(led_pin, False)
    time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

I have also short a video I have posted on Instagram. Here it is:

Blinking LED using GPIO programming

Actuate on Proximity

Here I have used both packages to run something when the proximity sensor detects any object near the sensor.

The sensor I am using is an IR proximity sensor.

import time

from gpiozero import LED
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
GPIO.setup(8, GPIO.IN)

led = LED(18)

while True:
    if GPIO.input(8) == 0:
        print("turning light on")
        led.on()
    else:
        print("turning light off")
        led.off()

    time.sleep(0.1)
Enter fullscreen mode Exit fullscreen mode

IR sensor in action

Controlling LED brightness, 0-100 and back

Below is Python code to change the brightness of a LED light using Raspberry Pi.

import time
import RPi.GPIO as GPIO

led_pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)

pwm_led = GPIO.PWM(led_pin, 500)
pwm_led.start(100)

while True:
    start = 0
    end = 100
    while start < end:
        pwm_led.ChangeDutyCycle(start)
        time.sleep(.025)
        start += 1
    break
Enter fullscreen mode Exit fullscreen mode

I don't shoot a video for this one because the intensity was so low that it was very hard to distinguish between different strengths of light.

Controlling an RGB light (failed)

I have also bought a common cathode LED. But somehow, I'm not able to turn on the LED. Not sure if the problem is in the LED, my code, or the pins.

Here is the code I was using.

from gpiozero import RGBLED

led = RGBLED(22, 27, 17)

led.color = (1, 0, 0)
Enter fullscreen mode Exit fullscreen mode

And here is the setup I was using.

Failed attempt to use RGB LED

In the above image, the blue, green, and red are placed at 6, 7, and 8 on the left column, and the common cathode is placed at 3rd from the right.

Please let me know if you have a solution for this one.

Conclusion

This is not the entirety of the things I have done with my Raspberry Pi in the first month. I have a DHT11 sensor which I mistakenly bought without the IC. And now I need a 4.7K resistor to work with it. I am yet to order the resistor.

Alongside Raspi accessories, I have also bought some NFC tags to play with. I will post another blog if I make something interesting with it.

Installing Home Assistant is another thing that I have done on my Pi. This board is going to be the hub of other smart devices on my network. I'm planning to buy some ESF32 to help me with my home automation journey.

If you are also keen on home automation and IoT, I'd recommend you IoT for Beginners.

Let me know if you want more articles like this one.

homeautomation Article's
30 articles in total
Favicon
The Future of Smart Homes: Top Devices, Trends & Innovations for 2024
Favicon
Tektronix Technologies: Home Automation Experts in Dubai, Abu Dhabi & Beyond
Favicon
Replace Philips Hue automation with Home Assistant's
Favicon
Navigating the Future: Smart Home Innovations and IoT Trends You Need to Know
Favicon
The Home Assistant model
Favicon
Revolutionizing Living Spaces: The Latest in Smart Home & IoT Innovations
Favicon
Revolutionizing Smart Homes: Apple’s Bold Step into IoT with Intelligent Innovations
Favicon
Unlocking the Future: Top Smart Home Devices & Trends of 2024
Favicon
Smart Cupboard System with Robotic Arm: Precision and Accessibility in Home Automation
Favicon
Apple's Next Big Thing: Smart Home Displays Set to Change Our Homes in 2025
Favicon
Apple's Game-Changer: New Smart Home Device Set for 2025 Unveiling
Favicon
Unlocking the Future: Exciting Innovations in Smart Home and IoT for 2024
Favicon
Unlocking the Future: Smart Home Breakthroughs and IoT Innovations
Favicon
MajorDom β€” Your Effortlessly Simple Smart Home, Launched on Kickstarter
Favicon
Smarter Than You Think: NLP-Powered Voice Assistants
Favicon
Building Smart Home Automation with JavaScript
Favicon
Crafting My Perfect Home Assistant Dashboard
Favicon
Raspberry Pi: What you need to know
Favicon
Unlocking Vision: Evaluating LLMs for Home Security
Favicon
Is it Dry Yet?
Favicon
Creating NFC Or QR Code Automations In Home Assistant Using Webhooks
Favicon
Shabbat / Yom Tov Home Assistant Automations β€” Part 2 (Helper Configuration)
Favicon
Live Average Carbon Intensity rating with Octopus Home Mini in Home Assistant
Favicon
Atom8 Robotic Lab's Comprehensive Home Automation Solutions
Favicon
The Role of LIN Protocol in Smart Home Automation
Favicon
The Future of Smart Homes: How IoT is Changing the Way We Live
Favicon
Adding school morning routine for my son via Homeassistant
Favicon
First Month With My Raspberry Pi
Favicon
How to Control Philips Wiz Bulb Using Go
Favicon
Open-source Sonos apps

Featured ones: