These are nice small cheap devices for making liquid level sensors. It involves using 2 low resistance resistors for generating heat and a thermistor for measuring the temperature. Its they are pretty cheap to make its is an involved process. This recipe explains both how to make them and a way to control them without burning them out buy using a mosfet controller and temperature sensor circuit.
#include <Servo.h> Servo myservo; // create servo object to control a servo #include <Wire.h> #include <SoftwareSerial.h> #define THERMISTOR_PIN A0 int valveservo = 11; int washpin = 10; int drypin = 9; int pcvpin = 6; int heatpin = 5; int turnon5vpin = 5; int tempsensor = A0; //int levelsensor = A1; int washval = 255; int dryval = 255; int pcvval = 255; String command; float currpos; int fillflag = 1; int levelval = 50; int heatval = 50; int htcnt = 0; int pumpdelayct = 0; int pumpdelay = 0; int pumponflag = 0; int levelstreamon = 0; #define NUMTEMPS 20 short temptable[NUMTEMPS][2] = { {1, 841}, {54, 255}, {107, 209}, {160, 184}, {213, 166}, {266, 153}, {319, 142}, {372, 132}, {425, 124}, {478, 116}, {531, 108}, {584, 101}, {637, 93}, {690, 86}, {743, 78}, {796, 70}, {849, 61}, {902, 50}, {955, 34}, {1008, 3} }; void setup() { // put your setup code here, to run once: Serial.begin(115200); myservo.attach(valveservo); analogWrite(pcvpin, 0); analogWrite(washpin,0); analogWrite(drypin, 0); analogWrite(heatpin, 0); analogWrite(turnon5vpin, 0); currpos = 0; } void loop() { int rawvalue = analogRead(THERMISTOR_PIN); int celsius = read_temp(); int fahrenheit = (((celsius * 9) / 5) + 32); // put your main code here, to run repeatedly: if ((celsius > levelval) and (fillflag == 0)){ htcnt = htcnt + 1; if (htcnt > 10) { analogWrite(pcvpin, 255); pumponflag = 1; delay(pumpdelay); pumpdelayct = 0; } } else if ((celsius < (levelval-5) and (pumponflag == 1) and (fillflag == 0))) { if (pumpdelayct == pumpdelay){ analogWrite(pcvpin, 0); pumponflag = 0; } pumpdelayct = pumpdelayct + 1; } else if ((analogRead(tempsensor) > levelval)){ htcnt = 0; } if (levelstreamon == 1) { Serial.println(celsius); delay(500); } if(Serial.available()) { char c = Serial.read(); if (c== '\n') { currpos = parseCommand(command, currpos); command = ""; } else { command +=c; } } delay(30); } float parseCommand(String com, int currpos) { if(com.equalsIgnoreCase("washon")){ analogWrite(washpin, washval); delay(100); } else if(com.equalsIgnoreCase("washoff")){ analogWrite(washpin, 0); delay(100); } else if(com.equalsIgnoreCase("dryon")){ analogWrite(drypin, dryval); delay(100); } else if(com.equalsIgnoreCase("dryoff")){ analogWrite(drypin, 0); delay(100); } else if(com.equalsIgnoreCase("info")){ Serial.println("wash_dry_pcv_electrocaloric_kill_stepper_valve"); } else if(com.equalsIgnoreCase("turnon5v")){ analogWrite(turnon5vpin, 255); } else if(com.equalsIgnoreCase("turnoff5v")){ analogWrite(turnon5vpin, 0); } else if(com.equalsIgnoreCase("manpcv")){ fillflag = 1; analogWrite(pcvpin, 0); } else if(com.equalsIgnoreCase("feedbackpcv")){ fillflag = 0; } else if(com.equalsIgnoreCase("pcvon")){ if (fillflag == 1){ analogWrite(pcvpin, pcvval); } } else if(com.equalsIgnoreCase("pcvoff")){ if (fillflag == 1){ analogWrite(pcvpin, 0); } } else if(com.equalsIgnoreCase("levelstreamon")){ levelstreamon = 1; } else if(com.equalsIgnoreCase("levelstreamoff")){ levelstreamon = 0; } else if(com.equalsIgnoreCase("heatoff")){ analogWrite(heatpin, 0); } else if(com.equalsIgnoreCase("heaton")){ analogWrite(heatpin, heatval); } else if(com.equalsIgnoreCase("readlevel")){ int rawvalue = analogRead(THERMISTOR_PIN); int celsius = read_temp(); Serial.println(celsius); } else if (com.substring(0,10) == "setwashval") { washval = com.substring(11).toInt(); } else if (com.substring(0,9) == "setdryval") { dryval = com.substring(10).toInt(); } else if (com.substring(0,9) == "setpcvval") { pcvval = com.substring(10).toInt(); } else if (com.substring(0,11) == "setlevelval") { levelval = com.substring(11).toInt(); } else if (com.substring(0,7) == "heatval") { heatval = com.substring(7).toInt(); } else if (com.substring(0,10) == "valveservo") { myservo.write(com.substring(com.indexOf("valveservo")+11).toInt()); } return currpos; } int read_temp() { int rawtemp = analogRead(THERMISTOR_PIN); int current_celsius = 0; byte i; for (i=1; i<NUMTEMPS; i++) { if (temptable[i][0] > rawtemp) { int realtemp = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]); if (realtemp > 255) realtemp = 255; current_celsius = realtemp; break; } } // Overflow: We just clamp to 0 degrees celsius if (i == NUMTEMPS) current_celsius = 0; return current_celsius; }