How to read serial data from Non-contact Ultrasonic liquid level sensor


I am trying to read data from a liquid level ultrasonic sensor, with the attached specification.

Pin 1 (Red): VCC DC 3.3V
Pin 2 (Black): GND
Pin 3 (White): RX
Pin 4 (Yellow): TX

The output format is RS232. I am using a RS232 to TTL converter to connect to arduino.

How do I read serial data from the sensor in arduino.

Thanks for your support.

Use the hardware Serial pins of your Arduino and the normal Serial library, set to the correct baud rate. Connect the converter's TX to Arduino RX and the other way around.

With the wiring you show you should be using SoftwareSerial.

By the way, are you sure this is an ultrasound sensor, not a capacitive sensor? Please post a link to its data sheet.


Its an ultrasonic sensor for liquid level detection.
I bought it from this link.

Other than it's shocking price, that's a very interesting sensor.
It is just glued to the bottom of the container, right?
Where's it's data sheet or manual?

Housing indicates it's weather proof but no claims of that on any of the many sites that sell it.

No information on how to read this sensor, at all. It's also known as DYP-1603.

It apparently can be use as level switch if mounted to the side of a tank, and as absolute level sensor (no word on calibration; unsure whether the wall thickness has any effect) for 50-1000 or even 50-2000 mm liquid depths when mounted on the bottom of (i.e. beneath) the tank.

There are various versions of the sensor: DS1603AQ (analog output), DS1603NF (level switch - only a high/low signal), DS1603DA (UART/Serial output) and finally DS1603L which appears to have UART output, and a fifth wire marked "OUT" - my best guess is that this is meant to be a level switch.

And here you go, something that closely resembles a manual on this page. The UART is apparently 9600 bps TTL compatible (provided you supply it 5V it should never get over that voltage, and it apparently will also work on 3.3V). Quite irritating that the text is in the form of images so Google Translate doesn't work.

Prices on Alibaba/Taobao are RMB85 for single units, and go down to RMB68 in volume which is a lot friendlier price already :slight_smile:

OK, got some translation done.

It’s a slowish sensor: one measurement per second; no liquid detection takes 10 seconds; liquid present 2 seconds. Good enough for most practical purposes.

No word on how to initiate conversion or so. Power with 3.3-12V, typical 5V, TTL compatible UART output. So it should be possible to connect direct to Arduino’s RX/TX pins.

9600 bps, 8 data bits, one stop bit, no parity bit.
4 bytes of data:

  • header: fixed value 0xFF
  • Data_H: high byte of height.
  • Data_L: low byte of height.
  • SUM: a checksum.

Checksum: (header + Data_H + Data_L) & 0x00FF
Height in mm: Data_H * 256 + Data_L

LED on: sensor powered but no liquid detected.
LED flash (one per second): liquid detected.

No word on how to initiate conversion or communication - my best guess is that the sensor measures continuously and simply transmits every second.

Power consumption: <35 mA. Peak current: 100 mA @5V, ripple max 50 mV, noise max 100 mV.

50-2000 mm level; max. error 3 mm + 0.5% of height.

Use temperature: -15 to 60 C; humidity max 80%; no condensation.

Thanks for the translation.

I tried reading data from the sensor with this code.

byte byteRead;
#include <SoftwareSerial.h>

#define txPin 3
#define rxPin 2

SoftwareSerial sonarSerial(rxPin, txPin);

void setup() {


void loop() {

byteRead =;

but it outputs



I also tried connecting directly to arduino, and the output is



Oh, continuous stream of data. That's why that header, then. Makes sense.

255 - 0 - 0 - 255 would be a single set of readings (header, data_h, data_l, sum). That's when the sensor is not attached to a container filled with liquid, right?

The first set of numbers doesn't make sense to me. It should for starters be series of four numbers.

@wvmarle Thanks very much for your contribution.

I connected the sensor directly to arduino and like you said, 255-0-0-255 means no liquid present.
When liquid is detected it outputs a fixed 255 and three other numbers depending on the height of the liquid.

I'll just have to do some calibration with different types of liquids.

The package came with a glue(fluid), which I had to apply on the surface of the container before it could detect the liquid present.

Thanks so much wvmarle!!! :slight_smile: :slight_smile: :slight_smile:

Thanks for reporting back. I am definitely going to try out these sensors myself, too.

If your liquid is water, there's a fair chance little or no calibration is needed. After all the speed of sound in water is fairly constant, and it seems all parameters of the sensor are based on use with water.

What do u think about using it to measure liquid in propane tank.
How did you determine that the parameters of the sensors are based on water?

Several times the manufacturer talks about measuring the level of water, and calibrating with water.
Water is probably the most common liquid on this planet, it’s cheap and readily available, and pretty safe in use. So it makes sense they use water for that.
I suppose it will work just fine with propane, they do talk all the time about “any liquid that can not be touched” such as corrosive and flammable liquids.
The principle seems to be entirely based around bouncing ultrasound waves off the liquid’s surface, so I don’t see why it wouldn’t work for other liquids. You’ll have to calibrate for your liquid (though if you look up the speed of sound in water vs. propane you should be able get a reasonable estimate on how to calculate one from the other).

Just got one of those sensors myself - reading the data is no problem but I can't get it to detect water. I tried pushing it to the bottom of various containers, but nothing seems to work.

The package did include some kind of adhesive, so maybe its not making good enough contact. How did you fare in this?

Too bad you didn't buy two - so you could dissect one and see what's inside. :slight_smile:

I tried pushing it to the bottom of various containers, but nothing seems to work.

You mean you held it tight up against the bottom (outside) of various containers? Did you use the adhesive? Seems like it probably needs the adhesive for proper coupling.

Did you try steel containers? What wall thickness and size?

But anyway, it is a bit hard to believe this could work (finding fluid depth when mounted on the outside of a vessel)...especially if the wall is thick.

in fact I have two of them.

But not going to dissect any before I got at least one working :slight_smile: It seems the problem I have is in the contact with the container. Gotta rig up a test thing with batteries and LCD or so, make it more mobile. At least reading the thing is pretty straightforward, every 2 seconds it will simply transmit a reading.

I added some questions while you were typing...

You mean you held it tight up against the bottom (outside) of various containers? Did you use the adhesive? Seems like it probably needs the adhesive for proper coupling.

Did you try steel containers? What wall thickness and size?

Also, it would be interesting to hold the "business end" of the sensor slightly under the water surface (at the top of the container), pointed down toward the bottom of the container, to see if works as a typical "sonar"...bouncing a signal off the bottom of the container.

I tried a glass and a plastic container, no adhesive. I suspect that to be the problem (I suppose it's not just because that they add the stuff to the package, even though the Taobao listings don't mention it). Final application is for metal containers, just hoped to get some readings on the bench before committing to gluing it on to one of the containers.

It's for 1.2 mm stainless steel containers, max about 30 cm of water. That's all well within specs and expected to work fine. A second practical issue is the rather short wiring, which I have to do something about - and then waterproof the joint as it's an outdoor application. That's also why I didn't want to start gluing and so just yet.

You could try some K-Y jelly or similar as a temporary coupling material (before committing to the adhesive). Our ultrasonic thickness gauges (for measuring the thickness of metal components) use a fairly viscous fluid like that.

I will, thanks for the tip.

It works better when you apply a gel between the two surfaces to close the air gap.