hi ive got this code( the dallas multiple temperature one) which i have modified to output to a serial LCD, it outputs fine to the serial port immediatley and VERY frequently, but when i output it to the LCD (activate the code to 'lcd.print(something)' ) the values are only updated every 6 secconds as opposed to 1 or 2, which happens to be the amount of time it takes to do a full loop of the calculations and the runthrough of the lcd commands with the delay.
if i remove the delay it outputs fine, but i cannot read the results on the LCD as their too fast, help pls
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define ONE_WIRE_BUS 10 //digital pin 10
#define TEMPERATURE_PRECISION 12 //12byte precision so i get more than just XX.50 Celcius etc
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// arrays to hold device addresses
DeviceAddress Tture1, Tture2;
DeviceAddress Tture3;
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
if (!sensors.getAddress(Tture1, 0)) Serial.println("Unable to find address for Device 0");
if (!sensors.getAddress(Tture2, 1)) Serial.println("Unable to find address for Device 1");
if (!sensors.getAddress(Tture3, 2)) Serial.println("Unable to find address for Device 2");
// show the addresses we found on the bus
Serial.print("Device 0 Address: ");
printAddress(Tture1);
Serial.println();
Serial.print("Device 1 Address: ");
printAddress(Tture2);
Serial.println();
Serial.print("Device 2 Address: ");
printAddress(Tture3);
Serial.println();
sensors.setResolution(Tture1, 12);
sensors.setResolution(Tture2, 12);
sensors.setResolution(Tture3, 12);
Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(Tture1), DEC);
Serial.println();
Serial.print("Device 1 Resolution: ");
Serial.print(sensors.getResolution(Tture2), DEC);
Serial.println();
Serial.print("Device 2 Resolution: ");
Serial.print(sensors.getResolution(Tture3), DEC);
Serial.println();
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 8) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}
/*
device 0 = 286A98BA0200005E
device 1 = 28AEA2BA02000024
device 2 = 288195BA02000063
*/
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress); //the LOT
Serial.print("Temp C: ");
Serial.print(tempC);
// float temp1 = sensors.getTempC(Tture1);
// float temp2 = sensors.getTempC(Tture2);
// float temp3 = sensors.getTempC(Tture3);
lcd.begin(16, 2);
lcd.clear();
lcd.print("TEST1 ");
lcd.print(sensors.getTempCByIndex(0));
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("TEST2 ");
lcd.print(sensors.getTempCByIndex(1));
lcd.print("C");
delay(1000);
// float temp3 = sensors.getTempC(Tture3);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("TEST3 ");
lcd.print(sensors.getTempCByIndex(2));
lcd.print("C");
delay(1000);
}
// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
Serial.print("Resolution: ");
Serial.print(sensors.getResolution(deviceAddress));
Serial.println();
}
// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
Serial.print("Device Address: ");
printAddress(deviceAddress);
Serial.print(" ");
printTemperature(deviceAddress);
Serial.println();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus
Serial.print("Loading...");
sensors.requestTemperatures();
Serial.println("DONE");
printData(Tture1);
printData(Tture2);
printData(Tture3);
}