SKU_DFR0918_Raspberry_Pi_GPIO_Terminal_Block_HAT-DFRobot

Introduction

This terminal block expansion hat for Raspberry Pi 4B offers stable and reliable connections for your projects.
All GPIO pins are broken out to terminal blocks. The terminal block is labeled with high-quality color silkscreens, clear and durable. Besides, it has onboard level indication LEDs for corresponding pins below the blocks, which allows users to directly view the pin status when operating GPIO so as to conveniently do testing, debugging, and post-maintenance.

Features

Parameter

Dimension Diagram

Board Overview

Specification

Description

The on-board LED indicators of CE0, CE1, SDA1, SCL1, RXD, TXD, I022, IO21, SDA0, SCL0, 3.3V and 5V are default to be on.

Raspberry Pi Pin Description

This product adopts BCM pin mapping labeling.

Tutorial

1. GPIO Example

This example uses the on-board LED for LED blinking demonstration.

import time
from traceback import print_list
import RPi.GPIO as GPIO

pin_list=[4,27,21,13,26,23,22,12,20,19,24,25,16,5,6,17,18,10,9,11,8]
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin_list,GPIO.OUT)
GPIO.setwarnings(False)

while True:
  GPIO.outp(pin_list,GPIO.LOW)
  time.sleep(0.5)
  GPIO.output(pin_list,GPIO.HIGH)
  time.sleep(0.5)

2. I2C Example

This example uses the SEN0405 acceleration sensor for demonstration. Click LIS library download address to download the sample codes of the acceleration sensor. Select the program in the example -> LIS2DW12 folder.

Connection Diagram:

#include <DFRobot_LIS2DW12.h>

DFRobot_LIS2DW12_I2C acce;

void setup(void){

  Serial.begin(9600);
  while(!acce.begin()){
     Serial.println("Communication failed, check the connection and I2C address setting when using I2C communication.");
     delay(1000);
  }
  Serial.print("chip id : ");
  Serial.println(acce.getID(),HEX);
  acce.softReset();
  acce.continRefresh(true);
  acce.setDataRate(DFRobot_LIS2DW12::eRate_50hz);
  acce.setRange(DFRobot_LIS2DW12::e2_g);
  acce.setFilterPath(DFRobot_LIS2DW12::eLPF);
  acce.setFilterBandwidth(DFRobot_LIS2DW12::eRateDiv_4);
  acce.setPowerMode(DFRobot_LIS2DW12::eContLowPwrLowNoise2_14bit);
  Serial.print("Acceleration:\n");
  delay(100);
}

void loop(void){
    Serial.print("x: ");
    Serial.print(acce.readAccX());
    Serial.print(" mg \ty: ");
    Serial.print(acce.readAccY());
    Serial.print(" mg \tz: ");
    Serial.print(acce.readAccZ());
    Serial.println(" mg");
    delay(300);
}

Result:

3. SPI Example

This example uses the SEN0405 acceleration sensor for demonstration.

Connection Diagram:

#include <DFRobot_LIS2DW12.h>

DFRobot_LIS2DW12_SPI acce(/*cs = */LIS2DW12_CS,&SPI);
//DFRobot_LIS2DW12_SPI acce(/*cs = */LIS2DW12_CS);

void setup(void){

  Serial.begin(9600);
  while(!acce.begin()){
     Serial.println("Communication failed, check the connection and I2C address setting when using I2C communication.");
     delay(1000);
  }
  Serial.print("chip id : ");
  Serial.println(acce.getID(),HEX);
  acce.softReset();
  acce.continRefresh(true);
  acce.setDataRate(DFRobot_LIS2DW12::eRate_50hz);
  acce.setRange(DFRobot_LIS2DW12::e2_g);
  acce.setFilterPath(DFRobot_LIS2DW12::eLPF);
  acce.setFilterBandwidth(DFRobot_LIS2DW12::eRateDiv_4);
  acce.setPowerMode(DFRobot_LIS2DW12::eContLowPwrLowNoise2_14bit);
  Serial.print("Acceleration:\n");
  delay(100);
}

void loop(void){
    Serial.print("x: ");
    Serial.print(acce.readAccX());
    Serial.print(" mg \ty: ");
    Serial.print(acce.readAccY());
    Serial.print(" mg \tz: ");
    Serial.print(acce.readAccZ());
    Serial.println(" mg");
    delay(300);
}

Result:

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents