SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By erdc
#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);
}
By paulvha
#199145
Try to use another pin for ONE_WIRE_BUS than 12. Seems the library is setting standard SPI interface and then pin 12 is set for MISO (on arduino uno).
By paulvha
#199167
does the reading work correctly on pin 8 or 7 when "Just by commenting out all TeensyView code EXCEPT FOR "#include <TeensyView.h>" and "oled.begin();" will cause this effect to take place."
By paulvha
#199176
This issue now os maybe not related to Teensyview. Try use a standard sketch that is part of DS18B20 library and make that work first with pin 7 or 8 (maybe removing Teensy hardware if needed).
By paulvha
#199179
I know, but I understood that at that time the temperature was read correctly as long as you commented out many Teensyview lines. If you now comment out the same lines (using pin 8 or 7 for the DS18B20) ) and still don't get the right temperature, there might be another issue to solve first and then include the Teensyview. The fact that it would not work with pin 12 is was because of SPI/MISO, not sure why it would not work with pin 7 or 8.