Ive been working on a one wire temperature sensor project. I would like to read the temperature of 5 one wire temperature sensors and compare it to a temperature, then set a pin high to light a red green or blue LED.
example:
if (thermistor1 > 78"degrees"){
digitalWrite(Red, HIGH);
}
if (thermistor1 < 78){
digitalWrite(Blue, HIGH);
}
if (thermistor1 == 78){
digitalWrite(Green, HIGH);
}
"Ive tried this way multiple times and returns 'cannot compare pointer to integer' "
I am starting with arduino and do not know alot so any help on this is greatly appreciated!
#include <OneWire.h>
#include <DallasTemperature.h>
// 1 wire data pin 3
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Thermistor1 = { 0x28, 0x6A, 0x15, 0x41, 0x05, 0x00, 0x00, 0xE6 };
DeviceAddress Thermistor2 = { 0x28, 0xD0, 0xB1, 0x40, 0x05, 0x00, 0x00, 0x8D };
DeviceAddress Thermistor3 = { 0x28, 0xF2, 0x96, 0x40, 0x05, 0x00, 0x00, 0xFC };
DeviceAddress Thermistor4 = { 0x28, 0x37, 0xB6, 0x40, 0x05, 0x00, 0x00, 0x70 };
DeviceAddress Thermistor5 = { 0x28, 0x8A, 0x1E, 0x41, 0x05, 0x00, 0x00, 0xBF };
int Red = 2;
int Green = 3;
int Blue = 4;
void setup(void)
{
// Start serial port
Serial.begin(9600);
// Start the library
sensors.begin();
// Sets the resolution to 12 bit
sensors.setResolution(Thermistor1, 10);
sensors.setResolution(Thermistor2, 10);
sensors.setResolution(Thermistor3, 10);
sensors.setResolution(Thermistor4, 10);
sensors.setResolution(Thermistor5, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
pinMode(Red, OUTPUT);
pinMode(Green, OUTPUT);
pinMode(Blue, OUTPUT);
}
void loop(void)
{
delay(5000);
Serial.print("Getting temperature...\n\r");
sensors.requestTemperatures();
Serial.print("Thermistor 1 temperature is: ");
printTemperature(Thermistor1);
Serial.print("\n\r");
Serial.print("Thermistor 2 temperature is: ");
printTemperature(Thermistor2);
Serial.print("\n\r");
Serial.print("Thermistor 3 temperature is: ");
printTemperature(Thermistor3);
Serial.print("\n\r");
Serial.print("Thermistor 4 temperature is: ");
printTemperature(Thermistor4);
Serial.print("\n\r");
Serial.print("Thermistor 5 temperature is: ");
printTemperature(Thermistor5);
Serial.print("\n\r\n\r");
}
sketch_jul21a.ino (1.95 KB)