Hello
I am a complete newbie to this, so I need some help with the programming. The project is copied from dronebotworkshop.com/esp32-pwm-fan/ , and when I compile the file in Arduino IDE (newest version), I get the following error message:
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:50:16: error: expected initializer before 'tachISR'
50 | void IRAM_ATTR tachISR() { tachPulseCount = tachPulseCount + 1;
| ^~~~~~~
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:50:16: error: expected initializer before 'tachISR'
50 | void IRAM_ATTR tachISR() { tachPulseCount = tachPulseCount + 1;
| ^~~~~~~
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino: In function 'void setup()':
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:60:13: error: no matching function for call to 'TwoWire::begin(int, int)'
60 | Wire.begin(4, 5); // SDA=4, SCL=5
| ~~~~~~~~~~^~~~~~
In file included from C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:12:
C:\Users\birkl\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\5.6.0\libraries\Wire\src/Wire.h:50:10: note: candidate: 'virtual void TwoWire::begin()'
50 | void begin() override;
| ^~~~~
C:\Users\birkl\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\5.6.0\libraries\Wire\src/Wire.h:50:10: note: candidate expects 0 arguments, 2 provided
C:\Users\birkl\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\5.6.0\libraries\Wire\src/Wire.h:52:10: note: candidate: 'virtual void TwoWire::begin(uint8_t)'
52 | void begin(uint8_t address) override;
| ^~~~~
C:\Users\birkl\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\5.6.0\libraries\Wire\src/Wire.h:52:10: note: candidate expects 1 argument, 2 provided
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:77:3: error: 'ledcAttach' was not declared in this scope
77 | ledcAttach(PWM_PIN, PWM_FREQ, PWM_RESOLUTION);
| ^~~~~~~~~~
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:85:52: error: 'tachISR' was not declared in this scope
85 | attachInterrupt(digitalPinToInterrupt(TACH_PIN), tachISR, FALLING);
| ^~~~~~~
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:88:3: error: 'ledcWrite' was not declared in this scope
88 | ledcWrite(PWM_PIN, 0);
| ^~~~~~~~~
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino: In function 'void loop()':
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:153:5: error: 'ledcWrite' was not declared in this scope
153 | ledcWrite(PWM_PIN, pwmValue);
| ^~~~~~~~~
C:\Users\birkl\OneDrive\Dokumenter\Arduino\Tempstyret_FAN\Tempstyret_FAN.ino:155:5: error: 'ledcWrite' was not declared in this scope
155 | ledcWrite(PWM_PIN, 0);
| ^~~~~~~~~
exit status 1
Compilation error: expected initializer before 'tachISR'
So what's missing, or what's wrong?
Kind Regards
Klaus K.
ChatGPT seems to think the errors mean you are targeting an RP2040 board?
That earlier error path:
...packages\rp2040\hardware\rp2040\...
means the Arduino IDE is currently targeting an RP2040 board, not your Seeeduino XIAO ESP32-S3.
I would say make sure the code is compatible with the version of the library you are using. If so, then comment things out until it compiles then add things in. You may just want to compile a known working program just to make sure your system is good. Small steps first.
@robotbuilder Hello, Thank you for the reply 😀
That kinda makes sense, I am targeting a RP2040 board because that is what I have at hand, but I have now ordered the Seeeduino XIAO ESP32-S3, and then I will try again.
Kind Regards
Klaus K.
@noweare Hello, Thank you for the reply 😀
I have targeted a RP2040 board, not a Seeeduino XIAO ESP32-S3. I have now ordered the S3 board, and will try again.
Kind Regards
Klaus K.
Problem is now solved.
I was trying to use a RP2040, but that didn't work. I then purchased a genuine Seeed ESP32-S3, and the problem is no longer present, so thank you for the inputs to solve this matter.
"One never stops learning"
Klaus K.