Water pressure sensor for central heating

Hi Bart,

first choose you adc. The internal ADC might sound nice (one less component) but what I read not very precise, slow and some other flaws. I use ESP8266s and the adc there is bad. The ADS1115 is nice, cheap (cheaper than a fried ESP32 and cheaper than a PI) , versatile.
Don't worry the is not much that can go wrong in all cases.

internal ADC

you might want to use the one of the 2 ADC(s) (muliplexed to up to 18) of your ESP32. Then you will need a voltage devider.(two resistors) to meet the voltage levels from the 0-5V to 0-3.3V (on an ES8266 you only have one ADC 0-1V often with build in voltage devides to 0-3.3V)

So for the 0-5 V you need something like this

image

Where R1 = 1K and R2 = 2K
or do the calculation here (Voltage divider: calculator and application – Renzo Mischianti)

Chose values over 1K because you will drain permanently some current via the two resistors (important to know if you run from batteries)

external ADC

Or you might use an extranal ADC like the ADS1115 with 4 ADCs 16Bit resuluton, configurable amplifier and .... (I love this, cheap, accurate versatile) and read it via I2C (Hey I found the correct schematic).

Power the ADC with 5V! (then the maximum voltage on the analog pins is 0.3V over the supply voltage! So absolute save. Plugging in an USB charger (1A) and leave away the power jack is perfect.

There is no protection on the input pins ... so be a little bit careful!

There is an software controlled amplifier on all input pins (very handy)

image

But with the wrong settings you might be able destroy the adc too!

image

But the default is save no worries.

And don't worry about the 5V on SDA (and ALERT/RDY)... the ESP32 can handle this

If you have more than one i2c device on your bus you need pull up resistors (common 4.7K) to +5V. But not for only one device.

And last but not least choose your firmware

A) Homebrew (you can start with my own if you don't want to start from scratch including full homie convention support, ota updates via mqtt ... detailed logging via serial and syslog) But I will have to upgrade it to ES32 as currently only ESP8266s are supported. No problem a task on my backlog since ages.
B) One of the Swiss army knives like Tasmota, esphome ..... (I can't help here because I don't use them any more)

Calibration

you will receive a 16bit figure of the voltage range choosen (by the amplifier)

Best is to have a pressure meter for reference (your build in bight do). Or do it without units and determine the desired value and the value when you like to fire an alarm.

To get values in the units you desire (and don't fly to mars) you need two reference points measured and the corresponding voltages and do the math. Best is something like 1 and 2 Bars (0 might be inaccurate. (all above normal pressure before somebody start to split hairs here).

But you have to lower the pressure of your heating circulation (or raise it to max. 3 Bar and lower it later to normal 2 Bar or go down to 1 to get the maximum precision) .... :wink: Have fun ...

2 Likes

Well you could use 1K and 2K to get to 3.33V which is close enough.

I doubt you need to be so accurate for your purpose, as will know if the pressure is dropping over time.

1 Like

Hey ... so many posts during me writing all this :wink: Have fun over the weekend :wink:

BTW my firmware triggers messages not only by time. You can define a delta value between faster samples to increase the frequency if necessary (and an regular intervals). I needed this to protect my pump where a regular interval might come "too later"

1 Like

To be fair there are all sorts of rules etc that can be setup in Tasmota, to fire actions based on some event eg low pressure reading etc. :wink: (more commssion ha ha ..)

1 Like


Prototype of multi sensor, waiting for 3d print of nicer box :wink:

3 Likes

Hi Bart,
I'll check out the situation with the analogue input to an ESP-32. Certainly on the Wemos D1 Mini there is an additional resistor (network) to allow a max input of 3.3V. I would have thought the ESP32 would have the same input mechanisim - I'll check the data-sheets and get back to you.

It looks like you have created quite an interest from the forum in your project.

1 Like

I don't wanted to say that any "of the shelf" firmware can do that.

I love to have complete control of my micro. At that time I could not have 130k+ RAM left over with a fully configured multi sensor node and supporting the homie convention and running on ESP8285 a 1MB device too with OTA ... And to have fun;)

Ok the internal ADC seems to be 12bits, while the ADC1115 has 16 bits. Not sure at the moment how much I need. I assume it depends also on the precision and the noise of the sensor itself. I assume for my purpose 12 bits is enough, because 2^12=4096 different value seems quite a lot for my pressure of my radiators hot water pressure measurements. But I might be mistaken...

Yes indeed that is something I was wondering also. Don't know if @dynamicdave has somehow taken into account the impedance of the sensor itself, but not sure at all if that is required?

Can you please explain that a bit more?

Is that both valid for the ESP32 and the ADC1115? And is there any easy way to add some protection?

Good to know!!

@dynamicdave,
Can you explain how you calculate that value please? And then my ESP is protected during most common circumstances I assume....

You can actually get a 3.3v diode zener-diode-3-3v that would allow you to use a larger range, this link also has a good explanation of how it works in this case.

1 Like

Ok last question for today. Much too late again...
I was looking for some ESP32 development boards on Aliexpress, but there are a lot of different types. And I see some reviews that they have bought clones with bad drivers and so on...
Would be nice if somebody could share a link to esp's that are ok to buy...

I got 3 of these - esp32 , like you I wasn't sure about getting them from china, also didn't want to wait ages :wink:
They work fine with Tasmota.

If it is just for the boiler sensor then you could use a cheaper wemos D1 mini, they have less I/O pins but you only need the 1 analog D1 mini

Bart if you are going to order the sensors etc from ALixexpres then i would suggest you get some ESP8266 as well - the libraries for things like Tasmota and EspEasy, ESPHome are much more developed and bug tested on those chips than the newly support ESP32.

The cost of a Wemos D1 mini or a ESP2866 Dev board is nearly nothing nowadays.

Craig

2 Likes

To answer some of the questions above.

Here's how to calculate the division ratio for a voltage-divider.
vi-div-calc
As you can see the formula is R2 divided by the sum of R1 + R2.
If R1 and R2 have the same resistance value, then it's a 2:1 divider.
The trick is finding suitable values for the resistors using the preferred range of resistors.
As mentioned in the above thread, you need to take the impedance of the transducer into account as you don't what to load it - as that would affect the results. Probably use 10K resistors in this situation.

I must have 40 or more Wemos D1 Minis (for my students), most of them flashed with ESPeasy, others with C++ using Platformio and some with Arduino sketches. As was mentioned above, these devices have been around for ages and people have done all sorts of things with them - so lots of material is available to be shared. I like using the Wemos D1, flashed with ESPeasy, as I find it is dead-easy to get a sensor up and running and send its values (using the rule facility in ESPeasy) via MQTT to Node-RED. This is purely based on the fact I discovered ESPeasy a few years ago and have stuck with it ever since. Other people on the forum have had different journeys, and like me, are happy with what they are using. I certainly don't want to get into a battle over which mouse-trap (i.e. firmware) is better than another.

First question is how many pressure sensors are you planning on using?

If it's one, then a Wemos would be suitable - just use the A0 input.
If it's up to four, then an ADS1115 and a Wemos would work.
The other option is an ESP32 Dev Board as I think you have 18 ADC channels available.
The ADS1115 is a 16-bit ADC with 4-channels and can run from a supply voltage of 2V to 5.5V

I used them with my IoT students when they built some solar-powered weather stations. Here's part of the schematic showing the resistor-divider networks and connections between the ADS115 and the Wemos.

2 Likes

Hi Bart,

For what you are planning to do even 8Bit would be fine. As the ADS1115 is so cheap and versatile I use it because it gives me everything I need (and will ever need). 15€ for a pack of 5 from a bigger German supplier (china is becomming less interesting in the last years with higher shipping fees - so support your local heroes)

As you do your research right it is worth to take a look into the datasheet (always a ton first hand information)
image

Although for your application the ADS1115 might be a total overkill it might be beneficial to get familiar with one ADC which you can use with every micro (and the PI) on the market.

But As I said the internal ADC is fine too (and one component less) and a zener diode (one component more to specify and source) as @dynamicdave suggested is fine too.

Again a quick read in the datasheet about the analog input pins:

image

So you run your ADS1115 on 5V you can scroll (or follow the link) up and read under 7.1

image

Your maximum Anlaog Votage is 5V + 0.3V = 5.3V! I can't see how you will be able to exceed this with your circuit. (and the minimum is -0.3V)

I don't see any need of more protection (more components). If you check your circuit before powering on there is no potential problem other than human error. (BTW: ! have 20+ ESPs and only fried one by inserting it 180° reverse into the socket of my motherboard - shit happens)

Last but not least as there is a lot of controversy on the net about 5V inputs pins on an ESP: Is ESP8266 I/O really 5V tolerant? - Digital Me

But this does not apply to the one ADC of the ESP8266. It works from 0-1V of the chip. Most boards come with a build in voltage divider to allow inputs from 0-3.3V. You have to take this into account when designing your voltage divider for ESP8266 boards. One Resistor to widen the range might be enough.

Simply speaking: I run 5V i2c (digital) buses on 2 devices since 3 Years with ESP8266 now with no problem. good signal stability (perhaps better than on 3.3V)
As i2c is a bus all your devices on one 5V bus have to be 5V tolerant. But you can have multiple i2c buses as i2c is a so basic protocol that the arduino drives can emulate i2c on all I/O Pins via bit banging in software (think they do this anyway even on the official D1/D2 pins). So @dynamicdave circit is absolutely correct running on 3.3V as he has a BME280 on the same bus.

Last but not least why not throwing a couple of DS18B20s in the mix to measure some temperatures of your heating system
image

They run on the so called DALLAS 1Pin Bus with individual addresses for each sensor. BUT: This is again a bus topology! Running many in a star configuration is at least unreliable. If you have cables longer than lets say 30cm you better connect each on its own I/O Pin (but there are some left over as your 4 ADCs only use 2 I/O pins :slight_smile:

The packaging is easy to strap on pipes or simply pushed under the isolation. And you even could drown them into water (I have 3 in my pond for years one at -1.5m)

2 Likes

What a bunch of useful info... Love you guys :heart_eyes:
Only from a scientific point of view of course! So don't get high hopes :rofl:

Hey @craigcurtin,
You are right. Those Wemos D1 mini devices are more than enough for my purpose.
Ok I will go for Wemo D1 mini...
Seems that amazon.de only offers nodemcu, so I think I will buy them here.

Ok now I finally am getting somewhere...
Bit off-topic so I will create two separate discussions:

  • Discussion 1: How should I power a large series of those wemo d1 mini devices.
  • Discussion 2: How can I use wired ethernet on a wemo mini. Because that perhaps limits the firmware that I need to chooce?

Then we can keep this disussion focussed on analog water sensors...
Hope to see some of you guys also in that other discussion :wink:

And how do you install those? Because they seem to have no screw like the pressure sensors, to install them into a tube...

If you want wired ethernet then I think the D1 Mini is not what you want. Get a board with Ethernet built in. You may be able to find one that can be powered over the ethernet (POE) which might be useful to you.

1 Like

As I wrote ... stuff them under your isolation and/or use straps to make good contact with the metal of your pipework. Worst case you might have a small temperature offset, but who cares. If you care you will need a calibrated sensor to calibrate your sensor. Do you trust the thermometer of your heating controller to be accurate? I wrote this before: Even the beloved BME280 in my experience comes with a huge offset of 1-3°C on most boards as it might loose its "promised" factory calibration during re flow soldering.That is a known issue (as the adafruit library even has an option for setting an offset) but not obvious until you put a good old Mercury thermometer or different sensors side by side.

What you don't want is your sensor influenced by something else i.e. components on the same PCB or inside a case heating up as these factors are non predictable and have a non linear influence.


I pulled it out a bit ... Yes "Limeprotection" is a big problem here eating away all valves.
or

I agree with Colin - Wemos D1 Mini is not suitable for wired ethernet applications.

Might be worth looking at the Raspberry Pi Pico range as they do a Ethernet HAT or a combined Pico.

EDIT: Oops sorry - this response was meant to be a general comment (not just to Colin).

Apologies! Overlooked that somehow.
Thanks for the pictures! So stupid and yet genius, I love it and must have it :wink:

Hey Colin,
If you should have any suggestions, don't hesitate to share it in that discussion 2!

Yes if that pico does the job, fine for me! Can you also please share that in discussion 2 please? Thanks a lot for the pointers!