Adeept Robot HAT for Raspberry Pi

Subsequently to the Serial interface issues, I bought an Adeept Robot HAT from Amazon. I have been keeping an eye on it for a while. The schematics and example code for the Robot Hat are available to download, which means that I can work on utilising the designs in my own hardware solutions.

A basic overview of its peripherals includes:

  • A Type-C USB connector that is used to power the Hat, the Raspberry Pi, and charge the battery.
  • A connector for 2S1P 18650 LiPo batteries to allow for battery operation.
    • There is a battery level meter that also makes use of one of the Analogue Inputs to give the value to the RPi
    • Battery Level indicator: Battery charging indicator light, red light is on when the battery is connected and charging. Green light is on when the battery is not connected or when the battery is fully charged.
  • UART Interface connector, this breaks out one of the UART interfaces on the RPi 40-way connector to a JST header.
  • 2 x RGB LED connectors for connecting common Anode RGB LEDs.
  • An onboard passive buzzer.
  • Two onboard WS2812 LEDs, with an extension port allowing the use of additional WS2812 LEDs
  • 16x Servo ports: Servo interface, baised on an PCA 9685 chip on the I2C port.
  • A port for an MPU6050 Module: I2C interface for installing an MPU6050 module.
  • 6x ADC IN, 6 available Analouge inputs (One isalready assigned, one to the battery monitor)
  • 4x DC Motor hbridges, this is broken out to 4 motor ports M1, M2, M3, M4.

Running the Example Code for the Adeept Robot HAT

The example code is available from Adeept’s repository. Since it is Python, my wife, Tamarisk, is a professional Python programmer, so I take her advice on how best to work with Python code. She recommends UV; I will use UV. My Raspberry Pi is set up following my Basic Linux Setup guide.

$ curl -LsSf https://astral.sh/uv/install.sh | sh

Once we have installed UV, I grabbed the example code from GitHub and initiated the Robot Hat folder with UV.

$ cd ~
$ git clone https://github.com/adeept/Adeept_Robot_HAT-V3.git
$ cd Adeept_Robot_HAT-V3
$ uv init
$ uv run main.py

Running main.py returns the following message1.

Using CPython 3.11.2 interpreter at: /usr/bin/python3.11
Creating virtual environment at: .venv
Hello from adeept-robot-hat-v3!

Tracking down libraries and getting them all working

Now we have the example code; we will find out if we try to run any of them, that some of them will fail to run.

$ uv run 01_Servo.py
Traceback (most recent call last):
  File "/home/pi/Adeept_Robot_HAT-V3/01_Servo.py", line 14, in <module>
    from board import SCL, SDA
ModuleNotFoundError: No module named 'board'

To find the module named board, we need to pull in the Adafruit Circuit Python Motor library. Because we are using UV, installing that is very easy

$ uv add adafruit-circuitpython-motor 

However, now when we run 01_Servo.py again we are greeted with a different error

$ uv run 01_Servo.py
Traceback (most recent call last):
  File "/home/pi/Adeept_Robot_HAT-V3/01_Servo.py", line 14, in <module>
    from board import SCL, SDA
  File "/home/pi/Adeept_Robot_HAT-V3/.venv/lib/python3.11/site-packages/board.py", line 51, in <module>
    from adafruit_blinka.board.raspberrypi.raspi_40pin import *
  File "/home/pi/Adeept_Robot_HAT-V3/.venv/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_40pin.py", line 6, in <module>
    from adafruit_blinka.microcontroller.bcm283x import pin
  File "/home/pi/Adeept_Robot_HAT-V3/.venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 7, in <module>
    from adafruit_blinka.microcontroller.generic_linux.rpi_gpio_pin import Pin
  File "/home/pi/Adeept_Robot_HAT-V3/.venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/rpi_gpio_pin.py", line 6, in <module>
    from RPi import GPIO
ModuleNotFoundError: No module named 'RPi'

RPi seems to be referring to a module called RPi.GPIO, which has been deprecated and replaced with a module called gpiozero, so once I have used the examples to find out how to do what I need to do using the Adeept Robot HAT, I will work with GPIOZero in my own code. At this point, we will grab both. Also, at this point,t I know I will need to grab Adafruit_CircuitPython_PCA9685 as well (in place of the deprecated adafruit_pca9685).

$ uv add RPi.GPIO
$ uv add gpiozero
$ uv add Adafruit_CircuitPython_PCA9685

Running the 01_Servo.py again tells us we need to enable Hardware I2C. This is enabled using raspi-config. The RasPi Config tool needs to be run as sudo. If you want to avoid typing the password when using the sudo command, I have written an article on how to avoid needing to do this: Passwordless Sudo.

$ sudo raspi-config

Navigate to “3 Interface Options” ⟫ “I5 I2C” and then select <YES> to the question “Would you like the ARM I2C interface to be enabled?”

Screenshot of I2C in Raspi-Config
Screenshot of I2C in Raspi-Config question “Would you like the ARM I2C interface to be enabled?”

Testing with a Servo

once we have the pre-requists installed, we can now try again to get the first example working, running 01_Servo.py with a servo plugged into Channel 0 now works.

I will try out more of the functionality over the next few days and write up some more of the solutions as I find them.

  1. main.py is generated when we run uv init, it is not part of the Adeept example code

Leave a comment

Your email address will not be published. Required fields are marked *

The maximum upload file size: 20 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop files here