Added the main setup.sh file and added instructions in README file along with making some minor changes to alternative method.
This commit is contained in:
parent
b02d4d81ce
commit
97cabc3a75
38
README.md
38
README.md
@ -4,6 +4,38 @@ This project is a uses the AdaFruit libraries for sensing temperature using DHT1
|
||||
|
||||
---
|
||||
|
||||
## Main method
|
||||
|
||||
> [!NOTE] This is the main method, using AdaFruit library. For an easier method, checkout [## Alternative method](https://git.kska.io/notkshitij/DHT11#alternative-method)
|
||||
|
||||
1. Install some prerequisite packages:
|
||||
```shell
|
||||
sudo apt update &&\
|
||||
sudo apt install git
|
||||
|
||||
```
|
||||
|
||||
2. Clone the project:
|
||||
```shell
|
||||
git clone https://git.kska.io/notkshitij/DHT11.git
|
||||
```
|
||||
|
||||
> Alternatively, you can also [download the zip file](https://git.kska.io/notkshitij/DHT11/archive/main.zip)
|
||||
|
||||
3. Change the current working directory to the folder in which the project was cloned:
|
||||
```shell
|
||||
cd ./DHT11
|
||||
```
|
||||
|
||||
4. Run the `setup.sh` script:
|
||||
```shell
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> After running the code, and completing the execution, run `deactivate` in the terminal to exit the virtual environment.
|
||||
|
||||
---
|
||||
|
||||
## Alternative method
|
||||
|
||||
@ -26,8 +58,12 @@ cd /home/$(whoami)/temp-sensor
|
||||
python3 -m venv .
|
||||
source bin/activate
|
||||
pip install dht11 setuptools RPi.GPIO
|
||||
|
||||
```
|
||||
|
||||
3. Run the code [alt-temp.py](https://git.kska.io/notkshitij/DHT11/src/branch/main/alt-temp.py)
|
||||
3. **Download** and **run** the code [alt-temp.py](https://git.kska.io/notkshitij/DHT11/src/branch/main/alt-temp.py)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> After running the code, and completing the execution, run `deactivate` in the terminal to exit the virtual environment.
|
||||
|
||||
---
|
||||
|
88
setup.sh
Executable file
88
setup.sh
Executable file
@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat << "EOF"
|
||||
|
||||
__| |______________________________________________________________________| |__
|
||||
__ ______________________________________________________________________ __
|
||||
| | | |
|
||||
| | | |
|
||||
| | ____ _ _ _ | |
|
||||
| | | _ \ ___ ___(_) __ _ _ __ ___ __| | __ _ _ __ __| | | |
|
||||
| | | | | |/ _ \/ __| |/ _` | '_ \ / _ \/ _` | / _` | '_ \ / _` | | |
|
||||
| | | |_| | __/\__ \ | (_| | | | | __/ (_| | | (_| | | | | (_| | | |
|
||||
| | |____/ \___||___/_|\__, |_| |_|\___|\__,_| \__,_|_| |_|\__,_| | |
|
||||
| | |___/ | |
|
||||
| | _____ _ _ _ | |
|
||||
| | | ____|_ __ __ _(_)_ __ ___ ___ _ __ ___ __| | | |__ _ _ | |
|
||||
| | | _| | '_ \ / _` | | '_ \ / _ \/ _ \ '__/ _ \/ _` | | '_ \| | | | | |
|
||||
| | | |___| | | | (_| | | | | | __/ __/ | | __/ (_| | | |_) | |_| | | |
|
||||
| | |_____|_| |_|\__, |_|_| |_|\___|\___|_| \___|\__,_| |_.__/ \__, | | |
|
||||
| | |___/ |___/ | |
|
||||
| | _ __ _ _ _ _ _ | |
|
||||
| | | |/ /___| |__ (_) |_(_)(_) | |
|
||||
| | | ' // __| '_ \| | __| || | | |
|
||||
| | | . \\__ \ | | | | |_| || | | |
|
||||
| | |_|\_\___/_| |_|_|\__|_|/ | | |
|
||||
| | |__/ | |
|
||||
| | | |
|
||||
__| |______________________________________________________________________| |__
|
||||
__ ______________________________________________________________________ __
|
||||
| | | |
|
||||
|
||||
EOF
|
||||
|
||||
# Declaring variables
|
||||
line="=================================="
|
||||
|
||||
# Update and upgrade packages
|
||||
echo -e "$line\nUpdating and upgrading packages.\n$line\n"
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
echo -e "$line\nFinished updating and upgrading packages.\n$line\n"
|
||||
|
||||
# Check if python3-pip is installed
|
||||
echo -e "$line\nChecking for python3-pip.\n$line\n"
|
||||
if ! dpkg -l | grep -q python3-pip; then
|
||||
echo -e "$line\npython3-pip is not installed,\nInstalling python3-pip.\n$line\n"
|
||||
sudo apt install python3-pip -y
|
||||
else
|
||||
echo -e "$line\npython3-pip already installed, moving on...\n$line\n"
|
||||
fi
|
||||
|
||||
# Check if libgpiod2 is installed
|
||||
echo -e "$line\nChecking for libgpiod2.\n$line\n"
|
||||
if ! dpkg -l | grep -q libgpiod2; then
|
||||
echo -e "$line\nlibgpiod2 is not installed,\nInstalling python3-setuptools.\n$line\n"
|
||||
sudo apt install libgpiod2 -y
|
||||
else
|
||||
echo -e "$line\nlibgpiod2 already installed, moving on...\n$line\n"
|
||||
fi
|
||||
|
||||
# Create project folder
|
||||
USER=$(whoami)
|
||||
PROJECT_DIR="/home/$USER/Desktop/temp-sensor"
|
||||
|
||||
if [ ! -d "$PROJECT_DIR" ]; then
|
||||
echo -e "$line\nCreating 'temp-sensor' in Desktop directory for current user.\n$line\n"
|
||||
mkdir -p "$PROJECT_DIR"
|
||||
echo -e "$line\nCreated '$PROJECT_DIR' directory.\n$line\n"
|
||||
else
|
||||
echo -e "$line\n$PROJECT_DIR already exists. Please delete the folder before running this script.\n$line\n\nExiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create and activate Python virtual environment
|
||||
cd "$PROJECT_DIR"
|
||||
python3 -m venv . --system-site-packages
|
||||
echo -e "$line\nVirtual environment created.\n$line\n"
|
||||
echo -e "$line\nActivating virtual environment...\n$line\n"
|
||||
source bin/activate
|
||||
|
||||
echo -e "$line\nInstalling dependencies...\n$line\n"
|
||||
pip3 install --upgrade setuptools click adafruit-python-shell adafruit-circuitpython-dht
|
||||
|
||||
echo -e "$line\nSetting up raspi-blinka...\n$line\n"
|
||||
python3 raspi-blinka.py
|
||||
|
||||
echo -e "\n\n\n$line$line$line\nSetup completed.\nExecute the command 'python3 temp-calc.py' to calculate\nthe temperature.\n# DESIGNED AND ENGINEERED BY KSHITIJ.\n# END OF SCRIPT\n$line$line$line\n\n\n"
|
||||
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user