Migration from 2.x to 3.0
Introduction
This is a guide to highlight breaking changes in the API and to help the migration of projects from versions 2.X (based on ESP-IDF 4.4) to version 3.0 (based on ESP-IDF 5.1) of the Arduino ESP32 core.
All the examples on the version 3.0.0 were updated to be compatible to the new API. The old examples from the versions below 3.0.0 will be not compatible with the version 3.0.0 or newer releases.
For more information about all changes and new features, check project RELEASE NOTES.
BLE
Changes in APIs
Changed APIs return and parameter type from
std::stringto Arduino styleString.Changed UUID data type from
uint16_ttoBLEUUIDclass.BLEScan::startandBLEScan::getResultsmethods return type changed fromBLEScanResultstoBLEScanResults*.
I2S
The I2S driver has been completely redesigned and refactored to use the new ESP-IDF driver. For more information about the new API, check I2S.
LEDC
The LEDC API has been changed in order to support the Peripheral Manager and make it easier to use, as LEDC channels are now automatically assigned to pins. For more information about the new API, check LED Control (LEDC).
Removed APIs
ledcSetupledcAttachPin
New APIs
ledcAttachused to set up the LEDC pin (mergedledcSetupandledcAttachPinfunctions).timerGetFrequencyused to get the actual frequency of the timer.timerAttachInterruptArgused to attach the interrupt to a timer using arguments.
Changes in APIs
ledcDetachPinrenamed toledcDetach.In all functions, input parameter
channelhas been changed topin.
RMT
For more information about the new API, check RMT.
Removed APIs
_rmtDumpStatusrmtSetTickrmtWriteBlockingrmtEndrmtBeginReceivermtReadData
New APIs
rmtWriteAsyncrmtTransmitCompletedrmtSetRxMinThreshold
Changes in APIs
In all functions, input parameter
rmt_obj_t* rmthas been changed toint pin.rmtInitreturn parameter changed to bool.rmtInitinput parameterbool tx_not_rxhas been changed tormt_ch_dir_t channel_direction.rmtInitnew input parameteruint32_t frequency_Hzto set frequency of RMT channel (as functionrmtSetTickwas removed).rmtWritenow sending data in blocking mode. It only returns after sending all data or through a timeout. For Async mode use the newrmtWriteAsyncfunction.rmtWritenew input parameteruint32_t timeout_ms.rmtLooprenamed tormtWriteLooping.rmtReadinput parameters changed toint pin, rmt_data_t* data, size_t *num_rmt_symbols, uint32_t timeout_ms.rmtReadAsyncinput parameters changed toint pin, rmt_data_t* data, size_t *num_rmt_symbols.rmtSetRxThresholdrenamed tormtSetRxMaxThresholdand input parameteruint32_t valuehas been changed touint16_t idle_thres_ticks.rmtSetCarrierinput parametersuint32_t low, uint32_t highhave been changed touint32_t frequency_Hz, float duty_percent.
SigmaDelta
SigmaDelta has been refactored to use the new ESP-IDF driver. For more information about the new API, check SigmaDelta.
Removed APIs
sigmaDeltaSetupsigmaDeltaRead
New APIs
sigmaDeltaAttachused to set up the SigmaDelta pin (channel is acquired automatically).timerGetFrequencyused to get the actual frequency of the timer.timerAttachInterruptArgused to attach the interrupt to a timer using arguments.
Changes in APIs
sigmaDeltaDetachPinrenamed tosigmaDeltaDetach.sigmaDeltaWriteinput parameterchannelhas been changed topin.
Timer
Timer has been refactored to use the new ESP-IDF driver and its API got simplified. For more information about the new API check Timer.
Removed APIs
timerGetConfigtimerSetConfigtimerSetDividertimerSetCountUptimerSetAutoReloadtimerGetDividertimerGetCountUptimerGetAutoReloadtimerAlarmEnabletimerAlarmDisabletimerAlarmWritetimerAlarmEnabledtimerAlarmReadtimerAlarmReadMicrostimerAlarmReadSecondstimerAttachInterruptFlag
New APIs
timerAlarmused to set up Alarm for the timer and enable it automatically (mergedtimerAlarmWriteandtimerAlarmEnablefunctions).timerGetFrequencyused to get the actual frequency of the timer.timerAttachInterruptArgused to attach the interrupt to a timer using arguments.
Changes in APIs
timerBeginhas now only 1 parameter (frequency). There is an automatic calculation of the divider using different clock sources to achieve the selected frequency.timerAttachInterrupthas now only 2 parameters. Theedgeparameter has been removed.
UART (HardwareSerial)
Changes in APIs
setHwFlowCtrlModeinput parameteruint8_t modehas been changed toSerialHwFlowCtrl mode.setModeinput parameteruint8_t modehas been changed toSerialMode mode.
Functional changes
It is now possible to detach UART0 pins by calling
end()with no previous call ofbegin().It is now possible to call
setPins()beforebegin()or in any order.setPins() will detach any previous pins that have been changed.begin(baud, rx, tx)will detach any previous attached pins.setPins()orbegin(baud, rx, tx)when called at first, will detach console RX0/TX0, attached in boot.Any pin set as -1 in
begin()orsetPins()won’t be changed nor detached.begin(baud)will not change any pins that have been set before this call, through a previousbegin(baud, rx, tx)orsetPin().If the application only uses RX or TX,
begin(baud, -1, tx)orbegin(baud, rx)will change only the assigned pin and keep the other unchanged.