ESPHome Iron Timer - Rotary Encoder and 14 segment LED display. Lambda heavy!

I’ve just published an ESPHome project I’ve been working on to Github.

The intention was to learn about ESPHome rather than being “really necessary”, I mean this could be done pretty simply in Home Assistant.

I’ve called it Iron Timer as it’s designed to turn off your clothes iron after a countdown time selected with a rotary encoder and displayed on a LED display. It’s pretty lambda heavy so might help if that’s your thing. Check it out! https://github.com/patfelst/Iron-Timer-Mk2.

The ugly prototype:

and a block diagram / circuit diagram

The ESPHome yaml config is 290 odd SLOC, you can find it here. Here’s a snapshot of the display code:


display:
  - platform: lcd_ht16k33
    address: 0x70
    update_interval: 1s
    scroll: true
    scroll_speed: 200ms
    scroll_dwell: 10s
    scroll_delay: 5.0
    id: led_display
    lambda: |-
      int encoder = 0;
      int mins = 0;
      int secs = 0;
      //ESP_LOGW("display", "Mode = %d", id(rotary_encoder_mode));
      switch (id(rotary_encoder_mode)) {
        case SET_TIMER_MODE:
          encoder = (int) (id(knob).state * 15.0); // Display in 15 second increments
          // Set countdown timer - just display, don't countdown
          secs = encoder % 60;
          mins = (encoder - secs) / 60;
          if (encoder > 0)
            it.printf("%2d.%02d", mins, secs);
          break;
        case COUNTDOWN_MODE:
          if (id(countdown) > 0 ) {
            id(countdown)--;
            secs = id(countdown) % 60;
            mins = (id(countdown) - secs) / 60;
            if (!id(shutdown_early))
              it.printf("%2d.%02d", mins, secs);
            else {
              // Put an asterix in the first digit as another cue to the user that they requested an immediate end to the countdown
              it.printf("*%1d.%02d", mins, secs);
            }
          }
          break;
        case SET_BRIGHTNESS_MODE:
          it.set_brightness(id(led_brightness));
          it.printf("Brightness %.1f", id(led_brightness));
          break;
        case BOOT_MSG_MODE:
          // This message gets displayed once for 5 seconds after power on
          static int boot_timer = 0;
          if (boot_timer <= 5) {
            boot_timer++;
            it.printf("%s", "Iron Timer");
          }
          else {
            id(rotary_encoder_mode) = SET_TIMER_MODE;
          }
          break;
      }

I hope you find this useful, or at least interesting!

6 Likes

Your post helped me to build a tea timer that lifts the tea bag when the countdown is over. Thanks a lot!

1 Like