2025-09-20 14:41:08 +01:00
# DShotRMT - ESP32 RMT DShot Driver
2025-09-09 16:19:57 +01:00
2025-09-20 14:41:08 +01:00
[](https://github.com/derdoktor667/DShotRMT/actions/workflows/ci.yml)
2025-06-12 23:45:48 +01:00
2025-09-20 14:41:08 +01:00
A C++ library for generating DShot signals on ESP32 microcontrollers using the RMT (Remote Control) peripheral. It's designed for both Arduino and ESP-IDF projects, providing a simple and efficient way to control brushless motors.
2025-07-19 15:41:04 +01:00
2025-09-20 14:41:08 +01:00
This library is a rewrite using the modern ESP-IDF 5 RMT encoder API (`rmt_tx.h` / `rmt_rx.h` ) for improved performance and flexibility. The legacy version using the old `rmt.h` API is available in the `oldAPI` branch.
2025-07-19 15:41:04 +01:00
2025-09-20 14:41:08 +01:00
## 🚀 Core Features
2021-06-29 19:05:20 +01:00
2025-09-20 14:41:08 +01:00
- **Multiple DShot Modes:** Supports DSHOT150, DSHOT300, DSHOT600, and DSHOT1200.
- **Bidirectional DShot:** Full support for RPM telemetry feedback.
- **Hardware-Timed Signals:** Precise signal generation using the ESP32 RMT peripheral, ensuring stable and reliable motor control.
- **Simple API:** Easy-to-use C++ class for sending throttle commands and receiving telemetry data.
- **Efficient and Lightweight:** The core library has no external dependencies.
- **Arduino and ESP-IDF Compatible:** Can be used in both Arduino and ESP-IDF projects.
2021-07-26 21:20:49 +01:00
2025-07-19 15:41:04 +01:00
## 📦 Installation
2025-09-07 14:19:52 +01:00
### Arduino IDE
2021-07-26 21:20:49 +01:00
2025-09-20 14:41:08 +01:00
1. Open the Arduino Library Manager (`Sketch` > `Include Library` > `Manage Libraries...` ).
2. Search for "DShotRMT" and click "Install".
3. Alternatively, you can clone this repository or download it as a ZIP file and place it in your Arduino libraries folder (`~/Arduino/libraries/DShotRMT/`).
2025-09-07 14:19:52 +01:00
### PlatformIO
2025-09-20 14:41:08 +01:00
Add the following to your `platformio.ini` file:
2025-09-09 16:19:57 +01:00
```ini
lib_deps =
2025-09-20 14:41:08 +01:00
https://github.com/derdoktor667/DShotRMT.git
2025-09-09 16:19:57 +01:00
```
2025-07-19 15:41:04 +01:00
## ⚡ Quick Start
2021-07-26 21:20:49 +01:00
2025-09-20 14:41:08 +01:00
Here's a basic example of how to use the `DShotRMT` library to control a motor:
2025-09-09 16:19:57 +01:00
2025-09-07 14:19:52 +01:00
```cpp
2025-09-20 14:41:08 +01:00
#include <Arduino.h>
#include <DShotRMT.h>
// Define the GPIO pin connected to the motor ESC
const gpio_num_t MOTOR_PIN = GPIO_NUM_27;
// Create a DShotRMT instance for DSHOT300
DShotRMT motor(MOTOR_PIN, DSHOT300);
void setup() {
Serial.begin(115200);
// Initialize the DShot motor
motor.begin();
Serial.println("Motor initialized. Sending low throttle for 5 seconds...");
// Send a low throttle command for 5 seconds
for (int i = 0; i < 500 ; i + + ) {
motor.sendThrottle(100);
delay(10);
}
Serial.println("Stopping motor.");
motor.sendThrottle(0);
}
void loop() {
// Your main code here
}
2025-09-07 14:19:52 +01:00
```
2021-07-26 21:20:49 +01:00
2025-09-20 14:41:08 +01:00
## 🎮 Examples
2025-07-18 08:31:44 +01:00
2025-09-20 14:41:08 +01:00
The `examples` folder contains more advanced examples:
2023-03-29 21:12:08 +01:00
2025-09-20 14:41:08 +01:00
- **`dshot300`:** A simple example demonstrating how to send DShot commands and receive telemetry via the serial monitor.
- **`web_control`:** A full-featured web application for controlling a motor from a web browser. It creates a WiFi access point and serves a web page with a throttle slider and arming switch.
- **`web_client`:** A variation of the `web_control` example that connects to an existing WiFi network instead of creating its own access point.
2025-06-11 08:29:59 +01:00
2025-09-20 14:41:08 +01:00
### Dependencies for Web Examples
2025-06-11 08:29:59 +01:00
2025-09-20 14:41:08 +01:00
The `web_control` and `web_client` examples require the following additional libraries:
2025-06-12 23:45:48 +01:00
2025-09-20 14:41:08 +01:00
- [ArduinoJson ](https://github.com/bblanchon/ArduinoJson )
- [ESPAsyncWebServer ](https://github.com/ESP32Async/ESPAsyncWebServer )
- [AsyncTCP ](https://github.com/ESP32Async/AsyncTCP )
2025-07-19 15:41:04 +01:00
2025-09-20 14:41:08 +01:00
You can install these libraries using the Arduino Library Manager or by adding them to your `platformio.ini` file:
2025-06-11 08:29:59 +01:00
2025-09-20 14:41:08 +01:00
```ini
lib_deps =
https://github.com/derdoktor667/DShotRMT.git
https://github.com/bblanchon/ArduinoJson
https://github.com/ESP32Async/ESPAsyncWebServer
https://github.com/ESP32Async/AsyncTCP
2025-06-11 08:29:59 +01:00
```
2025-09-20 14:41:08 +01:00
## 📚 API Reference
2025-06-11 08:29:59 +01:00
2025-09-20 14:41:08 +01:00
The main class is `DShotRMT` . Here are the most important methods:
2025-09-04 13:41:05 +01:00
2025-09-20 14:41:08 +01:00
- `DShotRMT(gpio_num_t gpio, dshot_mode_t mode, bool is_bidirectional = false)` : Constructor to create a new DShotRMT instance.
- `begin()` : Initializes the RMT peripheral and the DShot encoder.
- `sendThrottle(uint16_t throttle)` : Sends a throttle value (48-2047) to the motor.
- `sendCommand(uint16_t command)` : Sends a DShot command (0-47) to the motor.
- `getTelemetry(uint16_t magnet_count)` : Receives and parses telemetry data from the motor (for bidirectional DShot).
2025-09-04 13:41:05 +01:00
2025-09-20 14:41:08 +01:00
For more details, please refer to the `DShotRMT.h` header file.
2025-06-11 08:29:59 +01:00
2025-09-07 14:19:52 +01:00
## 🤝 Contributing
2025-09-04 13:41:05 +01:00
2025-09-20 14:41:08 +01:00
Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.
2025-06-11 08:29:59 +01:00
2025-07-19 15:41:04 +01:00
## 📄 License
2025-06-11 08:29:59 +01:00
2025-09-20 14:41:08 +01:00
This project is licensed under the MIT License. See the [LICENSE ](LICENSE ) file for details.