Hello,
I have wireup 2 ds18b20 sensors and made a thermometer
My serial monitor works just fine.
My Nokia screen displays the correct temperatures
BUT
The display resets itself every time a new measurement is acquired.
I have tried all the possible combinations that i can think off in regards the placement of .clearDisplay ,
.begin part of the code.
Please some help so as to make the display NOT blink on and off on each measurement...?
/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h> //for graphics
#include <Adafruit_PCD8544.h> //for Nokia 5110 lcd
#include <Wire.h>
#include <DallasTemperature.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define ONE_WIRE_BUS_PIN 2
float Dimitris;
float Thanos;
//Init Display (SCLK, DIN, D/C, CS, RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
/*-----( Declare objects )-----*/
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS_PIN);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/*-----( Declare Variables )-----*/
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress Probe01 = { 0x28, 0xFF, 0x0F, 0x54, 0xA2, 0x17, 0x05, 0xF5 };
DeviceAddress Probe02 = { 0x28, 0xFF, 0xF3, 0x49, 0xA2, 0x17, 0x05, 0xD7 };
void setup() /****** SETUP: RUNS ONCE ******/
{
// start serial port to show results
Serial.begin(115200);
Serial.print("File:_2probes");
//Serial.println(DALLASTEMPLIBVERSION);
// Initialize the Temperature measurement library
sensors.begin();
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 9);
sensors.setResolution(Probe02, 9);
display.begin();
display.clearDisplay(); // clears the screen and buffer
display.setContrast(60);
}//--(end setup )---
void loop() {
Serial.println();
Serial.print("Number of Devices found on bus = ");
Serial.println(sensors.getDeviceCount());
Serial.print("Getting temperatures... ");
Serial.println();
// Command all devices on bus to read temperature
sensors.requestTemperatures();
Serial.print("Probe 01: ");
printTemperature(Probe01);
Serial.println();
Serial.print("Probe 02: ");
printTemperature(Probe02);
Serial.println();
delay(5000);
sensors.requestTemperatures();
Thanos = (sensors.getTempCByIndex(0));
Dimitris = (sensors.getTempCByIndex(1));
display.begin();
display.setContrast(60);
display.clearDisplay(); // clears the screen and buffer
display.setCursor(0,0);
display.setTextSize(1);
display.println(" Current Temp ");
display.print(Dimitris);
display.println();
display.print(Thanos);
//delay(150);
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
display.clearDisplay();
display.print("Check Probes");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
//Serial.print(" F: ");
//Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}// End printTemperature
//*********( THE END )***********