Click to Get FREE shipping in the U.S. on orders over $60!

Getting Started with Relay HAT 2 for Raspberry Pi

Overview

Turta Relay HAT

The goal of this post will be to get you on board and make sure that you have all the resources to keep you going using Relay HAT 2. This process takes about 10 minutes if you already have a Raspbian installed Raspberry Pi. 

Before we get started, it's important to know that our Relay HAT 2 is built to enable developers to control the switch of their high-power electronic appliances up to 5 per HAT. In a nutshell, you can control your lights, your desktop computer's switch, your coffee machine and almost anything else that powers itself from electricity.

Relay HAT 2 is a stackable HAT, that means you can have up to 8 Relay HAT 2 stacked on each other and control 40 electric appliances at the same time with one single Raspberry Pi.

Things you'll need

Getting Started

Once you have your Raspberry Pi and Raspbian OS ready, you will need to establish SSH connection to your Raspberry Pi. (How to connect to Raspberry Pi with SSH ). 

Once connected, you will need to install turta-relayhat2 library. To do that, you are going to use the following command in your Raspberry Pi's terminal

pip3 install turta-relayhat2


This command will install the required library and other dependencies (if any).

This following step will not always be necessary, yet it is important to mention that Relay HAT 2 needs your I2C enabled to be able to run. You can reference to our post to enable I2C on your Raspberry Pi  

Now, you are just one step away from running your first sample for Relay HAT 2.

First Sample

There are 2 ways to get your first sample running.

First way is GitHub samples. If you are familiar with Git, you can find and pull our Turta Relay HAT 2 samples down to your Raspberry Pi and run them as you wish.

or

Second way is to download the following sample code into your Raspberry Pi.

wget https://raw.githubusercontent.com/Turta-io/RelayHAT2/master/Samples/Python/Relay_Control.py
Now, all you have to do is to make sure that your Relay HAT 2 is attached to your Raspberry Pi and then you'll run the following code to see the result.
python3 Relay_Control.py

Once you run the code, you should be able to see your Relay HAT 2 functioning.

Before I end this post, I invite you to check our Raspberry Pi HATs Using our HATs, you will be able to create a variety of different IoT projects within hours using your Raspberry Pi.

  • You can create your own smart home
  • You can build your own smart IoT hub where you measure air quality, temperature and humidity level.
  • Setup long distance (5 to 15 kilometers), no subscription requiring communication network using our LoRa HAT.
  • Even create your own security hub that can detect motion and notify you!

Scenarios are endless, the sky is the limit!

Leave a comment

Please note, comments must be approved before they are published

x