Hello guys!!
I’m looking for a solution to my problem.
I want my stepper motor to move according to the temperature values which are generated by a temp. sensor (bmp280). The whole thing is supposed to simulate a round thermometer (temps between 0C° and 50C°).
The process has to be initiated by a button click.
I have wired up everything and the components are working properly.
needless to say, I’m a noob.
here is my code so far.
esphome:
name: stepper1
platform: esp8266
board: nodemcu
on_boot:
- stepper.report_position:
id: mot1
position: 0
- stepper.set_target:
id: mot1
target: 0
- stepper.set_target:
id: mot1
target: 512
- delay: 10s
- stepper.set_target:
id: mot1
target: 0
wifi:
ssid: "#"
password: "#"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Fallback Hotspot"
password: "f5ffddiF0ckjvd84r7h"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
i2c:
sda: D2
scl: D1
scan: True
id: bus_a
stepper:
- platform: uln2003
id: mot1
pin_a: D0 # On Controllers pin: IN1 WHITE
pin_b: D1 # On Controllers pin: IN2 VIOLETT
pin_c: D3 #On Controllers pin: IN3 BLUE
pin_d: D4 # On Controllers pin: IN4 BROWN
max_speed: 250 steps/s
sleep_when_done: true
acceleration: inf
deceleration: inf
binary_sensor:
- platform: gpio
name: "Button"
pin:
number: D7
inverted: True
mode: INPUT_PULLUP
sensor:
- platform: bmp280
temperature:
name: "Temperature"
oversampling: 16x
pressure:
name: "Pressure"
address: 0x76
update_interval: 10s
- platform: template
name: "Random Values"
id: random_sensor
unit_of_measurement: "Steps"
lambda: |-
return rand() % 2048;
update_interval: 5s
on_value:
- stepper.set_target:
id: mot1
target: !lambda "return x;"
- logger.log: "A new value is generated"