How to connect the pressure sensor (hardware) with Home Assistant using ADS1115 and level converter

This post is mostly created because I had big problems to find adequate information on how to connect the pressure sensor with Home Assistant using ADS1115 and level converter. Since it took me almost a year (most of that time was spent waiting for replacement components) and it was almost impossible to find adequate help in any forum, I decided to use this experience to create a short guide on how I finally got this thing working.

I relied somewhat on the original posts here (thanks):

There are instructions on how to use the pressure sensor without the ADS1115, but I knew that I would need to connect more than one sensor later, and for that purpose, the only option was to use ADS1115 as shown here.

Connection diagram how I added all components is here:

The only guide I found how to connect the pressure sensor to HA was using D1 mini and ADS1115 and level converter. So I started with that, but it seemed completely hopeless. Whatever I tried, the only result was an error: “Found no i2c devices!” and “Communication with ADS1115 failed!”
The only suggestions I got from forums was “it must be a faulty soldering” which in itself was somewhat logical but also ridiculous because looking for a possible hardware error I replaced all the parts, some up to three, some up to eight(!) times. Then every time there should have been exactly the same soldering error, which is already statistically improbable. So the sensor problem was still unresolved.
Finally, after almost a year on the shelf with periodic re-testing, I got it working by simply swapping out the D1 mini for a nodemcu.

What are the conclusions and how are other people trying to most likely get their pressuresensor working.

It is said that there are people who have made the sensor work in such a configuration using the D1 mini. So if you have an extra D1 board it might be worth a try.
However, while trying to solve my problems, I noticed that none of my D1 mini boards actually output more than about 4.5V from the 5V pin. However, since the voltage of the sensor is indicated as 5-12V, I tend to suspect that this was actually the cause of all my problems.
The Nodemcu board that I ended up using outputs exactly 5V from the vu pin, and that actually seemed to solve the problem. However, I cannot guarantee that, for example, some ADS1115 board I used in the meantime was also not faulty. So I recommend - since these are absolutely cheap parts, stock up on more than one before starting, and preferably from different suppliers.
Nodemcu board connection diagram is basically the same as for D1 mini shown here. 3V and GND connect to the corresponding pins on the nodemcu board. Getting the 5V needed to power the sensor depends on your nodemcu board version. I used v3 board and the 5V output there was the VU pin. GPIO14 and GPIO12 worked for me as i2c pins.

The ESPHome yaml I used for the sensor was:

esp8266:
  board: nodemcuv2

i2c:
  sda: GPIO14
  scl: GPIO12
  scan: true
  frequency: 400kHz

ads1115:
  - address: 0x48

sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 4.096
    name: "Waterpressure"
    id: WP
    internal: false
    unit_of_measurement: 'bar'
    accuracy_decimals: 1
    icon: "mdi:gauge"
    update_interval: 2s
    filters:
      - median:
          window_size: 5
          send_every: 5
          send_first_at: 5
      - calibrate_linear:
		  # Map 0.52 (from sensor) to 0 (true value)
          - 0.52 -> 0
          - 1.28775 -> 2.8
      - lambda: |-
          if (x <= 0){      
            return 0;
          } else {
            return x;}
    

# Enable logging
logger:
  level: DEBUG
  logs:
    component: ERROR

You’ll probably need to change the “calibrate_linear” numbers a bit according to your measurements. For this you need an actual pressure dial that is in line with your pipework. To do this, you simply put the log voltage of your sensor and the real bar reading in the “calibrate_linear” line. Dont also forget to check your real 0 value! You can also change bar to psi or whatever unit you want the reading to be in. You can look about calibrate linear function here Sensor Component — ESPHome
Depending of your actual configuration u may also want to change “gain” value. About that it is possible to learn here ADS1115 4-Channel 16-Bit A/D Converter — ESPHome

Two things that you may not need in your yaml are “frequency: 400kHz” and the logger lever. The reason why I used it here was that esphome has a problem with “Component xxxxxx took a long time for an operation” which seems to occur among a very large number of users and which (at the moment) has not been fixed. “frequency: 400kHz” tries to fix this problem. (helps some users) However, if this does not help, the logger should simply be silenced. If you don’t have such a problem, you can safely leave these parts out.

In case anybody is still confused with HA part, if you already have in HA ESPHome running, there’s no need to do anything extra. If the ESPHome log shows the sensor data (the sensor is really working), the sensor itself will appear in HA. Wait minute or so. HA may additionally ask if you want to add a new detected sensor.

I hope this helps someone, and if anyone else has any practical advice or experiences with those pressure sensors, they can definitely share it here for future users.

I tried to see if I could add the same sensor via Tasmota, but unfortunately without success. If someone has succeeded, it would be very cool if a detailed guide for Tasmota could also be added here. Connecting Tasmota should theoretically be easier because it doesn’t involve writing Yaml code, but it could just be that Tasmota (currently) doesn’t support this sensor.

2 Likes

High quality post. I have been wanting to do something similar, but didn’t know where to start. This will definitely get me started. Thank you!

Thank you for publishing the project!
I recreated your project with an ESP32 using this pressure sensor from Aliexpress and it works wonderfully! It’s available for around 10 euros from 5 bar