- Fri May 04, 2018 9:20 am
#199140
The below code will give me a valid temperature readings from a DS18B20, as long as I COMMENT OUT the TeensyView code. For when it is included, all I get then is a constant reading of -127.00 for C and a reading of -196.60 for F.
Just by commenting out all TeensyView code EXCEPT FOR "#include <TeensyView.h>" and "oled.begin();" will cause this effect to take place.
#################################################
#include <TeensyView.h>
#include <DallasTemperature.h>
#include <OneWire.h>
///////////////////////////////////
// TeensyView Object Declaration //
///////////////////////////////////
//Standard
#define PIN_RESET 15
#define PIN_DC 5
#define PIN_CS 10
#define PIN_SCK 13
#define PIN_MOSI 11
#define ONE_WIRE_BUS 12
TeensyView oled(PIN_RESET, PIN_DC, PIN_CS, PIN_SCK, PIN_MOSI);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup()
{
oled.begin(); // Initialize the OLED
oled.clear(ALL); // Clear the display's internal memory
delay(1000); // Delay 1000 ms
oled.clear(PAGE); // Clear the buffer.
sensors.begin();
}
void loop()
{
oled.clear(PAGE); // Clear the page
oled.setFontType(1); // Set font to type 1
oled.setCursor(0, 17); // move cursor
oled.print("TEMP = "); // Write a byte out as a charact
oled.println(sensors.getTempCByIndex(0));
oled.display(); // Send the PAGE to the OLED memory
Serial.print("TEMP = ");
Serial.println(sensors.getTempCByIndex(0));
delay(200);
}
Just by commenting out all TeensyView code EXCEPT FOR "#include <TeensyView.h>" and "oled.begin();" will cause this effect to take place.
#################################################
#include <TeensyView.h>
#include <DallasTemperature.h>
#include <OneWire.h>
///////////////////////////////////
// TeensyView Object Declaration //
///////////////////////////////////
//Standard
#define PIN_RESET 15
#define PIN_DC 5
#define PIN_CS 10
#define PIN_SCK 13
#define PIN_MOSI 11
#define ONE_WIRE_BUS 12
TeensyView oled(PIN_RESET, PIN_DC, PIN_CS, PIN_SCK, PIN_MOSI);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup()
{
oled.begin(); // Initialize the OLED
oled.clear(ALL); // Clear the display's internal memory
delay(1000); // Delay 1000 ms
oled.clear(PAGE); // Clear the buffer.
sensors.begin();
}
void loop()
{
oled.clear(PAGE); // Clear the page
oled.setFontType(1); // Set font to type 1
oled.setCursor(0, 17); // move cursor
oled.print("TEMP = "); // Write a byte out as a charact
oled.println(sensors.getTempCByIndex(0));
oled.display(); // Send the PAGE to the OLED memory
Serial.print("TEMP = ");
Serial.println(sensors.getTempCByIndex(0));
delay(200);
}