Authors:
Umer Asghar
Nooney Naga Sai Dharani Kumari
Raspberry Pi is a very general purpose yet very popular in developing IoT projects. The very first step is to setup the Raspberry Pi device with a developer friendly environment using Python and one easily gets lost in the ocean of available public blogs in the internet. In this multi-part blog, we will show you how to setup the Raspberry Pi device and use it for further for successful integration and development on AWS Cloud. For this blog purposes, we will show how to integrate a DHT11 Sensor (Temp and Humidity Sensor) with Raspberry Pi and push the data into AWS Cloud.
Device model used: Raspberry Pi 5.
It is assumed here that you have the Raspberry Pi 5 device, installed with Raspberry Pi OS. For further reading you can refer https://www.raspberrypi.com/software/
Setting up a Raspberry Pi for IoT projects requires careful configuration of various components and libraries. This guide walks through the essential steps to prepare your Raspberry Pi.
Configuring Hardware Interfaces
Enable necessary hardware interfaces in Raspberry Pi configuration:
Installing Required Python Libraries
Install essential Python libraries for hardware interaction:
# Adafruit Libraries
sudo pip3 install adafruit-blinka --break-system-packages
sudo pip3 install adafruit-circuitpython-mcp3xxx --break-system-packages
sudo pip3 install adafruit-circuitpython-ads1x15 --break-system-packages
sudo pip3 install adafruit-charlcd --break-system-packages
sudo pip3 install RPLCD --break-system-packages
# AWS IoT SDK
pip3 install AWSIoTPythonSDK --break-system-packages
python3 -m pip install awscrt --break-system-packages
# DHT Sensor Library
pip3 install adafruit-circuitpython-dht --break-system-packages
sudo apt-get update
sudo apt-get install libgpiod2
GPIO Setup
Configure GPIO permissions:
sudo mknod /dev/gpiomem c 243 0
sudo chmod 660 /dev/gpiomem
sudo chown root:gpio /dev/gpiomem
Key Components Installed
This setup includes support for:
-
ADC (Analog-to-Digital Converter) via MCP3xxx
-
LCD Display support
-
DHT11 temperature and humidity sensors
-
AWS IoT connectivity
-
GPIO access for sensors and actuators
Important Notes
-
The "--break-system-packages" flag is used because we're installing packages system-wide
-
Make sure to reboot your Raspberry Pi after making configuration changes
-
Verify that all interfaces are properly enabled through:
-
Test each component individually before proceeding with the full project setup
Next Steps
After completing this setup, your Raspberry Pi will be ready for:
-
Connecting sensors
-
Reading analog data through ADC
-
Displaying information on LCD
-
Communicating with AWS IoT Core
-
Running your IoT application
This configuration provides a solid foundation for building an IoT-based system with AWS integration.
Bonus Topics:
1- Connecting Raspberry PI device:
You can access a Raspberry Pi using a monitor, keyboard and mouse.
Remote Connection:
Sometime you need to access a Raspberry Pi without connecting it to a monitor, keyboard, and mouse. Perhaps the Raspberry Pi is embedded in a robot or mounted in an inconvenient location. Or maybe you don’t have a spare monitor.
To remotely control your Raspberry Pi from another device on your local network, use one of the following services:
1- SSH
2- VNC
Remote Raspberry Pi Connect
In case your Raspberry PI device is not in your network you can still access it using Raspberry PI connect service. This service allows you to remotely connect to your Raspberry Pi.
Below are the steps for configuration of RPI connect services.
1- sudo apt install rpi-connect. ## install package
2- rpi-connect on ## enable remote connect to on
3- rpi-connect signin ## Sign-if remote connect
4- Complete the sign-up on laptop / mobile
5- loginctl enable-linger ## if you want rpi-connect to run during boot, else after device boot rpi-connect will be disabled
6- Enable MFA from (https://connect.raspberrypi.com)
Some useful commands:
rpi-connect signin ## sign-in to remote pi device
rpi-connect signout ## sign-off to remote pi device
rpi-connect on ## Enable remote connect
rpi-connect off ## disable remote connect
rpi-connect vnc on ## enable VNC on remote connect
rpi-connect vnc off ## disable VNC on remote connect
rpi-connect shell on ## enable shell on remote connect
rpi-connect shell off ## disable VNC on remote connect
rpi-connect status ## check status of connections
2- Useful Raspberry PI command:
sudo i2cdetect -y 1 (use sudo)
This service scans an I2C bus for devices and displays the I2C addresses of the devices connected to the specified bus.
gpioinfo
gpioinfo is a tool to print information about all lines of the specified GPIO chip(s)
pinout
On a Raspberry Pi 5, the pinout command is a utility that displays a visual representation of the GPIO (General Purpose Input/Output) pins, their numbers, and functions, providing a quick reference for the pinout diagram.
pinctrl
On a Raspberry Pi 5, pinctrl is a command-line tool that provides direct access to the GPIO (General Purpose Input/Output) pins, allowing you to display and modify their state, bypassing the kernel drivers, and is designed as a replacement for the older raspi-gpio tool.
lsusb
On a Raspberry Pi 5 (or any Linux system), the lsusb command is a tool used to list and display information about USB devices connected to the system, including bus and device numbers, vendor IDs, and product IDs.
raspi-config
On a Raspberry Pi 5, raspi-config (use sudo) is a pre-installed configuration tool that provides a simple command-line interface to manage various system settings, allowing users to easily customize and optimize their system.