# Strange values from analog ports

Hi, maybe someone can help me…

April board with 3 thermistors attached on ports 9,8,7 , it in a voltage divider setup…

Everything works , getting temperature readings,
… but if i disconnect one of the cables from the pins , at first the temperature was -273 degrees , which was ok… but now i get random values… ?

`
// April with 10k EPCOS - B57891M0103K000 Farnell NTC Thermistor Voltage Divider Setup

// turn on WiFi power save to reduce power consumption when awake
imp.setpowersave(true);

local output = OutputPort("Temp1, Temp2, Temp3, Volts, SupplyVolts ", “table”);
imp.configure(“IMP2 Multi NTC Thermometer”, [], [output]);

// pin 5 is the middle of the voltage diverder formed by a 1.2k and 2.7k restistor to determine voltage at power supply
hardware.pin5.configure(ANALOG_IN);

// pin 7 is the middle of the voltage divider formed by the NTC - read the analog voltage to determine temperature
hardware.pin7.configure(ANALOG_IN);
// pin 8 is the middle of the voltage divider formed by the NTC - read the analog voltage to determine temperature
hardware.pin8.configure(ANALOG_IN);
// pin 9 is the middle of the voltage divider formed by the NTC - read the analog voltage to determine temperature
hardware.pin9.configure(ANALOG_IN);

// all calculations are done in Kelvin
// these are constants for this particular thermistor; if using a different one,
const b_therm = 3950;
const t0_therm = 298.15;

// to read the battery voltage reliably, we take 10 readings and average them
local v_high = 0;
for(local i = 0; i < 10; i++){
imp.sleep(0.01);
v_high += hardware.voltage();
}
v_high = v_high / 10.0;

local val = 0;
for (local i = 0; i < 10; i++) {
imp.sleep(0.01);
}
val = val/10;
//val2 = val2/65535.0;
local cV = 0;
cV = 3.3 * val / 65535;
cV = cV * 3.2 // Voltage divider

// Temp1
local val = 0;
local v_therm = 0;
local r_therm = 0;
local ln_therm = 0;
local t_therm = 0;

for (local i = 0; i < 10; i++) {
imp.sleep(0.01);
}
val = val/10;
local v_therm = v_high * val / 65535.0;
local r_therm = 10000.0 / ( (v_high / v_therm) - 1);
local ln_therm = math.log(10000.0 / r_therm);
local t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;
local f = (t_therm) ;

// End Temp1

// Temp2
local val = 0;
local v_therm = 0;
local r_therm = 0;
local ln_therm = 0;
local t_therm = 0;

for (local i = 0; i < 10; i++) {
imp.sleep(0.01);
}
val = val/10;
local v_therm = v_high * val / 65535.0;
local r_therm = 10000.0 / ( (v_high / v_therm) - 1);
local ln_therm = math.log(10000.0 / r_therm);
local t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;
local f2 = (t_therm) ;

// End Temp2

// Temp3
local val = 0;
local v_therm = 0;
local r_therm = 0;
local ln_therm = 0;
local t_therm = 0;

for (local i = 0; i < 10; i++) {
imp.sleep(0.01);
}
val = val/10;
local v_therm = v_high * val / 65535.0;
local r_therm = 10000.0 / ( (v_high / v_therm) - 1);
local ln_therm = math.log(10000.0 / r_therm);
local t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;
local f3 = (t_therm) ;

// End Temp3

// Logging
local f_str = format("%.01f - %.01f - %.01f", f,f2,f3)
server.log("Current temp is "+f_str);

local dTable = {
“temp1” : f,
“temp2” : f2,
“temp3” : f3,
“volt” : v_high,
“svolt” : cV
}

output.set(dTable);
server.show(format(“Running on %.2f V at %.1f Celsius”, v_high, f));
imp.wakeup(3, function() { server.sleepfor(1 + 160 - (time() % (160))); });
`

Can you say exactly what your wiring is, and which cable you disconnected?

Yellow line connected to pin9 , simular for pin8 and pin7 , when i disconnect the yellow line from a imp pin this happens… red and green connected to imp 3.3 and gnd