This tutorial will guide you on how to install the Home Assistant Operation System on your Raspberry Pi and enable I2C. This will allow you to use our ADC Pi and IO Pi Plus development boards, as well as many other I2C devices with Home Assistant.
First, we must set up a microSD card with the Home Assistant Operation System.
You will need the following items:
- Raspberry Pi. Model 3 or later.
- Power Supply for the Raspberry Pi
- Micro SD Card. Ideally, a 32 GB card or larger.
- SD Card Reader
- Ethernet Cable
Optional: An IO Pi Plus to add additional GPIO channels or an ADC Pi to add analogue inputs to Home Assistant.
Installing the Home Assistant Operating System
To install the Home Assistant Operating system onto your Raspberry Pi you can use the Raspberry Pi Imager on Windows, MacOS or Ubuntu
Writing the OS image to your SD card
- Download and install the Raspberry Pi Imager on your computer as described under https://www.raspberrypi.com/software/.
- Insert the SD card into your Micro SD Card reader and connect it to your computer.
- Open the Raspberry Pi Imager software and select your Raspberry Pi.
- Select the operating system:
- Select Choose OS
- Select Other specific-purpose OS > Home Assistants and Home Automation > Home Assistant.
- Choose the Home Assistant OS that matches your Raspberry Pi, i.e., RPi 3 or RPi 4.
- Click Choose Storage and select your SD card.
- Write the image to your SD card by clicking the “Next” button and wait for the file to be transferred to your card.
- When the transfer has been completed, close the Raspberry Pi Imager software.
How to Enable I2C
Before you can use any I2C devices, you need to enable I2C for the Home Assistant Operating System and then set up your I2C devices, such as sensors or GPIO expanders.
You need to access the boot partition on your SD card with the Home Assistant Operating System installed on it. If Home Assistant is running, shut down your Home Assistant system, unplug the SD card, insert the card into your card reader and connect it to your computer.
The card will mount as a drive or file system called hassos-boot.
You must create two new folders and add and edit config files to enable I2C.
In the root of the hassos-boot partition, add a new folder called CONFIG.
In the CONFIG folder, add another new folder called modules.
Inside the modules folder, add a text file called rpi-i2c.conf with the following content:
i2c-dev
In the root of the hassos-boot partition, edit the file called config.txt and add two lines to it at the end of the file:
dtparam=i2c_vc=on dtparam=i2c_arm=on
Unmount or disconnect the card reader, insert the SD card into your Raspberry Pi and reconnect the power to turn it on.
If this is the first boot of your new Home Assistant Operation System, you will be taken through the onboarding process where you set up user accounts, location and other preferences.
Using a web browser on your desktop system you will be able to reach your new Home Assistant at homeassistant.local:8123 or the IP address of your Raspberry Pi and port 8123
During the first boot it can take over 20 minutes for the operating system to load and configure so don't be concerned if nothing happens for a long time.
When the operating system starts, the hassos-config.service will automatically process the new rpi-i2c.conf configuration.
Another reboot might be necessary to ensure the imported rpi-i2c.conf is present at boot time.
I2C will now be enabled and available for you to connect sensors or development boards to your Raspberry Pi.