New to the forum and in need of some guidance. We are creating a battery temperature monitoring system that will turn on cooling fans when a specified temperature is reached. Using a 10K thermistor, a 10K ohm resistor and the arduino R3, we are reading one thermistor from the A0 input. I need to add 15 additional thermistors, monitor the temp of each group of cells and turn on the cooling fan when the specified temp of 116F is met. Apparently having trouble with the code. I need help writing the additional lines/functions to read the additional thermistors.
Here is my code
//CTEC 10K Thermistor Temperature Sensor
//Created 3/2/2020
//With LCD
//Wtih 5V Relay
#include <LiquidCrystal.h>
int relayPin = 8;//Energize and deenergize the relay when temperature thresholds are met.
int ThermistorPin []= {A0,A1}; //Thermistor analog input(s)
float read (int ThermistorPin);
int Vo;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
}
void loop() {
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2logR2 + c3logR2logR2logR2));
T = T - 273.15;
T = (T * 9.0)/ 5.0 + 32.0;
if (T >= 116){ // Turns the cooling fan on at 116 degrees F
digitalWrite(relayPin, HIGH);
}
if (T <= 114) { // Turns the cooling fan off at 114 degrees F
digitalWrite(relayPin, LOW);
}
lcd.print("Temp = ");
lcd.print(T);
lcd.print(" F");
delay(500);
lcd.clear();
}
Only one of the thermistors will engage the cooling fan. Both thermistors are not responding to a heat gun when heated. Is the thermistor pin line correct? Is there a line that needs added to the loop for the arduino to respond? If the thermistor associated with the A0 pin is reading 73F the thermistor associated with A1 pin is not reading or responding to anything. What do I need to do?
To explain a bit further, each group of cells is monitored individually, our setup is three cells in a group that we call group or cell 1. Group or cell 2 , 3, 4 thru 16 all have individual thermistors attached and if one group begins to overheat, then the cooling fan should come on once the temperature reaches 116F. Again, my error has to be the code.
What are you trying to do with this line?
float read (int ThermistorPin);
And here, you're trying to access an array but haven't specified which element:
Vo = analogRead(ThermistorPin);
float read (int ThermistorPin); This was an attempt to have the processor read the various pins. I realized this did not work and the line can be removed.
Vo = analogRead(ThermistorPin); This line read the thermistor pin value that was set in the variables.
You mention that I am "trying to access an array but haven't specified which element" I am very new at this so gong out on a limb, should I declare each analog pin as in the second line and then change the line "vo = analogRead(ThermistorPin); to vo = analogRead(Thermistor Pin A0,A1);
Again, I am very new at this and this is one of my first projects that I have taken on my own.
This is an array declaration:
int ThermistorPin []= {A0,A1}; //Thermistor analog input(s)
If you're not familiar with how arrays work, try to rewrite your code without arrays. Just do simple variable declarations.
You have 2 thermistors and 2 pins, right? So that means you'll have to do 2 different analog reads. Also, did you do a pinMode for either of those 2 pins? Look through your code and see if those are there.
If this seems a little much, review some simple sketch examples with analogRead to practice first.
Hi,
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Why thermistors?
Why not DS18B20 sensors, they can all share the same one-wire comms and are already calibrated.
There is a library that you can use with them.
Tom.... 