too many arguments to function 'hw_timer_t* timerBegin(uint32_t)'

  • ESP32 core 3.x

You may see

error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)'
error: too many arguments to function 'void timerAttachInterrupt(hw_timer_t*, void (*)())'
error: 'timerAlarmWrite' was not declared in this scope; did you mean 'timerWrite'?
error: 'timerAlarmEnable' was not declared in this scope

Why it happens

  • Timer commands changed in ESP32 core 3.x.

How to fix it

  1. timerBegin(0, 80, true) becomes timerBegin(1000000).
  2. timerAttachInterrupt(timer, &fn, true) becomes timerAttachInterrupt(timer, &fn).
  3. timerAlarmWrite(…) plus timerAlarmEnable(…) become timerAlarm(timer, 1000000, true, 0).
  4. Or install ESP32 core 2.0.17.

It worked if: Verify passes and the timer ticks.

Seen in a real run (some lines are close variants of it). Produced with Arduino CLI 1.5.1 and ESP32 core 3.1.3. Sources: Arduino ESP32: moving from 2.x to 3.0.

Didn't help? Search another error or ask us.