At the top of the sketch you can adjust the following #define values based on your hardware:
- SERIES_RESISTOR - This is the value in ohms of the resistor you attached to the hardware in series with the sensor. This should be 560 unless you used a different resistor value.
- SENSOR_PIN - This is the analog input pin which is connected to the sensor.
Resistance: 1963.70 ohms
Calculated volume: 0.00000
The resistance value is the measured resistance of the liquid sensor. With no liquid touching the sensor it should read a value around 1500-2000 ohms (depending on the length of the sensor).
Try pressing the sensor in various locations to see how the resistance changes. If you touch near the top of the sensor at the MAX line you should see a resistance around 200-400 ohms.
To calibrate the sensor for measuring volume, you will need to measure the following:
- The resistance value with no liquid touching the sensor.
- The resistance value when a known volume of liquid is touching the sensor.
- The volume of liquid used to find the above resistance value.
Once you've determined the above calibration values, update the #defines at the top of the sketch appropriately:
- ZERO_VOLUME_RESISTANCE - Set this to the resistance value with no liquid, in my case 1963.70.
- CALIBRATION_RESISTANCE - Set this to the resistance value with a known volume of liquid, in my case 512.81.
- CALIBRATION_VOLUME - Set this to the volume of liquid, in my case 500.00 milliliters (you can use other units, but milliliters are what the web application expects).
If you're not using an Arduino Yun, the software setup is done and you're now able to read the volume of liquid in the container. Consider adding a display, like this small OLED, to show the measured volume!
If you're using the Yun, continue on to learn about how to setup the Yun to display volume data on a web page.