vedatbotuk / zigbee-with-esp32h2

GNU General Public License v3.0
0 stars 0 forks source link

ESP32-H2 Project

This project involves developing an IoT system using the ESP32-H2 microcontroller. Below are instructions for setting up the project, an overview of the hardware, and the build process using the ESP-IDF toolchain. Additionally, Zigpy is integrated for Zigbee protocol support.

Hardware Overview

The system is built around the ESP32-H2, which supports low-power applications and Zigbee connectivity. The primary hardware components include:

More information about ESP32-H2. Below is the pinout diagram for the device:

ESP32-H2 Pinout

Zigpy Integration

Zigpy is a Zigbee protocol stack enabling communication between Zigbee devices, used for wireless networking within the system.

Development Environment Setup

ESP-IDF Installation

To set up the environment for building the project, follow these steps:

  1. Install the necessary dependencies:
    sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
  2. Clone the ESP-IDF repository:
    mkdir -p ~/esp
    cd ~/esp
    git clone -b v5.4-dev --recursive https://github.com/espressif/esp-idf.git
  3. Install the ESP-IDF toolchain:
    cd ~/esp/esp-idf
    ./install.sh esp32h2
  4. Set up the environment variables:
    . $HOME/esp/esp-idf/export.sh

Zigpy Installation

To install Zigpy for Zigbee communication:

pip3 install zigpy

Build and Flash Instructions

Build Process

To build the project for the ESP32-H2, follow these steps:

  1. Set the target for ESP32-H2:
    idf.py set-target esp32h2
  2. Build the project:
    idf.py build

Flashing the Firmware

After building the project, flash the firmware to the ESP32-H2 using:

idf.py flash

Monitor Serial Output

For debugging, monitor the serial output from your ESP32-H2:

idf.py monitor

Automatic Build using GitHub Actions

This project uses GitHub Actions for continuous integration. The build triggers automatically on each push or pull request to the main branch. Key steps in the build process include:

  1. Set up ESP-IDF: Installs the ESP-IDF toolchain and dependencies on the GitHub runner.
  2. Install Zigpy: Installs the Zigpy library for Zigbee communication.
  3. Build the Project: Builds the project using idf.py.

The configuration is specified in the .github/workflows/c-cpp.yaml file.

Project Structure

Signal handlar maping

Sensor or feature Binary value
OTA_UPGRADE 0 or 1
Humidity 0 or 1
Temperature 0 or 1
BATTERY 0 or 1
LIGHT_SLEEP 0 or 1
DEEP_SLEEP 0 or 1
SENSOR_WATERLEAK 0 or 1

For example use a RFD, which suppert temperature, humidity and light sleep. 110100