Is Z-Uno supported by Smart Things? I need a water level sensor

They are not as close to each over to make it in one device. And I did not wanted wires to go along the tube from the tank to the wire.

BTW, adding a flood sensor to the same Z-Uno can be a nice idea to make sure the tank to not leak :wink: Will be two-in-one. And adding a DS18B20 temp sensor would also make sense to monitor temperature.

1 Like

I built a water level gauge for an overhead tank . Using the ST_Anyhting library and an ultrasonic sensor . The ultrasonic sensor measures the distance between itself and the surface of the water and is very precise . I will be adding a motor control option in the future . Unfortunately i haven’t had the time to clean up my code and share it. I will work on that but my project is a little bit more complex than what you are looking for.

I would recommend you use 2 ESP8266 .

ESP8266 - One

ESP8266 - Two

Once you have all theses devices exposed to Smartthings you can create a simple Smart app to manage the automation and notifications.

Forgot to report back - my Z-Uno was delivered and I managed to make it report values to SmartThings. Just had to apply a template from another sensor and edit a bit to have correct scales. So Z-Uno is pretty well supported in Smart Things. Hopefully SmartThings have a nice template manager for such custom devices

I’ve been trying to get my Z-uno to talk to ST using a simple button and could not get it to work. I’ve tried different device templates in ST , none worked.
Could you post your Arduino code and the device manager template?

That would be very appreciated

I would love to see how you got this all to integrate with Smartthings and if you do have the time, an explanation of how you did this, would be much appreciated.

Here is the main ST_Anything forum thread…

Thanks. I’ll purchase the hardware - maybe the lights will come on for me. Currently I have no idea how this will work.

What exactly are you trying to accomplish? That would help us advise you on your options.

I’m looking for a solution to fill a water tank by turning a water pump on when the water drops below a specified level.
Thanks for you response.

Sounds like @Saif76 does indeed have a solution that you could use without having to reinvent the water wheel! :wink:

I have ordered the sensor and ESP8266. (I have never used a device like this, so I suppose a big learning curve awaits me.
Is my understanding correct that once I have these devices set up with my wifi, I’ll be using your ST_Anything DTH. Am I correct that there is a child-device for the Ultrasonic Distance Measuring Transducer? I suppose once I have all this connect and talking to each other, I will be able to figure out how to calibrate the sensor. I’m concerned that I’ll not be able to read the water level in webCoRE.


I believe you’re going to need some code developed by @Saif76 to get things going. My library does not currently have support for an Ultrasonic Distance Sensor (at least not that I can recall! :slight_smile: )

You are correct that you’ve got a big learning curve ahead of you if you’ve never done any Arduino programming before. There are plenty of “getting started tutorials” that you should familiarize yourself with before even attempting to use ST_Anything. ST_Anything is a hobbyist tool-kit, with some ready-to-run device support. For custom things, like this ultrasonic sensor with tight timing characteristics, some knowledge of C/C++ programming on the Arduino/ESP8266 platform is required. You will also need to learn how to write some Groovy language code on the SmartThings IDE side of things. There is no standard ST Capability for a Level Sensor, so you’re looking at some custom code there as well.

Hopefully @Saif76 can provide some of his work to get you kick-started.

Thanks Dan. I will first do some reading so that I at least have some understanding of what I’m dealing with, before I start bugging @Saif76.

Hi @Saif76.
Would you mind sharing the code you used to get the ultrasonic sensor working with ST_Anything?
There are a few members looking for a solution to check the water level of a reservoir/tank.
Thank you for considering.


Yes, Let me post it here and if @ogiewon is interested in including it in his library i’m fine with that.

There is one important change you have to make in the “parent-st-anything-ethernet.groovy”, I had to add a condition to intercept the value of the sensor so i could calculate and show me capacity in percentage and liters. The water tank i am using is cylindrical in shape so my settings accept a height and diameter in cm to calculate volume.

This is the sensor i used -

Here is the code to the Arduino class and the DH -

Here is what the it looks like in the app

In the parent device handler i had to change this

childDevice.sendEvent(name: namebase, value: value) 


            def functionExist = childDevice.parseValue(namebase,value) // check if the child has a parse function
            	 //log.debug "Function Exists"
            	childDevice.sendEvent(name: namebase, value: value)
                //log.debug "function does not exist"

I know @ogiewon has made a few changes to the library since then, I have not updated my code to accommodate the changes, So please make modifications to fit your needs.

1 Like

Thanks very much - much appreciated. I can’t wait to try this.

Did you install the sensor at the top of the tank, looking down towards the bottom thereof?

Hi again @saif76 and @ogiewon
I’ve now been busy for a few hours and have made some headway. I’ve learned how and managed to program the ESP8266 (ESP-01 Standalone version) and I think I know how to compile the sketch.

I got so far as to get the On/Off LED ST device working. I messed this up however by writing @saif76’s sketch to the ESP8266, which made me realize that one can only write one sketch at a time. I suppose I have to add the libraries together and write them all at the same time as one sketch to the chip?

I noticed the following in the heading of your sketch:

- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- long interval - REQUIRED - the polling interval in seconds
//				- long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
//				- byte digitalTriggerPin - REQUIRED - the Arduino Pin to be used as a digital output to trigger ultrasonic
//				- byte digitalEchoPin - REQUIRED - the Arduino Pin to be used as a digital input to read the echo

Am I correct that I have to add this info here:

PS_Ultrasonic(const __FlashStringHelper *name, unsigned int interval, int offset, byte digitalTriggerPin, byte digitalEchoPin);

If I’m correct, could you help me with the Groovy ST_Anything name? Not sure which DH info I should add there. Should it be Child Ultrasonic Sensor?

Which brings me to another question - once the ESP8266 has been programmed, how did you hook-up the chip to power and the Ultrasonic Sensor? The Sensor came with its own board, but so far I’ve been unable to determine how that should be connected.

Sorry for the newbie questions and thanks again for your assistance.

Edit: I don’t know if I’ve been going at this for too long now, but I don’t think I have any idea of how to combine the sketches and which ones I have to use. My goal is (at this stage) to only use the Ultrasonic Sensor, connected to an ESP-01, to measure the water level in a tank. I managed to do the LED On/Off thing in @ogiewon’s example, but now I stuck. I don’t know which of his sketches I should use and how @Saif76’s sketch for the Ultrasonic sensor, should be added to that.

I made the changes to the parent-st-anything-ethernet DTH.

Hi @Saif76/@ogiewon
I hate to be annoying, but if you perhaps have a few minutes in the next few days, I’ll appreciate your guidance immensely.
Thank you.

Start by following the standard ST_Anything ReadMe linked below. Use the ST_Anything_Multiples_ESP01.ino sketch to get started. Once you have this example working, you can start incorporating @Saif76’s new additions for the ultrasonic level sensor.

Is there a reason you didn’t go with a NodeMCU ESP8266 based board? They are much easier to use as they have onboard USB to ease connection and programming from your computer. The ESP01’s are tiny and inexpensive, but a bit of a pain to hook up and program.

Thank you, Dan, your assistance is much appreciated.

Why the ESP01? Simply because of a lack of experience. As I indicated earlier, I, however, managed to figure the programming out and got so far as to get your LED On/Off example working just fine.
It is the next step where I run into trouble, regardless of how many times I’ve read the README. (I really try to work stuff out, because that is the only way of getting to understand these things.)

My issues which I’ve not been able to figure out:
• Which of your libraries should I use with @Saif76’s sketch? I understand I should use the SmartThingsESP8266WiFi library?
• My understanding is that your library should be combined with @Saif76’s code for the ultrasonic sensor. My issue is that I don’t know how to combine the two. I have tried by loading your SmartThingsESP8266WiFi library and @Saif76’s code in 2 tabs of the Arduino IDE and issued the compile command. That did not work. I tried to “integrate” @Saif76’s code to the bottom of your ESP8266 library within the same tab in the Arduino IDE, but that would also not compile the sketch. My issue is that I know so little, it is almost impossible for me to tell why it fails because I could be making mistakes on numerous levels. I don’t know if I’m adding @Saif76’s code correctly, neither which of your many libraries I should use.

The question therefore here is: If I only want to use the Ultrasonic Sensor, which of your libraries should I use and how do I add @Saif76’s code to your library in the Arduino IDE to create the sketch?

@Saif76’s code contains the following remark at the top: “- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name” What is the object here? Is it your generic ST_Anything Tile in the ST App, or the Tile name of the new DTH being created for the Ultrasonic Sensor.

• Also, not using an Arduino but the standalone ESP8266, how should I change this part of his code, taking into account his remarks at the top of his code: _PS_Ultrasonic(const __FlashStringHelper *name, unsigned int interval, int offset, byte digitalTriggerPin, byte digitalEchoPin). Do you know what the Serial Pin (for the ESP8266) settings should be and how it should be defined here? The examples I could find on the internet contains what seems to be complicated coding and not simply a single digit representing the Pin. Perhaps if I could see what @SAI76’s working sketch looks like, I’ll be able to figure this one out?

• Lastly, as far as the Hardware setup is concerned, once I’ve written the Sketch to the ESP8266, do I connect the Trig and Echo pins of the ultrasonic sensor to the TX/RX pins respectively, or the other way around? Or should the Sensor be connected to the GPO pins of the ESP8266 (I’ve seen other projects on the www connecting sensors to the GPO pins, but I can’t figure out why/when that should rather be used.)

I’m sorry for being such a bother, but I really need to get this working to determine the level of my backup water reservoir. My problem is that I often attempt (electronic/programming) projects far beyond my capabilities.