I ordered this sensor and would like to connect it to the ESP. I'm not sure if my reasoning is correct. Is this how I should connect the sensor? The European version is 0-190 ohms. For greater stability, I want to add an external 16-bit converter.
Do you have the sensor in hand? From the aliexpress description I conclude that its output is ~15 discreet resistance readings as the magnetic float moves along the travel length. Is that true?
From your schematic, the voltage at AIN0 would look something like this except it would be discrete steps instead of a smooth line.
Unfortunately, I don't have the sensor yet. I think it will arrive next week. I wanted to make sure I had the connection figured out first. According to your simulation, it seems to be OK? So is there a chance my diagram might work?
Check to see if there are pull-up resistors on the SDA and SCL lines. If you have a schematic of the ADS1115 module you are using you could post that here.
Your circuit will measure whatever voltage is available from the sensor depending on whatever is inside it.
So, if the sensor resistance changes, it will be converted to voltage and then mapped to a percentage 0-100%. Additionally, I want to use the median to average and stabilize the measurement. If an unexpected value appears, the median will reject it.
Your circuit looks good but the range could be better by making the fixed resistor smaller. Also a 16bit ADC would be incredible overkill if the sensor is linear and even greater overkill if the sensor had 15 discrete values.
I was thinking about reducing it to 220 ohms. I'll check it once I have a sensor. The ADC isn't expensive, but I think it will improve stability because the ADC in the ESP8266 is very weak.
So what's the plan. If 220 doesn't burn out the sender then it's OK.
If it does then keep trying senders and resistors until you find a value that doesn't burn out the sender
Frankly I wouldn’t bother with the external ADC since the sensor has such low resolution. You could map the voltage into say 1/8 tank increments and be done with it.
Maybe you have a use for the other channels in which case that might be a reason to keep it.
Okay, so I'll forgo the external converter.Should I choose a resistor so that the voltage across the divider at 190 ohms is 1V? And then map this voltage 0-100?
I don't quite understand what's going on damage sender?
If I connect the sensor as shown in the diagram, before connecting it to the ESP analog pin, I can check the voltage with a multimeter by adding, for example, a 470R resistor and setting the sensor float to max.
If you're actually using the Wemos D1 Mini I might want to backtrack. It scales the analog input so the 8266 ADC would only see about 0.3V from your 1V sensor output. Maybe adequate for your application but maybe a reason to go back to your original ASD1115 idea.
Since we don't know the quality of the reed switches in the sensor, I wouldn't increase the current level. 5 mA probably is okay though unless they are really bad.
The Wemo ADC will likely be fine though since you'll have a small number of discrete voltages from your sensor and won't care if it's linear or not.
First, I would hook up the sensor with the 470 Ohm resistor and move the float through its maximum and minimum ranges to see how many voltage steps there are. Then measure and record the maximum voltage you get from the sensor and what the ADC reading is for that. It will be in the 300 range since it's a 10-bit ADC. Your map() function is perfect for this since it does integer math so you can write something like:
int ADCval;
int number_of_steps = 8; // number of discrete voltages from sensor
ADCval = map(ADCval, 0, 333, 0, number_of_steps);
then you can display the tank level in 1/8s: Empty, 1/8, 1/4, ... 3/4, 7/8, Full.
I think the concern is that the reed switches could be damaged by excessive current and since we don't know their specs it's best to use as low a current as practical.
EmilyJane Thank you very much for the explanation. I didn't realize the danger. I forgot that reed switches can be easily damaged, so jim-p's suggestion was very good.
I'll send an inquiry to the seller and see if I can find out more.
If that is accurate then it doesn't seem likely that you will damage them with 5-10 mA. It's still a mystery how many voltage steps there are but a question easily answered by experimentation.