ESPHome with M5 Stack Tube pressure sensor
Device documents: https://docs.m5stack.com/en/unit/tube_pressure
This device returns a linear voltage (0.1 - 3.1v) based on the pressure. This allows us to use the generic ADC device with EPShome. Due to the limited voltage range of the adc, you have to use the attentuate feature. I used attenuate: auto
and it worked fine.
I used a lambda function to convert the voltage to pressure (kPA) and to psi. The divide by 6.89... is the psi conversion.
Then I round it to one decimal place.
I added a device class of pressure and unit_of_measurement of psi.
I have the update interval set pretty fast. IRL, I will set that to ~30s
Here is the config yaml file:
esphome:
name: pressure-1
friendly_name: pressure_1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "******************************"
ota:
password: "******************************"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Pressure-1 Fallback Hotspot"
password: "*****************"
captive_portal:
sensor:
# m5 stack tube pressure sensor (https://docs.m5stack.com/en/unit/tube_pressure)
- platform: adc
pin: 32
name: "Tube pressure"
unit_of_measurement: "psi"
device_class: pressure
update_interval: 1s
attenuation: auto
filters:
- lambda: return ((x - 0.1) / 3.0 * 300.0 - 100.0) /6.89475729;
- round: 1