Hi all.
I have to interface a 0-5V analog pressure sensor to ESPHome (AZDelivery ESP32 platform)
I know I must shift the level in the 3.3V domain so I get a level shifter (specifically the TXS0108E sold by AZDelivery: see this link)
I triple check soldering and connection and used a 10K pullup resistor on the OE for the level shifter as required.
I observed this behaviour:
-
I checked the sensor using a voltmeter (no load) and it works correctly on the 0-5V range with linear performances
-
I connect power to the level shifter (VA to 3.3v given by ESPHOME, GND to GND by ESPHOME, VB to 5V used for the sensor. GND was the same for ESPHOME, the level shifter and the pressure sensor)
-
I checked with voltmeter the output of the “low voltage” from the shifter for the channel I used for pressure sensor (again: no load, just voltmeter) It was very precisely converted from the 5V domain to the 3.3V domain and it was really linear.
-
At this point I connect the SAME pin I just measured with volt meter to the GPIO34 of the ESPHOME and suddendly I read 3.3V, disregarding the level of the pressure sensor
This is very strange, it seems that as soon as I attach the ESPHOME pin (which I configured as ADC) it imposes the maximum voltage on the pin and do not use it as input.
Please find hereafter the configuration of my ESPHOME.
Any suggestion is more than welcome, as I do not know what I did wrong.
esphome:
name: "epshome-carico"
friendly_name: ESPHome Carico automatico
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret carico_HA_key
ota:
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
- ssid: !secret wifi_ssid_2
password: !secret wifi_password_2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-6Bda40"
password: !secret ap_password
captive_portal:
sensor:
- platform: adc
pin: GPIO34
#allow_other_uses: True
name: "Lettura analogica"
unit_of_measurement: "V"
attenuation: auto
update_interval: 1s
id: lettura
- platform: copy
source_id: lettura
name: "Lettura pressione"
unit_of_measurement: "atm"
id: conversione
filters:
- round: 1
- calibrate_linear:
method: least_squares
datapoints:
- 0.69 -> 1.0
- 3.00 -> 2.0
on_value_range:
- below: 1.0
then:
- switch.turn_on: relay1
- switch.turn_on: relay2
- above: 1.5
then:
- switch.turn_off: relay1
- switch.turn_off: relay2
switch:
- platform: gpio
pin: GPIO22
inverted: True
name: "Canale 1"
id: relay1
on_turn_on:
then:
- switch.turn_on: relay2
on_turn_off:
then:
- switch.turn_off: relay2
- platform: gpio
pin: GPIO23
inverted: True
name: "Canale 2"
id: relay2
on_turn_on:
then:
- switch.turn_on: relay1
on_turn_off:
then:
- switch.turn_off: relay1