DEV Community

maso
maso

Posted on

Preparing for Automation...

This time, I prepared for lighting automation and for monitoring of temperature, and humidity.
I think the light gets a bit hot, so I want to make sure the temperature inside the tent stays within an appropriate.(And if needed, I will add a fan.)

(The seeds are growing well, but it may take 1 or 2 weeks more.)

1. Buy the things!

I bought the following items to set up the automation system.

-1. Raspberry Pi 4

This time, I'm using a Raspberry Pi 4 for automation. I bought it from Akizuki Denshi because it was cheaper than buying it on Amazon.

https://akizukidenshi.com/catalog/g/g114839/?utm_source=chatgpt.com

-2. Sensor

I bought the sensor to monitor temperature and humidity inside the tent.
The SHT31 is a sensor that can measure temperature and humidity.
https://amzn.asia/d/0fcbqTFT

-3. Power supply for the Raspberry Pi 4

It requires a 5V 3A USB-C power supply with an integrated cable.
https://amzn.asia/d/0jh5FxTI

-4. MicroSD card for the Raspberry Pi4

I think the 32GB SD card is enough for the prototype, but I bought a 64GB one because I want to add camera functions later.
https://amzn.asia/d/0fbMhFmL

-5. Raspberry Pi 4 Case

I decided to use a case because I will be using the Raspberry Pi near water.
https://akizukidenshi.com/catalog/g/g114779/

2. Install the OS for the Raspberry Pi.

-1. Install the "Raspberry Pi Imager" into the PC.

You can download it from the following link.
https://www.raspberrypi.com/software/

-2. Insert the MicroSD into your PC.

I used MicroSD adapter to attach it to the PC.

-3. Write the OS image to the microSD card.

Start the Raspberry Pi Imager and select Device (Raspberry Pi 4), OS (Raspberry Pi OS Lite (64-bit)), Storage (microSD card).

Choose the storage device.

Set the hostname for the Raspberry Pi.

Set the user name and password for logging in to the Raspberry Pi.

Configure the Wi-Fi settings and enable SSH.

write the image to the microSD card.

The configuration files were written to the microSD card.

3. Connect with SSH

-1. Connect the power supply.

Connect the power supply and wait for the Raspberry Pi to boot.

-2. Connect with SSH

Run the following command to connect to the Raspberry Pi from your PC.

ssh <username>@<hostname>.local
Enter fullscreen mode Exit fullscreen mode

Run the following commands to confirm the current user, hostname, and working directory.

whoami
hostname
pwd
Enter fullscreen mode Exit fullscreen mode

Make sure that the Raspberry Pi can connect to the Internet.

ping -c 3 google.com
Enter fullscreen mode Exit fullscreen mode

-3. Initial settings

Update the packages.
(It takes about 10 minutes in my environment.)

sudo apt update
sudo apt upgrade -y

sudo apt install -y i2c-tools python3-pip python3-venv
Enter fullscreen mode Exit fullscreen mode

-3. Enable the I2C

open the configuration menu.

sudo raspi-config
Enter fullscreen mode Exit fullscreen mode

choose "Interface Options"
→choose "I5 I2C"
→a message will be shown, please choose Yes.
→You should see the message "The ARM I2C is enabled".

-3. Check the configuration

Reboot the Pi.

sudo reboot
Enter fullscreen mode Exit fullscreen mode

Reconnect

ssh username@hostname.local
Enter fullscreen mode Exit fullscreen mode

Check the I2C device files

ls /dev/i2c*
Enter fullscreen mode Exit fullscreen mode

If you can see "/dev/i2c-1", the setup has worked correctly.

That's all for initial configuration for the Pi.
Next time, I will connect the sensor to the Raspberry Pi.

I realized that the sensor I bought requires me to solder the sensor pins using a soldering iron. Next time, I’ll start by soldering them!

Top comments (0)