Board Port: ESP32-C3-DevKit-RUST-1
Introduction
The ESP32-C3-DevKit-RUST-1 is a development board that offers a wide range of features, including integrated temperature, humidity, and accelerometer sensors. In this article, we will explore how to port the existing code to this board, which has been successfully done by Harry, a member of the community. We will also discuss the potential ways to support multiple boards simultaneously.
Background
The ESP32-C3-DevKit-RUST-1 board is a variant of the ESP32-C3 microcontroller, which is a low-power, low-cost, and highly integrated system-on-chip (SoC). The board features a range of peripherals, including I2C, SPI, and UART interfaces, as well as a built-in temperature, humidity, and accelerometer sensors. The board is designed to be used with the ESP32-C3-DevKit-RUST-1 development kit, which includes a USB-to-UART bridge and a JTAG interface.
Porting the Code
Harry, a member of the community, has successfully ported the existing code to the ESP32-C3-DevKit-RUST-1 board. The process required almost no code changes, with only a few GPIO pin remapping and the addition of driver crates for the I2C-based sensors. The code changes were minimal, and the existing codebase was able to be reused with minimal modifications.
Adding Driver Crates
To add support for the I2C-based sensors, Harry added the icm42670
and shtcx
driver crates to the project. The icm42670
crate provides a Rust interface to the ICM-42670 accelerometer sensor, while the shtcx
crate provides a Rust interface to the SHTC3 temperature and humidity sensor.
Temperature Snippet
The following code snippet shows how to use the shtcx
crate to measure the temperature and humidity:
// existing function, sensors.rs +44
pub async fn sample_task() {
// comment existing i2c usage, and add:
let mut sht = shtcx::shtc3(i2c);
let mut delay = embassy_time::Delay;
let combined = sht.measure(shtcx::PowerMode::NormalMode, &mut delay).unwrap();
info!(
"Data: {} °C / {} %RH",
combined.temperature.as_degrees_celsius(),
combined.humidity.as_percent()
);
}
Supporting Multiple Boards
One of the challenges of supporting multiple boards is the complexity of the codebase. Without adding complexity, it may not be possible to support multiple boards simultaneously. However, there are a few potential solutions that could be explored:
- Documentation Page: Create a documentation page that outlines the differences between the boards and provides guidance on how to port the code to each board.
- Guide: Create a guide that provides step-by-step instructions on how to port the code to each board.
- Separate Branch: Create a separate branch for each board, which would allow developers to easily switch between boards and test their code.
Conclusion
In conclusion, porting the ESP32-C3-DevKit-RUST-1 board to the existing codebase required minimal code changes and the addition of driver crates for the I2C-based sensors. The process was successful, and the code is now working on the new board. However, supporting multiple boards simultaneously may require additional complexity, and potential solutions include creating a documentation page, guide, or separate branch for each board.
Future Work
Future work could include:
- Adding Support for Additional Boards: Adding support for additional boards, such as the ESP32-C3-DevKit-RUST-2 or the ESP32-C3-DevKit-RUST-3.
- Improving the Codebase: Improving the codebase to make it more modular and easier to maintain.
- Creating a Documentation Page: Creating a documentation page that outlines the differences between the boards and provides guidance on how to port the code to each board.
References
- ESP32-C3-DevKit-RUST-1
- icm42670
- shtcx
- Embassy
Q&A: Porting ESP32-C3-DevKit-RUST-1 Board =============================================
Q: What is the ESP32-C3-DevKit-RUST-1 board?
A: The ESP32-C3-DevKit-RUST-1 is a development board that offers a wide range of features, including integrated temperature, humidity, and accelerometer sensors. It is a variant of the ESP32-C3 microcontroller, which is a low-power, low-cost, and highly integrated system-on-chip (SoC).
Q: What is the process of porting the code to the ESP32-C3-DevKit-RUST-1 board?
A: The process of porting the code to the ESP32-C3-DevKit-RUST-1 board requires minimal code changes and the addition of driver crates for the I2C-based sensors. The existing codebase can be reused with minimal modifications.
Q: What are the I2C-based sensors supported by the ESP32-C3-DevKit-RUST-1 board?
A: The ESP32-C3-DevKit-RUST-1 board supports the ICM-42670 accelerometer sensor and the SHTC3 temperature and humidity sensor. The icm42670
and shtcx
driver crates provide a Rust interface to these sensors.
Q: How do I use the shtcx
crate to measure the temperature and humidity?
A: The following code snippet shows how to use the shtcx
crate to measure the temperature and humidity:
// existing function, sensors.rs +44
pub async fn sample_task() {
// comment existing i2c usage, and add:
let mut sht = shtcx::shtc3(i2c);
let mut delay = embassy_time::Delay;
let combined = sht.measure(shtcx::PowerMode::NormalMode, &mut delay).unwrap();
info!(
"Data: {} °C / {} %RH",
combined.temperature.as_degrees_celsius(),
combined.humidity.as_percent()
);
}
Q: How do I add support for additional boards?
A: To add support for additional boards, you will need to create a new branch for each board and modify the codebase accordingly. You may also need to add new driver crates for the I2C-based sensors supported by each board.
Q: What are the potential solutions for supporting multiple boards simultaneously?
A: There are several potential solutions for supporting multiple boards simultaneously, including:
- Documentation Page: Create a documentation page that outlines the differences between the boards and provides guidance on how to port the code to each board.
- Guide: Create a guide that provides step-by-step instructions on how to port the code to each board.
- Separate Branch: Create a separate branch for each board, which would allow developers to easily switch between boards and test their code.
Q: What is the future work for the ESP32-C3-DevKit-RUST-1 board?
A: Future work for the ESP32-C3-DevKit-RUST-1 board includes:
- Adding Support for Additional Boards: Adding support for additional boards, such as the ESP32-C3-DevKit-RUST-2 or the ESP32-C3-DevKit-RUST-3.
- Improving the Codebase: Improving the codebase to make it more modular and easier to maintain.
- Creating a Documentation Page: Creating a documentation page that outlines the differences between the boards and provides guidance on how to port the code to each board.
Q: Where can I find more information about the ESP32-C3-DevKit-RUST-1 board?
A: You can find more information about the ESP32-C3-DevKit-RUST-1 board on the following websites: