Skip to content

Commit 075c777

Browse files
bdracoCopilot
andauthored
Add ESP32 Arduino to ESP-IDF migration guide (#5200)
Co-authored-by: Copilot <[email protected]>
1 parent 2662d24 commit 075c777

File tree

1 file changed

+208
-0
lines changed

1 file changed

+208
-0
lines changed

guides/esp32_arduino_to_idf.rst

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
ESP32 Arduino to ESP-IDF Migration Guide
2+
=========================================
3+
4+
.. seo::
5+
:description: Guide for migrating ESP32 devices from Arduino framework to ESP-IDF
6+
:image: esp32.svg
7+
8+
Starting with ESPHome 2026.1.0, the default framework for ESP32 will change from Arduino to ESP-IDF. This guide will help you migrate your existing configurations or make an informed choice about which framework to use.
9+
10+
.. note::
11+
12+
This change only affects ESP32, ESP32-S2, ESP32-S3, and ESP32-C3 variants.
13+
Newer variants (ESP32-C6, ESP32-H2, ESP32-P4, etc.) already default to ESP-IDF
14+
as they have limited or no Arduino support.
15+
16+
Why the Change?
17+
---------------
18+
19+
ESP-IDF (Espressif IoT Development Framework) is the official development framework for ESP32. It offers several advantages:
20+
21+
- **Smaller Binaries**: Up to 40% reduction in binary size
22+
- **Better Performance**: More optimized for ESP32 hardware
23+
- **Custom Builds**: Firmware is built specifically for your device configuration
24+
- **Active Development**: All ESPHome developers use and test with ESP-IDF
25+
- **Latest Features**: New ESP32 features are available in ESP-IDF first
26+
27+
Trade-offs
28+
----------
29+
30+
While ESP-IDF offers many benefits, there are some trade-offs to consider:
31+
32+
- **Compile Times**: Initial compilation takes approximately 25% longer
33+
- **Component Compatibility**: Some components may need to be replaced with ESP-IDF compatible alternatives
34+
- **Library Differences**: Arduino-specific libraries won't be available
35+
36+
Making Your Choice
37+
------------------
38+
39+
Option 1: Migrate to ESP-IDF (Recommended)
40+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
42+
Add the following to your ESP32 configuration:
43+
44+
.. code-block:: yaml
45+
46+
esp32:
47+
board: esp32dev # Your board type
48+
framework:
49+
type: esp-idf
50+
51+
Option 2: Stay with Arduino
52+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
53+
54+
If you prefer to continue using Arduino (which will remain supported), explicitly specify it:
55+
56+
.. code-block:: yaml
57+
58+
esp32:
59+
board: esp32dev # Your board type
60+
framework:
61+
type: arduino
62+
63+
Migration Steps
64+
---------------
65+
66+
1. **Backup Your Configuration**: Always keep a backup of your working configuration before making changes.
67+
68+
2. **Check Component Compatibility**: When you compile with ESP-IDF, ESPHome will automatically notify you if any components are incompatible and suggest alternatives.
69+
70+
3. **Update Your Configuration**: Add the framework specification as shown above.
71+
72+
4. **Clean Build Files**: After changing frameworks, clean your build files:
73+
74+
**Using ESPHome CLI:**
75+
76+
.. code-block:: bash
77+
78+
esphome clean your-config.yaml
79+
80+
**Using ESPHome Dashboard:**
81+
82+
- Click on the three-dot menu for your device
83+
- Select "Clean Build Files"
84+
85+
5. **Compile and Test**: Compile your configuration and test thoroughly:
86+
87+
**Using ESPHome CLI:**
88+
89+
.. code-block:: bash
90+
91+
esphome compile your-config.yaml
92+
esphome upload your-config.yaml
93+
94+
**Using ESPHome Dashboard:**
95+
96+
- Click "INSTALL" on your device
97+
- Choose your preferred upload method (USB, OTA, etc.)
98+
- The dashboard will automatically compile and upload
99+
100+
Common Component Replacements
101+
-----------------------------
102+
103+
When migrating to ESP-IDF, you may need to replace some components. ESPHome will automatically suggest alternatives when available:
104+
105+
**Components with ESP-IDF Alternatives:**
106+
107+
.. list-table::
108+
:header-rows: 1
109+
:widths: 50 50
110+
111+
* - Arduino Component
112+
- ESP-IDF Alternative
113+
* - :doc:`bme680_bsec </components/sensor/bme680_bsec>`
114+
- :doc:`bme68x_bsec2 </components/sensor/bme68x_bsec2>`
115+
* - :doc:`fastled_clockless </components/light/fastled>`
116+
- :doc:`esp32_rmt_led_strip </components/light/esp32_rmt_led_strip>`
117+
* - :doc:`fastled_spi </components/light/fastled>`
118+
- :doc:`spi_led_strip </components/light/spi_led_strip>`
119+
* - :doc:`neopixelbus </components/light/neopixelbus>`
120+
- :doc:`esp32_rmt_led_strip </components/light/esp32_rmt_led_strip>`
121+
122+
**Arduino-Only Components:**
123+
124+
The following components currently require Arduino framework and don't have ESP-IDF alternatives yet:
125+
126+
- :doc:`ac_dimmer </components/output/ac_dimmer>` - AC dimmer control
127+
- :doc:`dsmr </components/sensor/dsmr>` - Dutch Smart Meter integration
128+
- :doc:`heatpumpir </components/climate/climate_ir>` - IR-based heat pump control
129+
- :doc:`midea </components/climate/midea>` - Midea air conditioner control
130+
- :doc:`WLED Effect </components/light/index>` - WLED UDP Realtime Control integration
131+
132+
If you need these components, you should continue using the Arduino framework.
133+
134+
.. note::
135+
136+
Component compatibility is constantly improving. Check the component documentation
137+
or try compiling with ESP-IDF to see if alternatives have become available.
138+
139+
Troubleshooting
140+
---------------
141+
142+
Compilation Errors
143+
^^^^^^^^^^^^^^^^^^
144+
145+
If you encounter compilation errors after switching to ESP-IDF:
146+
147+
1. Check the error message for component compatibility issues
148+
2. Look for suggested alternatives in the error output
149+
3. Clean your build files and try again
150+
4. Check the component documentation for ESP-IDF specific notes
151+
152+
Build Time
153+
^^^^^^^^^^
154+
155+
ESP-IDF compilation takes approximately 25% longer than Arduino:
156+
157+
- On modern desktop systems: ~15-30 seconds additional time
158+
- On Raspberry Pi 5: ~1 minute additional time
159+
- On Raspberry Pi 4 or older: 3-5 minutes additional time
160+
- Subsequent builds are faster but still proportionally slower
161+
- The longer build time is due to ESP-IDF's more comprehensive optimization process
162+
163+
Performance Considerations
164+
^^^^^^^^^^^^^^^^^^^^^^^^^^
165+
166+
ESP-IDF generally offers better performance, but:
167+
168+
- Initial boot time might be slightly different
169+
- Some timing-sensitive operations may need adjustment
170+
- WiFi and Bluetooth behavior might have subtle differences
171+
172+
Frequently Asked Questions
173+
--------------------------
174+
175+
**Q: Will Arduino framework be removed?**
176+
A: No, Arduino framework will continue to be supported. Only the default is changing.
177+
178+
**Q: Do I have to migrate immediately?**
179+
A: No, but you should explicitly specify your framework choice to avoid the automatic change in 2026.1.0.
180+
181+
**Q: Can I switch back to Arduino if ESP-IDF doesn't work for me?**
182+
A: Yes, you can switch between frameworks at any time by changing your configuration.
183+
184+
**Q: Will my existing devices be affected?**
185+
A: Only when you recompile. Devices already running will continue to work as before.
186+
187+
**Q: How do I know which framework my device is currently using?**
188+
A: Check your device's log output during boot, or look at your configuration file.
189+
190+
Getting Help
191+
------------
192+
193+
If you encounter issues during migration:
194+
195+
1. Check the `ESPHome Discord <https://discord.gg/KhAMKrd>`__ for community support
196+
2. Review component-specific documentation
197+
3. Search existing `GitHub issues <https://github.com/esphome/esphome/issues>`__
198+
4. Create a new issue if you find a bug
199+
200+
Remember, the migration is optional, and both frameworks will continue to be supported. Choose the option that best fits your needs!
201+
202+
See Also
203+
--------
204+
205+
- :doc:`/components/esp32`
206+
- :doc:`/guides/faq`
207+
- `ESP-IDF Documentation <https://docs.espressif.com/projects/esp-idf/>`__
208+
- `Arduino-ESP32 Documentation <https://docs.espressif.com/projects/arduino-esp32/>`__

0 commit comments

Comments
 (0)