Any little movement of the tape, even me just pushing on the wires a bit, makes the values jump around. See video example at https://www.youtube.com/watch?v=HTOZO6uWa9g.
I attached the schematic and layout I have attached the sensor. Below is the configuration I am using in ESPHome:
Code: Select all
external_components:
- source:
type: local
path: esphome-components/components
wifi:
ssid: MySSID
password: !secret wifi_password
ota:
password: !secret wifi_password
esphome:
name: bucket
comment: Bucket
on_boot:
priority: 600
then:
- light.turn_on:
id: status_pixel
red: 0%
green: 100%
blue: 0%
brightness: 50%
color_mode: RGB
- script.execute: screen_timeout
web_server:
port: 80
esp32:
board: featheresp32-s2
i2c:
sda: SDA
scl: SCL
substitutions:
relay_pin: T10
button_a_pin: T9
button_b_pin: GPIO6
button_c_pin: T5
status_led_pin: T13
status_pixel_pin: GPIO33
etape_pin: T8
status_led:
pin:
number: $status_led_pin
inverted: false
output:
- platform: gpio
pin: $relay_pin
id: relay_output
switch:
- platform: output
id: relay_switch
name: "Relay Output"
output: relay_output
on_turn_on:
then:
- light.turn_on:
id: status_pixel
red: 0%
green: 100%
blue: 0%
color_mode: RGB
effect: "Strobe"
on_turn_off:
then:
- light.turn_on:
id: status_pixel
red: 0%
green: 100%
blue: 0%
color_mode: RGB
effect: "None"
- platform: template
id: keep_screen_on_switch
name: "Keep Screen On"
optimistic: true
restore_state: true
on_turn_on:
then:
- lambda: |-
id(oled).turn_on();
on_turn_off:
then:
- script.execute: screen_timeout
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: $status_pixel_pin
num_leds: 1
name: "Status Pixel"
id: status_pixel
effects:
- strobe:
name: "Strobe"
colors:
- brightness: 50%
red: 50%
green: 0%
blue: 50%
duration: 500ms
- brightness: 0%
red: 50%
green: 0%
blue: 50%
duration: 250ms
font:
- file:
type: gfonts
family: Roboto
id: roboto
size: 16
- file: "fonts/tahoma.ttf"
id: tahoma
display:
- platform: sh1107_i2c
model: "SH1107 64X128"
address: 0x3C
rotation: 90
id: oled
lambda: |-
it.printf(0, 0, id(tahoma), TextAlign::TOP_LEFT, "Level: %.0f%%", id(etape_level).state);
it.printf(0, 20, id(tahoma), TextAlign::TOP_LEFT, "Res: %f", id(etape_resistance).state);
it.printf(0, 40, id(tahoma), TextAlign::TOP_LEFT, "Pump: %s", id(relay_switch).state ? "On" : "Off");
binary_sensor:
- platform: gpio
id: button_b
pin:
number: $button_b_pin
inverted: true
mode:
input: true
pullup: true
on_press:
then:
- lambda: |-
id(oled).turn_on();
- script.execute: screen_timeout
- platform: gpio
id: button_a
pin:
number: $button_a_pin
inverted: true
mode:
input: true
pullup: true
on_press:
then:
- switch.toggle: relay_switch
- script.execute: screen_timeout
script:
- id: screen_timeout
mode: restart
then:
- if:
condition:
switch.is_off: keep_screen_on_switch
then:
- delay: 10s
- lambda: |-
id(oled).turn_off();
sensor:
- platform: resistance
sensor: etape_source
configuration: DOWNSTREAM
resistor: 560Ohm
name: eTape Reading
id: etape_resistance
- platform: adc
id: etape_source
pin: $etape_pin
update_interval: 1s
attenuation: auto
- platform: template
name: "eTape Level"
id: etape_level
lambda: |-
const float etape_min = 1850.0;
const float etape_max = 400.0;
const float etape_range = etape_max - etape_min;
const float etape_percent = (id(etape_resistance).state - etape_min) / etape_range;
if (etape_percent > 1.0) return 100.0;
if (etape_percent < 0.0) return 0.0;
return etape_percent * 100.0;
unit_of_measurement: "%"
accuracy_decimals: 1
update_interval: 1s
logger:
level: DEBUG
Is this normal or is the sensor damaged?