0

I am building a monitor to measure how much water is in a tank.

I started using 12" Standard eTape Liquid Level Sensor with Plastic Casing connected to mcp3008 and it's not working great, well not working how I would expect it to.

When it's out of the water it returns a result of water being at 27cm! This cant be right

I wanted to know if there is another device that is more accurate as in my user case, it needs to be within 1cm accuracy.

That said I am wondering if there is a problem with the etape or the mcp3008 chip because the other issue is, I can not get the python code to return any value which I wasn't worried about at first as I building the application in Ruby and it returns values with ruby code using pi-piper gem

Any suggestions on devices would be appreciated

EDIT:

Sorry should have added this in the first place:

this is how it is wired up:

enter image description here

I am using a Rotary shaft potentiometer as the etape as I couldn't find a Fzitxing part to match the etape I have.

Then the code I am using is:

require 'pi_piper'
require 'date'

def read_adc(adc_pin, clockpin, adc_in, adc_out, cspin)
  cspin.on
  clockpin.off
  cspin.off

  command_out = adc_pin
  command_out |= 0x18
  command_out <<= 3

  (0..4).each do
    adc_in.update_value((command_out & 0x80) > 0)
    command_out <<= 1
    clockpin.on
    clockpin.off
  end
  result = 0

  (0..11).each do
    clockpin.on
    clockpin.off
    result <<= 1
    adc_out.read
    if adc_out.on?
      result |= 0x1
    end
  end

  cspin.on

  result >> 1
end

clock = PiPiper::Pin.new :pin => 11, :direction => :out
adc_out = PiPiper::Pin.new :pin => 9
adc_in = PiPiper::Pin.new :pin => 10, :direction => :out
cs = PiPiper::Pin.new :pin => 5, :direction => :out

adc_pin = 0

level_size = 30
raw_value = read_adc(adc_pin, clock, adc_in, adc_out, cs)
raw_value_volts = ((raw_value * 3.3)/1023)
level = ((level_size * raw_value_volts)/3.3)

puts "The raw value is: #{raw_value}, the mill-volts is #{raw_value_volts} and the level in CM is #{level}"

Technical Details of Etape (The data sheet only shows the standard etape that in not incased already and have 4 pins, I been told by PIHut the etape I have is a resistive divider / analog out) - DataSheet

Dimensions: 305mm x 29mm x 13mm / 12" x 1.14" x 0.51"

Weight: 56g

Sensor Output: 400-2000Ω ±20%

Ref. Resistance: 2000Ω ±20%

Actuation Depth: Nominal 25.4mm / 1"

Resistance Gradient: 60Ω/cm / 150Ω /inch

Power Rating: 0.5 Watts

Temperature Range: 15°F - 150°F / -9°C - 65°C

9
  • When it's out of the water it returns a result of water being at 27cm??? ... what is this question asking?
    – jsotola
    Commented Feb 4, 2022 at 21:10
  • did you calibrate the sensor? ... how did you measure the resistance of the sensor? ... include the schematic diagram of the circuit
    – jsotola
    Commented Feb 4, 2022 at 21:10
  • (1) Your £58 ruler looks professional and I think it can measure very "accurately". Can you give me the link to the spec and user gudie? (2) I have written python programs to use mcp3008 some years back. You can search my code in the forum.
    – tlfong01
    Commented Feb 5, 2022 at 2:53
  • 1
    @tlfong01 I thought the same about the rule being pro, but I am guessing it's something I am doing more than the device. I added the fritzing diagram and link to the datasheet, maybe(hopefully) you can point me in the right direction
    – Phil
    Commented Feb 5, 2022 at 12:21
  • Thanks a lot. I will take a look and hope to give your comments over this weekend.
    – tlfong01
    Commented Feb 5, 2022 at 12:50

2 Answers 2

1

The data sheet says this is a 4-terminal part, with the inner 2 pins being a variable resistor that varies with water pressure, and the outer 2 being a fixed resistor. Unfortunately your circuit diagram shows this as a 3-terminal device, so it is unclear how you have connected the 4 pins.

If you have access to a multimeter, disconnect the device from your circuit, and measure the resistance between the inner 2 pins, and you should see it vary as the water level changes. Then connect the sensor up as in the first of the 'sample circuits', with a 3.3V supply and the 2 resistors acting as a potential divider, and measure the voltage on the junction of the 2 resistors; you should see that change as the water level changes. Once that is working OK, connect that point to the input of the ADC, and run your code, comparing the values you get with the voltage indicated by the meter.

If you don't have access to a multimeter, then I suggest you start by checking that the ADC is working OK; you can do this by disconnecting your circuit and connecting the ADC input to the 0V rail, and see if it returns a value fluctuating around zero; then connect the ADC input to 3.3V and check that you get value around full-scale (4095 units). However, if you are doing that, make absolutely sure that you don't put more than 3.3V into the ADC, otherwise it will be damaged. If the ADC returns sensible values, connect the sensor to its input as described above, and hopefully it should work - but I would suggest you first use a multimeter, if at all possible.

2
  • 1
    this is one of the issues I have, what I brought from pi hat is different to what's in any data sheet, the difference being the etape pins are incased and all I get is 3 pin connector
    – Phil
    Commented Feb 5, 2022 at 17:06
  • If there are only 3 pins, then they have probably linked 2 of them together, so you have a supply pin, ground pin and output pin, but in the absence of any data, you have to guess which is which. This is where a multimeter would really come in handy; by measuring the resistance between any 2 pins, and varying the water depth, you can easily establish the pinout - the resistance between the output and ground will be varying, while the resistance between the output and supply will be fixed.
    – jayben
    Commented Feb 6, 2022 at 10:06
0

Question

How to use Rpi Python or Ruby to talk to the eTape liquid level sensor?

enter image description here

Answer

Part 1 - Calibration

  1. We need first to use a multimeter to calibrate to make sure the meter is working OK.

1.1 Dip the liquid sensing meter "ruler" to a vessel of water at about 6 inches.

1.2 The multimeter, "meter" should read the ruler's output (inner 2 pins of the 4 pin connector) resistance roughly 1.4 kΩ

1.3 Pour water so that the "ruler" now is about 9 inches.

1.4 The meter should now read 0.9 kΩ (900Ω)

Note 1

For this part of calibration, we don't need any power source such a battery etc.


/ to continue, ...

...

References

(1) Continuous Fluid Level Sensor PN-12110215TC-X - Milone Tech (Innovative Fluid Sensing)

(2) pi-piper Project 4: MCP3008 - jwhitehorn 2013jan21


6
  • 1
    I actually found the correct datasheet for the etape that I have which shows the module that is already built-in and pre-calibratied. Also to answer the questions from before yes I have multi-meter and can messure but not sure thats needed if pre-calibratied
    – Phil
    Commented Feb 5, 2022 at 18:52
  • (1) It is a bit confusing. Do you mean that you have a "module" which has the "ruler" built in? Perhaps you can show us a photo to clarify. (2) It is clear if the chart is for distilled water. If measure liquid with different pH values, the two extreme resistance value may be different. In other words, if you are using it for two kinds of liquids, you might need to use one ADC with two channels, separately calibrated. (3) And do you have any Arduino around? Then you don't need ADC, because Arduino has ADC built in. (4) Or you can use Rpi Pico, which, like Arduino, also has built in ADC.
    – tlfong01
    Commented Feb 6, 2022 at 7:45
  • 1
    really sorry I thought I put link into the comment with the correct data sheet, please see img1.wsimg.com/blobby/go/6e1bce17-f4fa-40c3-9d89-9bb7445697bb/…
    – Phil
    Commented Feb 6, 2022 at 13:56
  • 1
    Oh my goodness, so you have the complete module/assembly. In this case you don't need any MCP3008 ADC. But you need to pay attention that the module output is 5V logical, and if you input this 5V logic signal to your 3V3 logical Rpi, you might fry the Rpi. Ah. bed time. Se you tomorrow.
    – tlfong01
    Commented Feb 6, 2022 at 14:04
  • guessing I need to add a resistor between the pin out and the raspberry pie, but will that affect the reading?
    – Phil
    Commented Feb 7, 2022 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.