raspberry – Blog eTechPath https://blog.etechpath.com Tue, 03 Jan 2023 12:36:20 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://blog.etechpath.com/wp-content/uploads/2017/08/BrandLogo12-150x150.png raspberry – Blog eTechPath https://blog.etechpath.com 32 32 How to interface DHT11 DHT22 Temperature sensor with Raspberry Pi https://blog.etechpath.com/how-to-interface-dht11-dht22-temperature-sensor-with-raspberry-pi/ https://blog.etechpath.com/how-to-interface-dht11-dht22-temperature-sensor-with-raspberry-pi/#respond Sun, 21 Nov 2021 21:37:39 +0000 https://blog.etechpath.com/?p=541 About:
In this tutorial i will explain how to interface and program DHT11/22 temperature sensor with Raspberry Pi. I have used adafruit python library to program these sensors in python shell.




Things you will need:
Raspberry Pi (any model will work)
DHT11 or DHT22
4k7 Resistor




Circuit Diagram:

Circuit diagram

Python Code:

#!/usr/bin/python
# Name: DHT11/DHT22Interfacing Temperature sensor with raspberry Pi
# Author: Pranay Sawarkar
# Website: www.etechpath.com
# Copyright: Creative Common

import Adafruit_DHT

# sensor = Adafruit_DHT.DHT22
sensor = Adafruit_DHT.DHT11


# Sensor connected to Raspberry Pi GPIO4.
pin = 4

humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

if humidity is not None and temperature is not None:
    print('Temperature={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
else:
    print('Failed to capture reading. Please Try again!')

 




Steps:

  1. Connect your temperature sensor to GPIO4 of your raspberry pi  and don’t forget to connect 4k7 pull up resistor between vcc and data output pin. You can use any 4k7 to 10k range resistor for pull up purpose.
  2. Power on your raspberry pi and open terminal.
  3. First we will download and install adafruit library for DHT sensors,
    sudo apt-get update
    git clone https://github.com/adafruit/Adafruit_Python_DHT.git
  4. Install python essential files. (if you are using it for first time)
    sudo apt-get install build-essential python-dev
    sudo python setup.py install
  5. Now your raspberry pi is ready to run the adafruit dht python program,
  6. Copy main python code at home directory in a empty file and name it as dht.py (or download ready dht.py file from download section and copy it to your raspberry pi home directory).
  7. Now you can use bellow command to check the sensor data by running this python program from your raspbery pi terminal,
    sudo python dht.py

    You will get output like this,



 

]]>
https://blog.etechpath.com/how-to-interface-dht11-dht22-temperature-sensor-with-raspberry-pi/feed/ 0
How to share files between Raspberry Pi & Windows using shared folder. https://blog.etechpath.com/how-to-share-files-between-raspberry-pi-windows-using-shared-folder/ https://blog.etechpath.com/how-to-share-files-between-raspberry-pi-windows-using-shared-folder/#respond Sat, 21 Oct 2017 22:37:03 +0000 https://blog.etechpath.com/?p=435 About:
For sharing files between Raspberry Pi and Windows we need to setup a file server on Raspberry Pi, here in this tutorial we will use SAMBA file server to share files between two different operating systems.

What is SAMBA:

SAMBA is Linux based free tool which is widely used for file sharing in Windows PC, Apple Computers, and Unix-based operating systems. It is re-implementation of SMB/CIFS standard networking protocol and was developed by Andrew Tridgell. This tool is written in C,C++ and Python programming language and licensed under GPLv3.

How to Setup SAMBA in Raspberry Pi

1.Update apt

pi@raspberrypi ~ $ sudo apt update

 

2. Install SAMBA on your raspberry pi,

pi@raspberrypi ~ $ sudo apt-get install samba




(adsbygoogle = window.adsbygoogle || []).push({});

3. After finishing installation, configure SAMBA by editing configuration file /etc/samba/smb.conf

pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf

In this configuration file, you will need to add the workgroup name of the computer which you are going to connect with the raspberry pi.  To find workgroup name in windows 7 :- Right click on My Computer and enter properties -> Full computer name is your workgroup name (Example =>).

workgroup name
workgroup name
workgroup = MYWORKGROUP
wins support = yes

Replace MYWORKGROUP with your workgroup name. Save & exit the file by pressing ctrl+X , Y, Enter. Change wins support to yes.

 

4. Create shared folder in raspberry pi directory and give read, write & execute permission for this folder to all users.

pi@raspberrypi~ $ mkdir /home/pi/shared
pi@raspberrypi~ $ chmod 777 /home/pi/shared

 

5. Define the behavior  of shared folder. For that purpose we will net to edit configuration file again. /etc/samba/smb.conf

pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf

Add following lines in this file. Save & exit by pressing ctrl+X, Y, Enter.

[pishare]  
     comment = pi shared folder
     path = /home/pi/shared
     browsable = yes
     guest ok = yes
     writable = yes

 

6. Restart SAMBA,

pi@raspberrypi ~ $ sudo /etc/init.d/samba restart





How to setup shared folder in Windows:

  1. Make sure your computer and raspberry pi connected to same network and configured properly.
  2. Open Network tab on the left side of explorer window.
  3. After searching process, you will see a shared computer named as your raspberry pi hostname.
  4. Open it up and you will find Shared folder inside it which we have just created in raspberry pi.
  5. Now you can start sharing files and taking backup between your raspberry pi and windows computer.
]]>
https://blog.etechpath.com/how-to-share-files-between-raspberry-pi-windows-using-shared-folder/feed/ 0