Hi you all.
New to Arduino and in need of some help.
I'm trying to display the temperature from the DS18B20 in my lcd but I can't get it to do what I would like.
What I got to so far:
As you can see the temp. input repeats itself over and over.
What I want:
I'd like to have the temp. input update whithout printing another line in the lcd and also without blinking.
How do I go about doing this? Could you please help me understand what I need to do!
I have no real codingexperience but I'm willing to learn and understand the basics at least.
Here is the code I use:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
//Setup lcd
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress Probe012 = { 0x28, 0x6B, 0xE5, 0xE3, 0x03, 0x00, 0x00, 0x08 };
//DeviceAddress Probe013 = { 0×28, 0×43, 0×77, 0×22, 0×03, 0×00, 0×00, 0x9D };
//DeviceAddress Probe014 = { 0×28, 0×30, 0×65, 0×31, 0×03, 0×00, 0×00, 0×13 };
//DeviceAddress Probe015 = { 0×28, 0xDE, 0x9D, 0×31, 0×03, 0×00, 0×00, 0xB1 };
//DeviceAddress Probe016 = { 0×28, 0x7E, 0x8A, 0×31, 0×03, 0×00, 0×00, 0xC0 };
void setup(void)
{
// start lcd
lcd.begin(20, 4);
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(Probe012, 10);
//sensors.setResolution(Probe013, 10);
//sensors.setResolution(Probe014, 10);
//sensors.setResolution(Probe015, 10);
//sensors.setResolution(Probe016, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
}
else
{
lcd.print("C: ");
lcd.print(tempC);
//Serial.print(” F: “);
//Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(void)
{
delay(2000);
Serial.println();
Serial.println();
Serial.print("Getting temperatures\n\r");
sensors.requestTemperatures();
Serial.print("Probe 012 temperature is: ");
printTemperature(Probe012);
Serial.print("\n\r");
//Serial.print(“Probe 013 temperature is: “);
//printTemperature(Probe013);
//Serial.print(“\n\r”);
//Serial.print(“Probe 014 temperature is: “);
//printTemperature(Probe014);
//Serial.print(“\n\r”);
//Serial.print(“Probe 015 temperature is: “);
//printTemperature(Probe015);
//Serial.print(“\n\r”);
//Serial.print(“Probe 016 temperature is: “);
//printTemperature(Probe016);
//Serial.print(“\n\r”);
}