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:
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
When it's out of the water it returns a result of water being at 27cm???
... what is this question asking?