Help with class "error: RotaryEncoder' has no member named"

my filament dryer broke so instead of purchasing one decided to make it work with a esp32 laying aroundwith 2 ch relay for the heater and fan, 100k thermister for the heat plate temp and a SHT31 for chamber humidity and temp with a rotary encoder to set temp and timer. but when compiling i keep getting an error

error: 'class RotaryEncoder' has no member named 'begin'

28 | encoder.begin();

error: 'class RotaryEncoder' has no member named 'setMinMax'

29 | encoder.setMinMax(0, 24);

Compilation error: 'class RotaryEncoder' has no member named 'begin'

and i cannot seem to pinpoint why below is the code, any help is appriciated

TIA

#include <Wire.h>
#include <Adafruit_SHT31.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RotaryEncoder.h>

#define NTC_PIN A0
#define HEATER_RELAY 13
#define FAN_RELAY 12
#define ROTARY_PIN1 26
#define ROTARY_PIN2 25
#define MAX_TEMP 33

Adafruit_SHT31 sht31 = Adafruit_SHT31();
Adafruit_SSD1306 display(128, 64, &Wire, -1);
RotaryEncoder encoder(ROTARY_PIN1, ROTARY_PIN2);

float heaterTemp = 0;
float ambientTemp = 0;
float humidity = 0;

void setup() {
  pinMode(HEATER_RELAY, OUTPUT);
  pinMode(FAN_RELAY, OUTPUT);
  Wire.begin();
  sht31.begin(0x44);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  encoder.begin();
  encoder.setMinMax(0, 24);
}

void loop() {
  ambientTemp = sht31.readTemperature();
  humidity = sht31.readHumidity();
  heaterTemp = analogRead(NTC_PIN) * (3.3 / 4095.0) * 100; // Convert to Celsius

  if (heaterTemp < MAX_TEMP) {
    digitalWrite(HEATER_RELAY, HIGH);
    digitalWrite(FAN_RELAY, HIGH);
  } else {
    digitalWrite(HEATER_RELAY, LOW);
    digitalWrite(FAN_RELAY, LOW);
  }

  encoder.tick();
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println("Heater Temp: " + String(heaterTemp));
  display.println("Ambient Temp: " + String(ambientTemp));
  display.println("Humidity: " + String(humidity));
  display.println("Timer: " + String(encoder.getPosition()));
  display.display();
}

In looking at the RotaryEncoder library I see the following public methods:

  • long getPosition();
  • Direction getDirection();
  • void setPosition(long newPosition);
  • void tick(void);
  • unsigned long getMillisBetweenRotations() const;
  • unsigned long getRPM();

I see no begin or setMinMax methods defined. What made you think they existed?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.