Read a 0-4mA sensor with a Shelly

Hi folks,

I need help again from my electronics friends over here...

In a desperate attempt to simplify my home automation setup, I have replaced all my electronics in the last 2 years by Shelly devices. I only need to replace the liquid (i.e. oil, water, ...) level measurements in my tanks my Shellies.

Did test some sensors in the past, and at the end I had decided to go for pressure measurement. Had some good accuracy with ultrasonic sensors, but they appeared to be useless in some of my use cases due to reflections of the signal (since these sensor have a wide angle). Anyway don't want to discuss all the sensor types, because I bought mine already....

The tanks are underground in the garden and out of reach for my WIFI network. So I decided to put these Shellies indoor inside my big IOT closet, where lots of other Shellies are installed. Which means the sensor needs to be connected to the Shelly, via a long cable:

The cable is quite long, and runs through a series of cable ducts together with other cables (running all kind of signals). To avoid distortions on my signal, I decided not to go for an output of 0-10V but instead 4-20mA. So the output current of the sensor changes (instead of the output voltage), which should be less influenced by distortions. It is an industry standard, so I assume it is also good enough for my purpose. It is not a 0-20mA sensor, because the first 4mA are used to power the sensor.

So I bought this sensor last year from Aliexpress:

Then I needed to be able to convert the output current to an output voltage (to be able to read it with an ADC), for which I bought this device (model HW-685):

This converter eliminates the 0-4mA part, because otherwise the lower part of my output voltage would be not relevant. Which would decrease the accuracy of my measurement (see further).

Then I had to select a Shelly, that has an embedded ADC converter to read the analog output voltage. There are 3 different Shelly devices available:

  1. Shelly addon (datasheet):
    Voltmeter range: 0 to 10 V
    Voltmeter report threshold: 0.1 V

  2. Shelly Uni (datasheet): found on a forum discussion this info
    “The Shelly UNI has no special ADC chip but uses the two ADC incorporated in the ESP32 processor. These ADC have a resolution of 12bit (4.096 steps) each”

  3. Shelly Uni Plus (datasheet):

I had build last autumn the Shelly addon with a test setup where I had a vertical pipe of 4 meters long filled with water. The results for that pressure sensors are very good:

  • The accuracy of the sensor is very good (i.e. more than good enough for my use case).
  • The output is linear (i.e. output current vs liquid height), which will simplify my calculations inside Node-RED.

However the Shelly addon only provided me a lousy accuracy of steps of 4 cm. Which afterwards seemed logical because I had set the output of my current to voltage converter board to 0-10V (other options are 0-3.3V or 0-5V), to match the analog input voltage range of the Shelly addon. As a result, the accuracy is 0,1V, which is 4 cm (while I had hoped to get an accuracy of 1 cm). Since this is useless for my purpose, I had to abort my test at the end :frowning_face:

I would really like to get this up and running soon, but I have no idea how to continue with this. From the Shelly forums it looks to me that the Shelly Uni and Shelly Uni Plus devices have a much better ADC accuracy. And I want to keep the wiring as simple as possible:

  • I don't know if I need that converter board. Because it needs some calibration from time to time if I understand it correctly. Don't see my wife and kids do that if I would not be around here anymore... Perhaps I can replace the board by some simple resistors or something else?

  • There is also the powering. The pressure sensor needs 24VDC, while the converter board needs between 5 and 12 V (in contradiction to the voltage range mentioned in the chinese docs: otherwise it will burn...). And the Shelly Uni or Uni Plus also have other power ranges (which are not clear to me from their docs). Bit too much of different voltage ranges for me to see the entire picture :exploding_head: Would be nice to keep the number of power sources low, to keep the wiring as simple as possible...

Long story, lots of details. Thanks for reading, and for any help!!

Bart

|Voltmeter report threshold:|0.1 V|**

** Can be configured in the analog input / voltmeter settings

Does this have an option to increase the resolution ?

EDIT: Never mind I found the answer :wink:

  • Delta Threshold - The voltage change with more than a specified value, which triggers a data report. The minimum is 0.1 and the maximum is 5.

I couldn't find specifics for the data output of the other 2 shellys.

I know you are trying to standardise on shelly, but personally I would use a basic esp32, they have multiple ADC inputs so you could measure multiple things with one device.

Supply voltage: you can use 24v for the sensor, and a buck converter to drop to 5volts for the ESP & converter board. Set the output of the converter to 3.3v

@smcgann99
Thanks for joining!

Yes I know what you mean. I currently have ESP32's running for this already. Cannot say anything negative about them. Only that I never see my wifi or kids maintain all these different devices and firmwares. . Beside that, the ESP32's work great...

Yes I find it quite hard to find decent documentation about the ADC's in the Shelly devices.
I found the following info (in various websites), but unfortunately it doesn't ring a bell to me.

  • The Shelly Uni has 1 ADC with dual ranges from 0-12V and 0-30V


    It has a central configuration option for "ADC RANGE", which can be set =12 or =30 (Volt). It has to be 12V for a 12V adapter or 30V if you use 24V or higher.
    The Shelly UNI has no special ADC chip but uses the two ADC incorporated in the ESP32 processor. These ADC have a resolution of 12bit (4.096 steps) each.

  • The Shelly Uni Plus has a bit of other wiring:


    It also can be powered with 5VDC, but not sure if that is also possible in combination with larger input voltages.

Here are similar questions like mine:

https://community.shelly.cloud/topic/8577-connecting-shelly-uni-to-a-sensor-water-level/

Hopefully this might trigger some of the electronic brains in this community, but it won't be my brain...

Maintainability is something I have considered a lot over the past couple of months and while i think I have explained everything, documented everything I have come to the conclusion if I go things will just quit. My better half has no technical training nor does she have any interest. And while my system seems very stable there will be failures. So I'm not sure how much weight you should put on having your other half or others maintain what you have. Maybe go with what's easy and make sure your other half goes first. :slight_smile:

2 Likes

@gerry I also came to much the same conclusion.
Also hopefully long into the future, it's more likely that some generic ESP descendant will still exist, than a backward compatible Shelly unit.

This true of most ADC, the issue is the resolution that is actually reported, e.g. the Shelly addon only reporting 0.1 V steps. You really need to find out what the alternative shellys will give you.

Just to ask i presume you have no hope of extending wifi? Or maybe run an ethernet line with poe?

Same story here... But then at least I can leave this planet with the feeling that I at least tried to simplify stuff :yum:

I have already an ethernet line installed last year to all my tanks. Currently I use a poe powered wt32-eth01 inside the tank. But now I wanted to connect that 4-20mA sensor to that ethernet line and a Shelly Uni or Uni plus inside the house at the other end of that line.

Not a shelley user but it looks like the uni has a analog input, can't you use that to measure a voltage drop across a resistor from your current loop?