 # 6 channel temperature monitor trouble

Hey all,

I am definitely in the learning stages for arduinos. I’m in the process of designing a 6-channel LCD temperature monitor to monitor the water temperatures of 6 different aquariums. I haven’t actually built it yet, instead I’m working on a proof-of-concept model using 123d.circuits.io to lay it out and test it.

Currently I’m using TMP36 (because that is the only temp sensor on 123d) with 5v from the arduino but hope to eventually re-design with waterproof digital temperature senors as I gain more knowledge on the digital inputs. I’ve got everything running good for the LCD but seem to have some error in my temperature calculations (or something).

Below are clips from my code. When I run the lcd.print(Tank1,1) function to display the temperature I get a value of 429496… when the temperature should be 25.0. But if I change the code to lcd.print(“xx.x”) I get the display of xx.x, which leads me to believe it just has something to do with the temperature calculations.

Anyone willing to help? I also included my full code as an attachment.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int T1 = A0; //define sensor number to arduino pin
int T2 = A1;
int T3 = A2;
int T4 = A3;
int T5 = A4;
int T6 = A5;
int Tank1, Tank2, Tank3, Tank4, Tank5, Tank6;

void loop()
{
/* ----- do calculations from sensor voltage to degrees C ------- /
Tank1 = (100
(T1/1024))-50; //convert raw reading to voltage (T1/205.0) then to celsius
(100*voltage-50)and write it to tankX
…repeated for tanks 2-6

/* ----- Display Tank temp in degrees C -----*/
lcd.setCursor(2,0); //move cursor to 3rd column position
lcd.print(Tank1,1); //print the value for tank1 with one decimal places (i.e., xx.x)

…repeated for tanks 2-6

//delay(500);
}

_6_channel_temp.ino (2.08 KB)

``````/* ----- do calculations from sensor voltage to degrees C ------- */
Tank1 = (100*(T1/1024))-50; //convert raw reading to voltage (T1/205.0) then to celsius
(100*voltage-50)and write it to tankX
``````

You are reading T1 but not doing anything with the results. You have to save that result in a variable, then you can use it in your program.

Try something like:

``````    int raw = analogRead(T1);
Tank1 = (100*(raw/1023))-50; //convert raw reading to voltage (T1/205.0) then to celsius
(100*voltage-50)and write it to tankX
``````

Right and then you are doing the calculation with the pin number instead of a temperature reading.

And dividing by 1024 is nowhere near the same as dividing by 205.0 for two reasons.

Your calculation does not give you the voltage because you did not multiply by 5.0V. Dividing the analog reading by 1024.0 (note the floating point constant) will give a value between 0.0 and 0.999. You have to multiply that by the analog reference voltage (typically 5.0V) to get volts. You can do both at the same time by dividing by 204.8 (1024.0/5.0). Your comment is close but your code doesn’t match the comment.

If you use the word Pin in your pin number names it makes it clearer what is happening:

``````const int T1Pin = A0;
void loop() {