Hi all!
Absolutely new to all this, but I’ve run into an issue that Google can’t seem to help me with, or maybe I’m just not phrasing it correctly…
I’m playing around in ESPHome with an ESP32, a 28BYJ-48 stepper, and a display showing the current time. My stepper worked just fine until I added the code for the display (adding I2C, real-time-clock, fonts, etc). After adding all this, my stepper runs in intervals. Running for close to a second, then stops, then goes again, then stops, and so on, until it reaches its target.
Removing all the code except for the stepper functionality, resolves the issue, and the motor runs smoothly again.
Any takers? I might just be messing something up
Code:
#include <real_time_clock.h>
esphome:
name: stepper-test
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
level: INFO
i2c:
sda: 21
scl: 22
# Enable Home Assistant API
api:
encryption:
key: "XXX"
services:
- service: control_stepper
variables:
target: int
then:
- logger.log: "Speed updated"
- stepper.set_target:
id: my_stepper
target: !lambda 'return target;'
ota:
password: "XXX"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
#ap:
# ssid: "Stepper-Test Fallback Hotspot"
# password: "XXX"
#captive_portal:
time:
- platform: sntp
id: esptime
font:
- file: "gfonts://Roboto"
id: Roboto
size: 26
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
reset_pin: 0
address: 0x3C
lambda: |-
it.strftime(64, 32, id(Roboto), TextAlign::CENTER, "%H:%M:%S", id(esptime).now());
number:
- platform: template
name: Stepper Control
min_value: -5000
max_value: 5000
step: 10
set_action:
then:
- stepper.set_target:
id: my_stepper
target: !lambda 'return x;'
# Example configuration entry
stepper:
- platform: uln2003
id: my_stepper
pin_a: 27
pin_b: 26
pin_c: 33
pin_d: 32
max_speed: 100 steps/s
step_mode: HALF_STEP
# Optional:
acceleration: 100
deceleration: 100