Is this DS1603LV1.0 sensor bad? Or am I bad?

I recently bough a DS1603LV1.0 from Amazon. This sensor is suppose to be able to detect the water depth of a container, without even touching the water. However, after running the code for the library, it says it cannot even detect the sensor. I cannot tell if I need some other component to make this work, the wiring is bad, or the sensor is bad. Any opinion or answer is welcomed.
Connection: VCC -> 5V, GND ->GND, TX PIN -> pin 4, RX ->Pin5.
Library: Arduino_DS1603L/DS1603L.ino at master · wvmarle/Arduino_DS1603L · GitHub

My Serial output:

I'm not familiar with your sensor or library but I would first check the baud rates are all the same between your code, the sensor and the IDE monitor.

I just changed them to all be 9600 and the serial output is legible! Unfortunately, I think the sensor is faulty as it just gives me the same value regardless of the amount of water. But regardless, thank you for the reply.
image

I don't understand this sensor. In the graphics it looks like it is a water or no water sensor, kind of like a float switch. But it has a serial output and suggests it reports in mm.

Have you tried it with a flat sided container? I would suggest if it is not glued to the container you at least wet the interface and have a small a gap as possible.

Apparently this sensor can give an accurate output of how much water is in a container. I tracked down this library from this forum page:

The page has multiple people saying its capable of outputting a value in mm. I have glued this sensor to the bottom of a container filled with water but it doesnt seem to register anything.

oh wait nevermind i actually got it work!
image
I suppose the water amount matters as, I glued it to a bigger container and it actually gave me a reading!

I have an ultrasonic sensor measuring distance in air. I get spurious readings periodically.
Rather than try to average them out I:

  1. Read 9 readings into an array
  2. sorted the array
  3. used the middle reading.

You could take more readings and use the middle 3 averaged.

Thank you for the suggest JohnRob. I actually ditched the library in favor of just using the SoftwareSerial.h library. image

The sensor reads like so: value1 (sensor turns on, always 255), value 2 (receiver received nothing so its always 0), value 3 and 4 seem to be the accurate measurements of the water.
I'm not sure how I can create a line of code to only accept the last 2 values. Should I create a for loop counter that collects the value whenever i=3, or is there a better way to do that?

As I said originally I found sorting the easiest method. I wasn't in C so my code would be useless to you.
But...

Create an array of int 16 chars long (a few more than you plan to sample)

In a for loop
collect 15 samples

Then use a sort routine. Google Arduino sort array and you will find many options.

In another loop add the array numbers array[10] + array[11].....array[14]
then divide by 5 and you have a pretty solid value. This step basically ignores the highest 5 and the lowest 5 samples. Hopefully throwing out the "bad" samples.

1 Like

@kettai, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

This is called a median filter and if you search for that phrase with "Arduino code" you will find many examples.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.